I use a dynamic IP Address at home and a fixed IP address in my company, so I often need to switch back and forth ipsettings, which is very troublesome! Today, I can't bear it. I have compiled a script to ease the trouble of switching back and forth IP addresses! For fear of forgetting, please keep a record!
@ echo offrem // set the variable set name = "Local Connection" REM // The following attribute values can be changed as needed: Set ADDR = 172.16.18.184set mask = 255.255.255.0set gateway = 172.16.18.254set dns1 = 172.16.17.1set dns2 = 8.8.8.8rem/the above attributes are IP addresses, subnet masks, gateways, preferred DNS, and alternate dnsecho currently available operations: echo 1 is set to static ipecho 2 is set to dynamic ipecho 3 Exit echo select and press Enter: set/P operate = If % operate % = 1 goto 1if % operate % = 2 goto 2if % operate % = 3 goto 3: 1 ECHO is setting static IP, please wait... rem // Root Modify the echo IP address as needed = % ADDR % echo mask = % mask % echo gateway = % gateway % netsh interface IPv4 set address name = % name % source = static ADDR = % ADDR % mask = % mask % gateway = % gateway % gwmetric = 0> NUL echo preferred DNS = % dns1 % netsh interface IPv4 set DNS name = % name % source = static ADDR = % dns1 % register = primary> NUL echo backup DNS = % dns2 % netsh interface IPv4 add DNS name = % name % ADDR = % dns2 % Index = 2> NUL echo static IP already set! Pausegoto 3: 2 Echo is setting a dynamic IP address. Please wait... ECHO is automatically obtaining the IP address from DHCP... netsh interface IP Set address "Local Connection" dhcpecho is automatically obtaining the DNS address from DHCP... netsh interface IP Set DNS "Local Connection" DHCP Echo Dynamic IP address set! Pausegoto 3: 3 Exit
Min bin(Write to meOriginal blog (http://blog.csdn.net/binbinxyz), reprinted please noteSource!