Gadget for automatically changing IP under Windows (Bat batch file)

Source: Internet
Author: User

Every time on-line, we must first on the grayscale environment and then to the formal environment. In a grayscale environment, access to the grayscale environment is achieved by automatically acquiring the IP and changing the specified DNS. Concrete how to realize, we can Baidu by ourselves.

Create a new text document, change the suffix to bat, open the file, and copy the code:

@echo off: StartEcho============Please enter a number to select the next action:Echo============1: IP is set to grayscaleEcho============2: IP set to original IPSet/P var= ":"if%var%==1GotoIP10if%var%==2Gotoip172: Ip10CLSnetsh interface ipSetAddress Name= "Local Area Connection" source=dhcpnetsh Interface IP Delete DNS"Local Area Connection"Allipconfig/Flushdnscmd/C netsh interface ipSetDNS name= "Local Area Connection" Source=static addr=192.168.0.216 register=PrimaryEcho**ip set to grayscale, set success * *Echo ------------------------------------------Goto Start: ip172CLSnetsh interface ipSetAddress Name= "Local Area Connection" Source=static addr=192.168.1.132 mask=255.255.255.0 gateway=192.168.3.254cmd/C netsh interface ipSetDNS name= "Local Area Connection" Source=static addr=180.76.76.76 register=Primarycmd/C netsh interface ip add DNS name= "Local Area Connection" addr=8.8.8.8 index=2Echo**ip set to 192.168.1.132, Set success * *Echo ------------------------------------------Goto Start

Save exit, double click to run, the effect is as follows:

To view the network configuration, the IP has been changed.

You can add statements yourself if you have more requirements in real life.

Gadget for automatically changing IP under Windows (Bat batch file)

Related Article

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.