Tuesday, March 25, 2008

Switching among network profiles

If you are on the move, connecting to various networks which have DHCP disabled is a pain. The alternate configuration option in the TCP/IP properties dialog too doesn't work always as expected. Time to call up our swiss-army knife of network tools in WinXP -- netsh [1]

A unique command, netsh is a veritable goldmine of settings and one of the options allows setting the TCP/IP properties. To set a static IP address, subnet mask, default gateway I used

netsh interface ip set address name="Wireless Network Connection" static 10.1.2.40 255.255.255.0 10.1.2.1 1

Where "Wireless Network Connection" is the name of the connection as per "Network Connections" in Control Panel. (Shortcut: Start-> Run "ncpa.cpl"), 10.1.2.40 is the IP address that I want to set it to, 255.255.255.0 is the subnet mask, 10.1.2.1 is the default gateway and the last one sets the gwmetric (the metric for the default gateway.)

To set the dns servers; netsh interface ip set dns name="Wireless Network Connection" static 10.1.2.10 primary

To set the interface back to dhcp I used

netsh interface ip set address name="Wireless Network Connection" dhcp
netsh interface ip set dns name="Wireless Network Connection" dhcp primary

I created cmd files with the network settings and have placed them on my desktop. This way, I can simply double-click on them to set the Network Profile that I need to use.

It is a pleasure to work with a command that lends itself to easy learning.

 

[1] The TCP/IP Swiss Army Knife is a tool called netcat.

No comments:

Post a Comment