在大多数基于Windows(Windows) NT的操作系统中都可以找到命令提示(Command Prompt)应用程序,有时也称为命令 shell 。它的目的是执行特定的命令(execute specific commands)来解决或解决特定的Windows问题、执行高级管理功能以及通过批处理文件和脚本自动执行任务。
也就是说,当您想欺骗它以绕过对其内容施加此类限制的站点的地理封锁或在线禁令时,您也可以使用它来更改您的 IP 地址,或者出于故障排除原因更改您的域名系统( (Domain)DNS(System) )服务器(DNS)或让冲浪更安全、更快捷。
在本指南中,我们将向您展示如何使用Windows 10中的命令提示符更改您的 IP 地址和(Command Prompt)DNS服务器。
如何使用命令提示符更改 IP 地址(How To Change IP Address Using Command Prompt)
IP 地址(IP address)包含有关您的设备、位置、您的互联网服务提供商 ( ISP )(ISP)和浏览器信息的信息。
当您有一个故障路由器提供网络上不同计算机使用的地址或意外配置了无效地址时,更改它很有用。当您想安装新路由器并重新配置家庭网络以使用默认 IP 地址范围时,它也很有帮助。
更改 IP 地址的第一步是找到要更改的接口 的网络名称。(find the network name)
- 通过在搜索栏中键入CMD并单击Run as Administrator打开提升的命令提示符(Command Prompt)。
- 接下来,在命令提示符窗口中键入netsh interface ipv4 show config,按Enter,然后向下滚动到所需的界面。
在我们的案例中,我们将修改WiFi接口,但您可以为您的案例选择正确的接口。记下接口名称 。(Make)
- 要更改 IP 地址,请键入以下命令:netsh interface ipv4 set address name=”YOUR INTERFACE NAME” static IP_ADDRESS SUBNET_MASK GATEWAY
在我们的示例中,此命令如下所示:netsh interface ipv4 set address name=”Wi-Fi” static 192.168.0.173 255.255.255.0 192.168.0.0
该命令将使用 Wi-Fi 接口,将 IP 地址设置为 192.168.0.173,将子网掩码设置为 255.255.255.0,并将默认网关设置为 192.168.0.0。
如果要切换到使用DHCP服务器自动分配的 IP 地址而不是静态 IP 地址,请使用netsh interface ipv4 set address name=”YOUR INTERFACE NAME” source=dhcp 命令。
如何使用命令提示符更改 DNS 服务器(How To Change DNS Servers Using Command Prompt)
DNS服务器 在数据库中保存公共 IP 地址和相关主机名,并用于将主机名解析或转换为 IP 地址。服务器通过运行特殊软件,根据来自计算机的某些请求,通过特殊协议与其他服务器进行通信来做到这一点。
转换过程经过彻底的审查和验证,并且在幕后迅速发生,以便获得与计算机正在寻找的服务器对应的信息,然后告诉原始连接计算机去哪里以便它可以连接到该服务器.
您想要更改默认 DNS 服务器(change your default DNS server)的原因有很多,但主要原因是:
- 在绕过防火墙、绕过网站上的地理封锁或ISP封锁时增强您的隐私
- 提高安全性
- 家长控制,例如从您的路由器阻止网站(blocking websites from your router)
- 加快您的冲浪速度,您自己的 ISP 的DNS服务器可能无法提供,因为它们并不总是可靠或最新的
注意:您可以在路由器或计算机、智能手机和(Note)Chromebook以及其他设备上为您的家庭网络单独更改DNS服务器(DNS)
如何使用命令提示符更改(Command Prompt)DNS 服务器(Servers)
按照以下步骤了解如何使用命令提示符更改(Command Prompt)DNS服务器。
- 通过在搜索栏中键入CMD并单击以管理员身份运行(Run as Administrator)来打开提升的命令提示符(Command Prompt)。
- 接下来,输入interface ip show config并按Enter。
- 找到要更改其DNS服务器的网络接口,然后输入(DNS)netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER。这将设置您的主DNS服务器。
在上面的示例中,我们更改了“Wi-Fi”接口的 IP 地址,因此我们将使用相同的示例来更改DNS服务器。
在本指南中,我们将使用 Google 的主要公共DNS服务器 8.8.8.8。该命令将如下所示:netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.8.8
- 接下来,键入netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER index=2 命令设置辅助DNS服务器。同样(Again),我们将使用 Google 的公共DNS辅助服务器 8.8.8.8 作为示例,如下所示:netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.4.4 index=2.
注意(Note):如果您希望网络接口自动从DHCP服务器中选择DNS设置,您可以使用 netsh interface ipv4 set dnsservers name”YOUR INTERFACE NAME” source=dhcp继续我们的示例,此命令如下所示:netsh interface ipv4 set dnsservers name”Wi-Fi” source=dhcp
结论(Conclusion)
(Command Prompt)当您想要更改 IP 地址和DNS服务器时,命令提示符是一个很好的工具。它更快,并且省去了您必须从控制面板(Control Panel)界面单击多个窗口和对话框才能进入IPv4 属性(IPv4 Properties)对话框来执行相同操作的麻烦。
(Was)本指南有帮助吗?通过在下面的部分中删除您的评论,让我们知道。
Change IP Address and DNS Servers using the Command Prompt
The Command Prompt apрlication, sometimes referred to as сommand ѕhell, is found in most Windows NT-basеd operating systems. Its purpose is to execute specific commands for troubleshooting or solving specific Windows issues, performing advanced administrative functions, and automating tasks via batch files and scripts.
That said, you can also use it to change your IP address when you want to spoof it to bypass geoblocks or online bans on sites that impose such restrictions on their content, or change your Domain Name System (DNS) servers for troubleshooting reasons or to make surfing more secure and faster.
In this guide, we’re going to show you how to change your IP address and DNS servers using the Command Prompt in Windows 10.
How To Change IP Address Using Command Prompt
An IP address holds information about your device, location, your internet service provider (ISP), and browser information.
Changing it is useful when you have a malfunctioning router that’s providing addresses used by a different computer on the network or an invalid address is accidentally configured. It’s also helpful when you want to install a new router and reconfigure your home network to use the default IP address range.
The first step to changing your IP address is to find the network name for the interface you want to change.
- Open an elevated Command Prompt by typing CMD in the search bar and clicking on Run as Administrator.
- Next, type netsh interface ipv4 show config in the command prompt window, press Enter, and scroll down to the interface you want.
In our case, we’ll be modifying the WiFi interface, but you can pick the correct interface for your case. Make note of the interface name.
- To change the IP address, type this command: netsh interface ipv4 set address name=”YOUR INTERFACE NAME” static IP_ADDRESS SUBNET_MASK GATEWAY
In our example, this command would look like this: netsh interface ipv4 set address name=”Wi-Fi” static 192.168.0.173 255.255.255.0 192.168.0.0
This command will use the Wi-Fi interface, set the IP address to 192.168.0.173, set the subnet mask to 255.255.255.0 and set the default gateway to 192.168.0.0.
If you want to switch to using an IP address automatically assigned by a DHCP server instead of a static IP address, use the netsh interface ipv4 set address name=”YOUR INTERFACE NAME” source=dhcp command.
How To Change DNS Servers Using Command Prompt
A DNS server holds public IP addresses and related hostnames in a database, and is used to resolve or translate the hostnames to IP addresses. The server does this by running special software to communicate with other servers through special protocols based on certain requests from the computer.
The conversion process is thoroughly vetted and verified, and it happens quickly behind the scenes so as to obtain information corresponding to the server that the computer is looking for, and then tells the original connecting computer where to go so that it can connect to that server.
There are several reasons why you’d want to change your default DNS server, but the main ones are:
- Boost your privacy when getting around a firewall, bypassing geoblocks or ISP blocks on a website
- Increase security
- Parental controls like blocking websites from your router
- Speed your surfing, which your own ISP’s DNS servers may not offer because they’re not always reliable or up-to-date
Note: You can change DNS servers individually for your home network on your router or on computers, smartphone, and Chromebook, among other devices
How To Change DNS Servers With Command Prompt
Follow the steps below to learn how to change DNS servers using Command Prompt.
- Open an elevated Command Prompt by typing CMD in the search bar, and clicking Run as Administrator.
- Type netsh and press Enter.
- Next, type interface ip show config and press Enter.
- Find the network interface whose DNS server you want to change, and enter the netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER. This will set your primary DNS server.
From our example above, we changed the IP address for the “Wi-Fi” interface, so we’ll use the same example to change DNS servers.
For purposes of this guide, we’ll use Google’s primary public DNS server, 8.8.8.8. The command will look something like this: netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.8.8
- Next, type the netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER index=2 command to set the secondary DNS server. Again, we’ll use Google’s public DNS secondary server, 8.8.8.8 as an example, which will look like this: netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.4.4 index=2.
Note: You can use the netsh interface ipv4 set dnsservers name”YOUR INTERFACE NAME” source=dhcp command if you want the network interface to automatically pick DNS settings from a DHCP server. Continuing with our example, this command would look like this: netsh interface ipv4 set dnsservers name”Wi-Fi” source=dhcp
Conclusion
Command Prompt is a great tool to use when you want to change IP addresses and DNS servers. It’s faster and saves you the hassle of having to click through several windows and dialog boxes from the Control Panel interface just to get to the IPv4 Properties dialog box to do the same thing.
Was this guide helpful? Let us know by dropping your comment in the section below.