Windows Scripting sets multiple IPs

Source: Internet
Author: User
Tags domain name server

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.