Change IP Addresses with a NETSH Script

If you need to move your Windows XP laptop between networks regularly, then you’re no doubt familiar with the hassles of switching your network settings back and forth. If you’re lucky, all of the networks that you connect to use DHCP and it isn’t an issue. However, manual changes are necessary when this isn’t the case.

While changing your TCP/IP settings manually is not exactly a big deal, the NETSH command can easily put you just a double-click away from automating the switch. All you need to do is add the appropriate NETSH commands for each network to its own VBS script, and you can change anything from your IP address and default gateway settings to your DNS server addresses.

To set a static address of and a subnet mask of with NETSH, you would issue the following command:

netsh int ip set address name=”Local Area Connection” source=static addr= mask=

Of course, you’ll need to add the name of your connection in the name field (ipconfig /all provides the details). Quotes are necessary when the name includes spaces. If the command completes successfully, you’ll be presented with one very simple message – OK.

To change your default gateway address to, issue the following command:

netsh int ip set address name=”Local Area Connection” source=static gateway= gwmetric=1

To switch your DNS server address to, the command would be:

netsh int ip set dns name=”Local Area Connection” source=static addr=

To switch these same elements back to using DHCP instead, the commands would be:

netshint ip set address name=”Local Area Connection” source=dhcp

netshint ip set dns name=”Local Area Connection” source=dhcp

To automate the process of changing your addresses, fire up Notepad, create a Netsh command script for each network, and then save the resulting files to your desktop with .VBS extensions.

Create one for home, another for work, or as many as you need for the various networks you connect to. If you need to change your TCP/IP settings manually, this is a huge time saver. For more details on the NETSH command and its options, type netshint ip set address and press Enter.

Author: Dan DiNicolo

Dan DiNicolo is a freelance author, consultant, trainer, and the managing editor of He is the author of the CCNA Study Guide found on this site, as well as many books including the PC Magazine titles Windows XP Security Solutions and Windows Vista Security Solutions. Click here to contact Dan.