In Windows 7, I use a dynamic IP Address at home and a fixed IP address at the 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! [Plain] @ echo off rem // set the variable set NAME = "Local Connection" rem // The following attribute values can be changed as needed: set ADDR = 172.16.18.184 set MASK = 255.255.255.0 set GATEWAY = 172.16.18.254 set DNS1 = 172.16.17.1 set DNS2 = 8.8.8.8 rem // The above attributes are IP address, subnet mask, gateway, preferred DNS, and backup DNS echo. Currently available operations include: echo 1 is set to static IP echo 2 is set to dynamic IP echo 3 Exit echo select and press Enter: set/p operate = if % operate % = 1 goto 1 if % operate % = 2 goto 2 if % operate % = 3 goto 3: 1 echo is setting static IP, please wait... rem // you can To change the echo IP address = % 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 address set! Pause goto 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" dhcp echo is automatically obtaining the DNS address from DHCP... netsh interface ip set dns "Local Connection" dhcp echo Dynamic ip address set! Pause goto 3: 3 exit Source http://blog.csdn.net/binbinxyz/article/details/8876855