There is no doubt that setting up IP in Windows is convenient because there is a simple and intuitive interface to work with. Setting up IP through a 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 place commands that set the IP in a script file.
Set IP steps with the command line (WIN7, set for IPV4):
1. Set up a static IP
netsh interface ipv4 set address name= "Local Area Connection" Source=static addr=192.168.20.11 mask=255.255.255.0 gataway= 192.168.20.1 gwmetric=30
The Gateway Settings section of the black font is optional.
2, set multiple IP, note the difference between the red part of the instructions
netsh interface IPv4 set address name= "Local Area Connection" Source=static addr=192.168.20.11 mask=255.255.255.0 gataway= 192.168.20.1gwmetric=30
netsh interface IPv4 add address name= "Local Area Connection" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
This command sets the 192.168.20.11,192.168.1.11 two IP
3, set the automatic acquisition of IP
netsh interface ipv4 set address name= "Local Area Connection" Source=dhcp
4. Set the domain name
netsh interface ipv4 set DNS name= "Local Area Connection" Source=static addr=202.106.0.20 register=primary
Addr is the domain name server address, primary refers to the primary domain name
Complete Example:
A, office LAN use Beijing-office.bat
netsh interface ipv4 set address name= "Local Area Connection" Source=static addr=192.168.20.11 mask=255.255.255.0 gwmetric=30
netsh interface ipv4 add address name= "Local Area Connection" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
REM netsh interface ipv4 set DNS name= "Local Area Connection" Source=static addr=202.106.0.20 register=primary
B, the hotel for Internet use, for the automatic acquisition of IP settings, Beijing-hotal.bat
netsh interface ipv4 set address name= "Local Area Connection" Source=dhcp
netsh interface ipv4 set DNS name= "Local Area Connection" Source=static addr=202.106.0.20 register=primary
netsh interface ipv4 add DNS name= "Local Area Connection" addr=202.106.46.151
After creating these two script files, it is very convenient to execute the corresponding script files in different environments.