如果您的网络连接出现问题并将其配置为DHCP,那么确定您的 IP 地址可能是一项艰巨的任务。使用(Using)静态IP 地址(IP Address)有助于避免联网设备之间的 IP 地址冲突并使其易于管理。本文将向您展示如何在 Windows 11/10 计算机上分配静态 IP 地址。(static IP address)
Windows 11/10中分配静态 IP 地址
在大多数情况下,PC 或计算机的 IP 地址由各自的路由器自动配置为动态主机配置协议(Dynamic Host Configuration Protocol)( DHCP )。这很有用,因为设备会立即连接到您的网络。您可以省去自己为每台新设备手动配置 IP 地址的麻烦。但是,该过程存在一个不足之处——设备的 IP 地址可能会不时更改。
如果您定期共享文件、共享打印机或配置端口转发(Port forwarding),则可能需要设置静态 IP 。我们将看到四种方法来做到这一点:
- 通过控制面板
- 通过 Windows 设置
- 使用 PowerShell
- 使用命令提示符。
1]通过控制面板(Control Panel)设置静态IP地址
右键单击(Right-click)Windows 10任务栏(Taskbar)上可见的网络(或Wi-Fi )图标。
从显示的 2 个选项列表中,选择后一个 -打开网络和 Internet 设置。(Open Network and Internet settings.)
转到Wi-Fi设置并向下滚动一点以找到“相关设置(Related Settings)”部分。找到后,单击此处可见的“更改适配器选项(Change adapter options)”链接。
随即,将打开一个单独的窗口并将您定向到控制面板的(Control Panel)网络连接(Network Connections)部分。
右键单击(Right-click)需要为其设置静态 IP 地址的网络连接,然后选择“属性(Properties)”选项。
之后,选择“网络(Networking)”选项卡下的Internet Protocol Version 4 (TCP/IPv4)属性(Properties)”按钮。
将选择器切换到“使用以下 IP 地址(Use the following IP address)”。
现在根据您的网络设置输入以下字段。
- IP 地址(使用 ipconfig /all命令查找)
- 子网掩码(Subnet Mask)(在家庭网络上,它是 255.255.255.0)
- 默认网关(Default Gateway)(这是您路由器的 IP 地址。)
最后,不要忘记检查“退出时验证设置(Validate settings upon exit)”选项。它可以帮助Windows快速检查您的新 IP 地址和其他相关信息,以确保其正常工作。
如果一切正常,请按“确定”按钮并关闭网络适配器的属性窗口。
2]通过设置(Settings)分配静态IP地址(Assign Static IP Address)
视窗 11
右键单击(Right-click)任务栏(Taskbar)上的Windows按钮,然后从选项列表中选择设置。或者,您可以组合按Win+I直接进入设置。
(Select Network)从左侧面板中选择网络和Internet ,然后展开 Wi-Fi 菜单。(Internet)
选择您当前的连接,即您连接的网络。
当定向到新屏幕时,向下滚动到 IP 分配条目,点击它旁边的编辑按钮。(Edit )
现在,当“IP 设置”窗口弹出时,点击下拉箭头并选择“手动”选项。
将IPv4(IPv4)旁边的切换开关滑动到打开位置。
现在,设置静态 IP 地址。此外,设置子网(Subnet)前缀长度(子网掩码)。如果您的子网掩码为 255.255.255.0,则子网前缀长度(以位为单位)为 24。
完成后,配置默认网关(Default Gateway)地址、首选 DNS(Preferred DNS)地址并保存更改。
视窗 10
单击设置图标并选择“网络和 Internet(Network & Internet) ”选项卡。
选择Wi-Fi > Current连接,即您连接的网络。
向下滚动(Scroll)到 IP 设置部分并点击编辑(Edit)按钮。
然后,当弹出“ IP 设置(IP settings)”窗口时,点击下拉箭头并选择“手动(Manual)”选项。
打开IPv4拨动开关。
现在,设置静态 IP 地址。此外,设置子网(Subnet)前缀长度(子网掩码)。如果您的子网掩码为 255.255.255.0,则子网前缀长度(以位为单位)为 24。
完成后,配置默认网关(Default Gateway)地址、首选 DNS(Preferred DNS)地址并保存更改。
阅读:(Read:) 解释了 IP 地址的类型和类别(Types and Classes of IP addresses explained)。
3]通过PowerShell分配静态IP地址(Assigning Static IP Address)
以管理员身份打开 Powershell(Open Powershell as Administrator)并输入以下命令以查看您当前的网络配置 -
Get-NetIPConfiguration
在此之后,记下以下信息:
- 接口索引
- IPv4地址
- IPv4默认网关
- DNS 服务器。
之后,输入以下命令设置静态 IP 地址,然后按Enter。
New-NetIPAddress -InterfaceIndex 15 -IPAddress 192.168.29.34 -PrefixLength 24 -DefaultGateway 192.168.29.1.
现在,将DefaultGateway更改为网络的默认网关地址。确保将InterfaceIndex编号更改为与您的适配器相对应的编号,并将IPAddress更改为您要分配给设备的 IP 地址。
完成后,键入以下命令以分配DNS服务器地址,然后按Enter。
Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses 10.1.2.1
保存更改并退出。
4]使用命令提示符(Command Prompt)分配静态(Assign)IP地址(Static IP Address)
要使用命令提示符在Windows 10(Windows 10)中设置静态 IP 地址,请遵循以下建议:
右键单击(Right-click)“开始(Start)”按钮并选择“运行”(Run)以打开“运行”(Run)对话框。
在文本框中键入cmd并按Ctrl+Shift+Enter键盘快捷键以管理权限运行命令提示符(run the Command Prompt with administrative privileges)。
在命令提示符(Command Prompt)窗口中,键入以下文本代码:
ipconfig /all
当您按下回车键时,它将显示所有当前的网络配置。
在网络适配器下,记下以下信息:
- IPv4 地址
- 子网掩码
- 默认网关
- DNS 服务器。
之后,执行以下命令设置新的静态 IP 地址:
netsh interface ip set address name="Ethernet0" static ip_address subnet_mask default_gateway
在上面的命令行中,确保将Ethernet0更改为当前网络适配器的名称。
此外,将“ip_address subnet_mask default_gateway”替换为适合您情况的正确值。
再次键入以下命令并按回车键设置DNS服务器地址:
netsh interface ip set dns name="Ethernet0" static dns_server
在上面的命令行中,将Ethernet0替换为当前网络适配器的名称。此外,使用您的DNS(DNS) 服务器(Servers)的正确值更改 dns_server 。
运行上述命令后,键入exit并按Enter关闭命令提示符(Command Prompt)。
我希望这有帮助。(I hope this helps.)
什么是静态 IP 连接?
顾名思义,静态 IP 是一个固定不变的 IP 地址。因此,一旦为您的设备分配了静态 IP 地址,其编号通常保持不变,直到设备退役或您的网络架构发生变化。静态 IP 地址主要用于服务器或其他重要设备。
静态 IP 有什么用?
静态 IP 地址提供了方便的远程访问,这使得使用虚拟专用网络(Private Network)( VPN ) 或其他远程访问程序进行远程工作变得更加容易。此外,它可以实现更可靠的通信 [使用互联网协议(Internet Protocol)语音(Voice)( VoIP ) 进行电话(VoIP)会议或其他语音和视频通信]。
How to set a Static IP Address in Windows 11/10
If you are experiencing trouble with your network connection and have it configured to DHCP then, figuring out your IP addrеss can be quіte a task. Using Static IP Address helps avert IР address conflicts between nеtworked devices and enables their easy management. This article will show you how to assign a static IP address on a Windows 11/10 computer.
Assign a static IP address in Windows 11/10
In most cases, the IP addresses for PCs or computers are automatically configured to Dynamic Host Configuration Protocol (DHCP) by the respective router. This is useful as the devices connect to your network instantly. You save the trouble of manually configuring the IP address for each new device yourself. However, there’s one shortfall associated with the process – The device’s IP address can change from time to time.
Setting a static IP may be required if you regularly share files, share a printer, or when configuring Port forwarding. We will see four methods to do it:
- Via Control Panel
- Via Windows Settings
- Using PowerShell
- Using Command Prompt.
1] Setting a static IP address via Control Panel
Right-click the network (or Wi-Fi) icon visible on Windows 10 Taskbar.
From the list of 2 options displayed, select the latter one – Open Network and Internet settings.
Go to Wi-Fi settings and scroll down a bit to locate ‘Related Settings’ section. When found click on the ‘Change adapter options’ link visible there.
Instantly, a separate window will open and direct you to the Network Connections section of the Control Panel.
Right-click the network connection you need to set a static IP-address for and select ‘Properties‘ option.
After that, select Internet Protocol Version 4 (TCP/IPv4) seen under ‘Networking’ tab and hit the ‘Properties’ button.
Switch the selector to ‘Use the following IP address’.
Now make the entry for the following fields, corresponding to your network setup.
- IP address (Find it using ipconfig /all command)
- Subnet Mask (On a home network, it is 255.255.255.0)
- Default Gateway (It is your router’s IP address.)
In the end, do not forget to check ‘Validate settings upon exit’ option. It helps Windows to quickly check your new IP address and other relevant information to ensure that it works.
If all looks good, press the ‘OK’ button and close out of the network adapter’s properties window.
2] Assign Static IP Address via Settings
Windows 11
Right-click the Windows button on the Taskbar and select Settings from the list of options. Alternatively, you can press Win+I in combination to go to the settings directly.
Select Network & Internet from the side panel on the left and expand the Wi-Fi menu.
Select your current connection, i.e., the network to which you are connected.
When directed to a new screen, scroll down to IP assignment entry, hit the Edit button next to it.
Now, when the ‘IP settings’ window pops up, hit the drop-down arrow and select the ‘Manual’ option.
Slide the toggle next to IPv4 to the On position.
Now, set the static IP address. Also, set the Subnet prefix length (subnet mask). If your subnet mask is 255.255.255.0, then the subnet prefix length in bits is 24.
Once done, configure the Default Gateway address, Preferred DNS address, and Save the changes.
Windows 10
Click Settings icon and choose ‘Network & Internet’ tab.
Select Wi-Fi > Current connection, i.e., network to which you are connected.
Scroll down to IP settings section and hit the Edit button.
Then, when the ‘IP settings’ window pops up, hit the drop-down arrow and select ‘Manual‘ option.
Turn on the IPv4 toggle switch.
Now, set the static IP address. Also, set the Subnet prefix length (subnet mask). If your subnet mask is 255.255.255.0, then the subnet prefix length in bits is 24.
Once done, configure the Default Gateway address, Preferred DNS address and Save the changes.
Read: Types and Classes of IP addresses explained.
3] Assigning Static IP Address via PowerShell
Open Powershell as Administrator and enter the following command to view your current network configuration-
Get-NetIPConfiguration
Following this, note down the following information:
- InterfaceIndex
- IPv4Address
- IPv4DefaultGateway
- DNSServer.
After that, enter the following command to set a static IP address and press Enter.
New-NetIPAddress -InterfaceIndex 15 -IPAddress 192.168.29.34 -PrefixLength 24 -DefaultGateway 192.168.29.1.
Now, change DefaultGateway with the default gateway address of your network. Make sure to change the InterfaceIndex number with the one corresponding to your adapter and IPAddress with the IP address you want to assign to your device.
When done, Type the following command to assign a DNS server address and press Enter.
Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses 10.1.2.1
Save the changes and exit.
4] Assign a Static IP Address using Command Prompt
To set a static IP address in Windows 10 using a command prompt, follow the below suggestions:
Right-click on the Start button and select Run to open the Run dialog box.
Type cmd in the text box and press Ctrl+Shift+Enter keyboard shortcut to run the Command Prompt with administrative privileges.
In the Command Prompt window, type in the following text code:
ipconfig /all
When you press the enter key, it will show all the current network configuration.
Under the network adapter, write down the following information:
- IPv4 Address
- Subnet Mask
- Default Gateway
- DNS Server.
After that, execute the following command to set a new static IP address:
netsh interface ip set address name="Ethernet0" static ip_address subnet_mask default_gateway
In the above command-line, make sure to change Ethernet0 with the name of your current network adapter.
Also, replace the “ip_address subnet_mask default_gateway” the correct values for your case.
Again, type the following command and hit enter to set a DNS server address:
netsh interface ip set dns name="Ethernet0" static dns_server
In the above command-line, replace Ethernet0 with the name of your current network adapter. Also, change dns_server with the correct values of your DNS Servers.
After running the above commands, type exit and press Enter to close the Command Prompt.
I hope this helps.
What is Static IP connection?
A static IP as the name suggests is an IP address that remains fixed and never changes. So, once your device is assigned a static IP address, its number typically stays the same until the device is decommissioned or your network architecture changes. Static IP addresses are mainly used by servers or other important equipment.
What is Static IP used for?
A static IP address offers convenient remote access which makes it easier to work remotely using a Virtual Private Network (VPN) or other remote access programs. Besides, it enables more reliable communication [use Voice over Internet Protocol (VoIP) for teleconferencing or other voice and video communications].