Useful trick of the day
Netsh seems to be one of those built in Windows tools that have slipped under the radar. Works from Windows 2000 and up.
I got in to a conversation one of our Linux’s team. She was complaining that it sucked having to use the Windows GUI to set her IP details on her laptop.
When I told her that wasn’t true, she looked a bit freaked.
Open up a command prompt windows and type in Netsh interface ip dump
You’ll get this type of output if you have a static ip address:
# ----------------------------------
# Interface IP Configuration
# ----------------------------------
pushd interface ip
# Interface IP Configuration for "Earth"
set address name="Earth" source=static addr = 192.168.1.50 mask=255.255.255.0
set address name="Earth" gateway=192.168.1.1 gwmetric=1
set dns name="Earth" source= static addr = 192.168.1.50 register=PRIMARY
popd
# End of interface IP configuration
Now use this command to dump it to a text file
Netsh interface ip dump > c:\office.txt
You can edit this file to you heart’s content for multiple static and dhcp settings.
So you’ve created a bunch of different files for the office (office.txt), home (home.txt), wireless (wireless.txt) etc
Using the command: netsh -c "interface ip" -f C:\Working\office.txt
It imports the details back in to windows without having to open a single window.
I think I shattered some of those her illusions that Windows is only a GUI.
Okay, so that is fairly useful and a darn sight faster than going through windows.
For those who want to do this to remote machines:
netsh -c "interface ip" –r remotecomputername dump > c:\office.txt for a copy of it’s entire ip configuration to a local file.
Drop that in to a script, after using something like angryip for a complete network scan of ip addresses. You got a very detailed, documented & well mapped picture without much effort.
Now that’s very useful!
Netsh can do a lot of things so a little more reading:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netsh.mspx?mfr=true