Batch change IP Address

Source: Internet
Author: User
Tags dns2
@ Echo off
Rem ETH // set the NIC name, for example, "Local Connection"
Set Eth = "Local Connection"
Rem IP // set the IP address
Set IP = 10.11.12.163
Rem GW // set the Gateway
Set GW = 10.11.0000254
Rem netmasks // sets the subnet mask.
Set netmasks = 255.255.0.0
Rem dns1 // set the primary DNS
Set dns1 = 202.96.75.68
Rem dns2 // configure secondary DNS
Set dns2 = 202.96.64.68
ECHO is changing the local IP address to: % IP %
Netsh interface IP Set address "% ETH %" static % IP % netmasks % GW % default
ECHO is adding host DNS: % dns1 %
Netsh interface IP Set DNS "% ETH %" static % dns1 %
Echo adding local secondary DNS: % dns2 %
Netsh interface IP add DNS "% ETH %" % dns2 %

Echo ---------------------------------
Echo IP changed. Wow, haha...
Echo ---------------------------------
Pause
Close

Modify IP addresses using batch processing

The school always involves modifying the IP address when accessing the Internet. It is troublesome to manually modify the local connection each time. After searching for the IP address on the internet, I finally found a method to modify the IP address in batches, which is easy to use.

Create a text file on the desktop and name it change. bat. You can use NotePad to open the file by yourself. Enter the followingCode:

@ Echo off

Netsh interface name = "Local Connection" IP Set Address Source = static ADDR = 222.206.193.246 mask = 255.255.254.0 gateway = 222.206.193.254 1
Netsh interface name = "Local Connection" IP Set DNS source = static ADDR = 211.64.142.6

Parameter Introduction: netsh is a win command, so you don't need to worry about it. The name value is the same as your local connection, because some dual-network interfaces may be "local connection 2 ", static after source indicates that static IP addresses are used instead of automatically obtained. The last sentence is used to set the DNS address. The IP address, subnet mask, and gateway address are all set as needed.

If you want to change the IP address to automatically get it, create change2.bat and enter the following code:

@ Echo off
Netsh interface name = "Local Connection" IP Set Address Source = DHCP
Netsh interface name = "Local Connection" IP Set DNS source = DHCP

DHCP indicates automatic retrieval.

OK, run change. in the BAT file, a command prompt window will pop up. Wait a moment, the confirmation text will appear, and the window will disappear. At this time, you can check your IP address. The command is ipconfig/All, you will find that the IP address is as expected. If you want to change it to automatic retrieval, run the second BAT file.

Haha, once and for all, it's amazing.

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.