命令提示符修改电脑ip_如何从命令提示符更改计算机的IP地址

命令提示符修改电脑ip

命令提示符修改电脑ip

icp_top

It’s easy enough to change an IP address on your PC using Control Panel, but did you know you can also do it from the Command Prompt?

使用控制面板更改PC上的IP地址很容易,但是您知道也可以从命令提示符处进行操作吗?

Changing your IP address with the Control Panel interface isn’t difficult, but it does require clicking through a number of different windows and dialog boxes. If you’re a fan of the Command Prompt, though, you can get it done more quickly using the netsh command, which is just one of the great network utilities built into Windows.

使用“控制面板”界面更改IP地址并不困难,但这确实需要单击多个不同的窗口和对话框。 但是,如果您是命令提示符的粉丝,则可以使用netsh命令更快地完成它,它只是Windows内置的出色网络实用程序之一。

The netsh command allows you to configure just about any aspect of your network connections in Windows. To work with it, you’ll need to open Command Prompt with administrative privileges. In Windows 10 or 8.1, right-click the Start menu (or press Windows+X on your keyboard) and choose “Command Prompt (Admin).” In previous versions of Windows, search Start for “command prompt” and then right-click the result and choose “Run as Administrator.”

netsh命令允许您在Windows中配置网络连接的几乎任何方面。 要使用它,您需要使用管理权限打开命令提示符。 在Windows 10或8.1中,右键单击“开始”菜单(或在键盘上按Windows + X),然后选择“命令提示符(管理员)”。 在Windows的早期版本中,在“开始”中搜索“命令提示符”,然后右键单击结果并选择“以管理员身份运行”。

查看您的网络信息 (View Your Network Information)

Before you change your IP address and related information, you’ll need to find the full name of the network for the interface you want to change. To do this, type the following command:

在更改IP地址和相关信息之前,您需要找到要更改的接口的网络全名。 为此,请键入以下命令:

netsh interface ipv4 show config
icp_1

Scroll down until you see the interface you’re looking for. In our example, we’re going to modify the Wi-Fi interface, which on our machine is just named “Wi-Fi.” You’ll also see other default names that Windows assigns to interfaces, such as “Local Area Connection,” “Local Area Connection* 2,” and “Ethernet.” Just find the one you’re looking for and make note of the exact name. You can also copy and paste the name to Notepad and then back into Command Prompt later to make things easier.

向下滚动,直到看到所需的界面。 在我们的示例中,我们将修改Wi-Fi接口,该接口在我们的计算机上被命名为“ Wi-Fi”。 您还将看到Windows分配给接口的其他默认名称,例如“ Local Area Connection”,“ Local Area Connection * 2”和“ Ethernet”。 只需找到您要寻找的那个,并记下确切名称即可。 您还可以名称复制并粘贴到“记事本”中,然后稍后再返回到“命令提示符”中,以简化操作。

更改您的IP地址,子网掩码和默认网关 (Change Your IP Address, Subnet Mask, and Default Gateway)

With the interface name in hand, you’re ready to change the IP Address, subnet mask, and gateway. To do this, you’ll issue a command using the following syntax:

有了接口名称,您就可以更改IP地址,子网掩码和网关。 为此,您将使用以下语法发出命令:

netsh interface ipv4 set address name="YOUR INTERFACE NAME" static IP_ADDRESS SUBNET_MASK GATEWAY

So, for example, your command might look something like the following:

因此,例如,您的命令可能类似于以下内容:

netsh interface ipv4 set address name="Wi-Fi" static 192.168.3.8 255.255.255.0 192.168.3.1

where the info is replaced by whatever you want to use. In our example, the command does the following:

其中的信息将替换为您要使用的任何内容。 在我们的示例中,该命令执行以下操作:

  • Uses the interface name “Wi-Fi”

    使用接口名称“ Wi-Fi”
  • Sets the IP address to 192.168.3.1

    将IP地址设置为192.168.3.1
  • Sets the subnet mask to 255.255.255.0

    将子网掩码设置为255.255.255.0
  • Sets the default gateway to 192.168.3.1

    将默认网关设置为192.168.3.1

And if you’re using a static IP address but want to switch to using an IP address assigned automatically by a DHCP server–such as your router–you can use the following command instead:

如果您使用的是静态IP地址,但想切换为使用DHCP服务器自动分配的IP地址(例如路由器),则可以改用以下命令:

netsh interface ipv4 set address name=”YOUR INTERFACE NAME” source=dhcp

更改您的DNS设置 (Change Your DNS Settings)

You can also use the netsh command to change the DNS servers used by a network interface. Third-party DNS servers–like Google Public DNS and OpenDNS–can be faster and more reliable than the DNS servers provided by your ISP. Whatever your reason for changing your DNS server, you can do it either at the router so it affects all the devices that get their information from the router or at the individual device. If you want to change the DNS servers for just one PC, it’s easy to do with the netsh command.

您还可以使用netsh命令更改网络接口使用的DNS服务器。 第三方DNS服务器(例如Google Public DNSOpenDNS )可能比ISP提供的DNS服务器更快,更可靠。 无论出于何种原因更改DNS服务器 ,都可以在路由器上进行操作,这样会影响从路由器或单个设备上获取其信息的所有设备。 如果只想在一台PC上更改DNS服务器,则使用netsh命令很容易。

You’ll need to use the command twice: once to set your primary DNS server and once to set your secondary, or backup, DNS server. To set your primary DNS server, use the following syntax:

您将需要使用两次命令:一次设置主DNS服务器,一次设置辅助DNS服务器或备用DNS服务器。 要设置主DNS服务器,请使用以下语法:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER

So, for example, your command might look something like the following (in which we set it to Google’s primary public DNS server, 8.8.8.8):

因此,例如,您的命令可能类似于以下内容(其中将其设置为Google的主要公共DNS服务器8.8.8.8):

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.8.8

To set your secondary DNS server, you’ll use a very similar command:

要设置辅助DNS服务器,您将使用非常类似的命令:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER index=2

So, continuing our example, you might set your secondary DNS as the Google Public DNS secondary server, which is 8.8.4.4:

因此,继续我们的示例,您可以将辅助DNS设置为8.8.4.4的Google Public DNS辅助服务器:

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.4.4 index=2

And just like with the IP address, you can also change it so that the network interface grabs its DNS settings automatically from a DHCP server instead. Just use the following command:

就像IP地址一样,您也可以对其进行更改,以使网络接口可以从DHCP服务器自动获取其DNS设置。 只需使用以下命令:

netsh interface ipv4 set dnsservers name"YOUR INTERFACE NAME" source=dhcp

And there you have it. Whether you like typing at the command prompt better or just want to impress your coworkers, now you know all the command line magic you need for changing your IP address settings.

那里有。 无论您是想更好地在命令提示符下键入命令,还是想打动同事,现在您都知道更改IP地址设置所需的所有命令行技巧。

翻译自: https://www.howtogeek.com/103190/change-your-ip-address-from-the-command-prompt/

命令提示符修改电脑ip

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值