Change the IP address gateway? Use the netsh command

  

We may need to work in different networks. It is a cumbersome task to repeatedly modify the IP address over and over again. In addition, the system has crashed, and it is annoying to reconfigure related parameters such as network cards (especially wireless network cards). In fact, clever use of the built-in netsh command in Windows 2000/XP/2003 system, you can quickly switch the IP address, let's take a look at it.

Here are two usages of netsh, copy them to In the text document, change the suffix name .txt to .cmd and double-click it to execute:

The first one is to use the netsh command to modify the computer's IP address, subnet mask, default gateway and DNS. Br>

@echo off

netsh interface ip set address "local connection" static 192.168.0.1 255.255.255.0 192.168.0.254 1

netsh interface ip set dns "local Connection " static 202.194.40.1

netsh interface ip add dns "local connection" 202.194.40.2 2

Note: The part above marked with blue font is required to be modified. section. The second, third, and fourth lines of "local connection" generally do not need to be modified, depending on your computer right-click "My Network Places", select "properties" & rdquo; appears & ldquo; network connection & rdquo; window Depending on the name of the connection, there is usually only one "local connection".

192.168.0.1 255.255.255.0 192.168.0.254 in the second line The three addresses are IP address, subnet mask and default gateway, and they are replaced with the address you want to modify.

202.194.40.1 in the third line is the DNS address, and you can replace it with the DNS address you want to modify.

202.194.40.2 in the fourth line is the secondary DNS address, which is the second one. Replace it with the second DNS address you want to modify. If not, you can put the fourth line. Just delete it.

The second is to use the netsh command to modify the computer's IP address, subnet mask, default gateway and DNS for dynamic access.

@echo off

netsh interface Ip set address "local connection" dhcp

netsh interface ip set dns "local connection" dhcp

Note: This is relatively simple, just modify it according to your computer's situation The blue font is marked with "local connection", and generally does not need to be modified.

The following article is about the detailed usage of the netsh command. After reading it, you will understand some of its other uses.

In Windows 2000, you can use the netsh command to script the following procedure: change the computer's static Internet Protocol (IP) address to a Dynamic Host Configuration Protocol (DHCP) address or vice versa. The netsh command does not require a restart of the computer to complete this task. This feature is especially useful for portable computers that move from one environment to another when it must use a statically assigned IP address in one location and a DHCP-assigned IP address in another location.

The method described in this article is suitable for Windows 2000, Windows XP and Windows Server 2003.

To switch the static address of the specified adapter to a DHCP address, type the following command:

netsh interface ip set address "local connection" dhcp Note: Typing this command will name The "local connection" interface is changed to DHCP.

To display all adapters on your computer and their current IP address to determine the correct adapter name, type the following command: Netsh interface ip show config To change to a static address, type the following command: netsh interface ip Set address "local connection" static IP mask gateway hops such as: netsh interface ip set address "local connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1

Change the DNS to 192.168. 0.1:netsh interface ip set DNS "local connection" static 192.168.0.1 delete gateway: netsh interface ip delete address "local connection" gateway=all delete DNS:

netsh interface ip delete dns " Local connection " all

If the prompt "invalid interface" is specified when performing the configuration, please open the system's "Remote Registry Service" service. Previous123Next page Total 3 pages

Copyright © Windows knowledge All Rights Reserved