Windows Script to Change IPs

Posted in How Did I Do That?

As a network administrator, I add routes, change IPs and things all the time. When you have a test machine that you carry around, one of the fastest, cleanest tests you can perform is to simply assign an IP, subnet, gateway, and DNS and quickly test. Having routes permanently stored on the machine is not really an effective test, for it will not simulate what other boxes on the network will do.

The fastest way to do this is to write a script for those various networks you test. Remeber the word "LAN" is the alias for the network interface. This is just a Windows bat file...

#i=ip address
netsh interface ip set address name="LAN" static iii.iii.iii.iii sss.sss.sss.sss ggg.ggg.ggg.ggg 1
netsh interface ip set dns "LAN" static

#for dhcp, do...
netsh interface ip set address "LAN" dhcp
netsh interface ip set dns "LAN" dhcp