Use batch files to quickly and dynamically modify IP addresses, default gateway and DNS

Source: Internet
Author: User

My lab has two types of networks: Iron Tong network, which can be used to access websites outside China. However, it is slow to access the CERNET and cannot access libraries and forums in the school. The other is CERNET, access to CERNET is fast, and you can access libraries and forums on campus, but you cannot access websites outside China.

You can't have both the fish and the bear's paw! Because I often use library resources and on-campus forums, and frequently access foreign websites, I always switch between these two networks. In this way, you have to use the Windows dialog box each time. It takes several steps to complete the operation, and it is too time-consuming.

To switch the two networks in our lab, you only need to modify the gateway and DNS, so I found a simple method that greatly saves the switching time. The method is as follows:

Copy the following code, such as Notepad, and save it as "Iron Tong. Bat"

Netsh interface IP Set address local connection static 192.168.0.107 255.255.255.0 192.168.0.1 1
Netsh interface IP Set DNS local connection static 192.168.0.1

Copy the following code as Notepad and save it as "CERNET. Bat"

Netsh interface IP Set address local connection static 192.168.0.107 255.255.255.0 192.168.0.2 1
Netsh interface IP Set DNS local connection static 192.168.0.2

Explanation: The static line is followed by an IP address, subnet mask, default gateway, and parameter 1.

The second line is static followed by DNS

Then, when switching, you only need to double-click the corresponding file.

If you have any questions in this article, you can contact me: hjhinternet@163.com

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.