Windows Script sets multiple IP addresses and script ip addresses

Source: Internet
Author: User
Tags domain name server

Windows Script sets multiple IP addresses and script ip addresses

There is no doubt that setting IP addresses in windows is very convenient, because there is a simple and intuitive interface for operation. Setting IP addresses through the graphic user interface is usually enough, but for those who often go on a business trip and change their work place, it is time-consuming and inconvenient to modify the IP address. If you place the IP Address Setting command in a script file for execution, it is very convenient and fast.

Set the IP address using the command line (WIN7, for IPV4 ):

1. Set a static IP Address

Netsh interface ipv4 set address name = "Local Connection" source = static addr = 192.168.20.11 mask = 255.255.255.0Gataway = 192.168.20.1Gwmetric = 30

The gateway settings in the black font are optional.

2. Set multiple IP addresses. Pay attention to the difference between the Red commands.

Netsh interface ipv4SetAddress name = "Local Connection" source = static addr = 192.168.20.11 mask = 255.255.255.0Gataway = 192.168.20.1Gwmetric = 30
Netsh interface ipv4AddAddress name = "Local Connection" addr = 192.168.1.11 mask = 255.255.255.0 gwmetric = 30
This command sets two IP addresses: 192.168.255.11 and 192.168.1.11.

3. Set automatic IP address acquisition

Netsh interface ipv4 set address name = "Local Connection" source = dhcp

4. Set domain names
Netsh interface ipv4 set dns name = "Local Connection" source = static addr = 202.106.0.20 register = PRIMARY

Addr is the Domain Name Server address, and PRIMARY is the PRIMARY domain name.


Complete example:

A. Office lan use 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, suitable for automatic acquisition of 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 only need to execute the corresponding script files in different environments, which is very convenient.



How can I write a script to automatically ping and tracert many IP addresses in linux and windows, and output results for each IP address? Use for loop ping for scheduled tasks at in windows
Using crontab-e in LINUX and using for loop ping
In Windows 7, how do I add multiple IP addresses? Right-click "Network Neighbor" on the desktop and choose "properties". On the Network Manager page, select "Change adapter Settings". On the local connection of the NIC, select "properties"> "network"> "Internet Protocol Version 4" (TCP/IPv4) click properties, click the advanced ipsettings tab, and click Add to enter the corresponding IP address.

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.