One click modification of IP and DNS in win7 + XP command line

Time:2020-5-8

Students who often go back and forth to the laboratory will often encounter a problem:

Routers in dormitories usually acquire IP automatically,

But in the laboratory, it is usually static IP.

Every time I go back and forth, I have to modify it every day. It’s very troublesome.

Here is a simple method:(this method is under win7, see the last line for XP)

Step 1Create a new TXT file

Step 2:Add the following to the file:

 

Netsh interface IP set address name = “local connection” source = static addr=10.60.37.99 mask=255.255.255.0gateway=10.60.37.254

Netsh interface IP set DNS “local connection” source = static addr=202.120.190.208 
 

Four red parts need to be modified as needed:

10.60.37.99             Is the IP address

255.255.255.0         Is mask address

10.60.37.254           Default Gateway

202.120.190.208     It’s DNS.

 

Step 3:Change the suffix of the txt file from. Txt to. CMD

Step 4:Right click the. CMD file and select run as Administrator

 

be accomplished!

 

 

PS:

If you want to go back to the dormitory and get IP and DNS automatically,

Just create a new CMD file with the following content:

Netsh interface IP set address name = “local connection” source = DHCP

Netsh interface IP set DNS name = “local connection” source = DHCP


The instructions in XP are slightly different:

Netsh interface IP set address name = “local connection” source = static addr = 10.60.37.96 mask = 255.255.255.0

Netsh interface IP set address name = “local connection” gateway = 10.60.37.254 gwmetric = 0

Netsh interface IP set DNS “local connection” source = static addr = 202.120.190.208