Windows script setting multiple IP

  
        

There is no doubt that setting up IP in windows is very convenient because there is a simple and intuitive interface to operate. Setting the IP through the graphical user interface is generally sufficient, but for those who travel frequently and change jobs, it is time consuming and inconvenient to modify the IP. It is very convenient and quick to put the command to set the IP in a script file.

Set the IP step with the command line (WIN7, set for IPV4):

1. Set a static IP

netsh interface ipv4 set address name="local connection" Source=static addr=192.168.20.11 mask=255.255.255.0 gataway=192.168.20.1 gwmetric=30

The gateway settings for black fonts are optional.

2, set multiple IP, pay attention to the difference between the red part of the command

netsh interface ipv4 set address name="local connection" source=static addr=192.168.20.11 mask=255.255. 255.0 gataway=192.168.20.1 gwmetric=30 netsh interface ipv4 add address name="local connection" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30 This command sets 192.168.20.11, 192.168.1.11 two IP< Br>

3, set to automatically get IP

netsh interface ipv4 set address name="local connection" source=dhcp

4, set the domain name netsh interface ipv4 set dns name= "Local Connection" source=static addr=202.106.0.20 register=PRIMARY

addr is the domain name server address, PRIMARY refers to the primary domain name

Full example:

A, Office LAN uses beijing-office.bat

netsh interface ipv4 set address name="local connection" source=static addr=192.168.20.11 mask=255.255.255.0 gwmetric=30 netsh interface ipv4 add address name= "Local Connection" addr=192.168.1.11 mask=255.255.255.0 Gwmetric=30 REM netsh interface ipv4 set dns name="local connection" source=static addr=202.106.0.20 register=PRIMARY

B, hotel Internet access, suitable for automatic access to IP settings, beijing- Hotal.bat

netsh interface ipv4 set address name="local connection" source=dhcp netsh interface ipv4 set dns name="local connection" source=static addr=202.106.0.20 register=PRIMARY netsh Interface ipv4 add dns name="local connection" addr=202.106.46.151

After creating these two script files, you can execute the corresponding script file in different environments, which is very convenient.

Copyright © Windows knowledge All Rights Reserved