Tuesday, July 10, 2007

Utilizing netsh to Change IP Address

Most all the time, I will hanging out in different client sites that require me to change the IP Address and some other TCP/IP configuration. The usual way requires several combination of mouse clicks and keypress. This is when netsh come in handy (thanks to kapla_hodot for showing the way). Yes, you might know better, but since this is my blog so I want to put something useful to me as a noob system admin. This is just a note to self on how to create the netsh network configuration file.

For dhcp setting, first fire up your favorite text editor(notepad,ultraedit,vim etc.). Then, put this lines into the file.

interface ip

set address name="Local Area Connection" source=dhcp
set dns name="Local Area Connection" source=dhcp register=PRIMARY
set wins name="Local Area Connection" source=dhcp
bye

Then save it to the file called, say C:\dhcp.netsh

To test it out, go to the command prompt and type:

C:\>netsh exec dhcp.netsh

Here are the sample configuration for static IP Address:

interface ip
set address name="Local Area Connection" source=static addr=192.168.1.207 mask=255.255.255.0
set address name="Local Area Connection" gateway=192.168.1.5 gwmetric=0
set dns name="Local Area Connection" source=static addr=192.168.1.6 register=PRIMARY
add dns name="Local Area Connection" addr=202.188.0.133 index=2
bye

Note that the line
add dns name="Local Area Connection" addr=202.188.0.133 index=2
is intended to specify the secondary DNS.

Some people go all the way to specify a new file type, so that you can just simply double-click the file to run it. But for me, the current way is lazy enough to fit the purpose.

3 comments:

Anonymous said...

visit changeipaddress.org to know the procedure to change ip address.

Anonymous said...

Chanchal, are you spamming or just ignorant of what the blog is about?

yoe said...

I would say both. Its ok, no harm done on my rare-visited blog. Anyway, thanks Drew.