.

Netsh – Managing IP configuration for the Windows command line

<<

What90

Full Member
Full Member

Posts: 120

Joined: Sat Jun 09, 2007 2:23 am

Location: Syndey, Australia

Post Thu Jul 26, 2007 8:21 am

Netsh – Managing IP configuration for the Windows command line

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. :D

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/docu ... x?mfr=true
<<

slimjim100

User avatar

EH-Net Columnist
EH-Net Columnist

Posts: 385

Joined: Wed Nov 08, 2006 12:50 pm

Location: Atlanta

Post Thu Jul 26, 2007 8:37 am

Re: Netsh – Managing IP configuration for the Windows command line

I also like little known windows command "pathping" it's like traceroute and ping with more features.

Brian
CISSP, CCSE, CCNA, CCAI, Network+, Security+, JNCIA, & MCP
<<

Negrita

User avatar

Sr. Member
Sr. Member

Posts: 299

Joined: Sat Sep 10, 2005 5:45 pm

Location: /dev/null

Post Thu Jul 26, 2007 4:11 pm

Re: Netsh – Managing IP configuration for the Windows command line

I've known about both netsh and pathping for a long time now. I used to use them when I worked at an ISP.

Pathping is particularly painful as you have to wait ages to see the results. When I was working in real-time, I'd much rather use a tool like Ping Plotter.
CEH, CCSA NG/AI, NNCSS, MCP, MCSA 2003

There are 10 kinds of people, those that understand binary, and those that don't.
<<

jimbob

Post Fri Jul 27, 2007 3:10 am

Re: Netsh – Managing IP configuration for the Windows command line

I never knew about netsh, but I'm more of a *nix man myself. Thanks for the info, I've got to admit that was one of my Windows bugbears too.

Another is the absence of a remote command line a la SSH. Does anyone have any suggesions how I can get a remote command prompt on my Windows boxes. Please don't say nc -e cmd.exe  ;)

Jim
<<

What90

Full Member
Full Member

Posts: 120

Joined: Sat Jun 09, 2007 2:23 am

Location: Syndey, Australia

Post Fri Jul 27, 2007 4:58 am

Re: Netsh – Managing IP configuration for the Windows command line

Jim,

You'll have to wait to Windows 2008 core for a true remote command line. Or so I'm told and I believe everything for the MS marketing machine :-)

The closest I could get you natively is a telnet session by turning on the telnet server service. 
Mind you, the amount of times I saw netcat on some systems, I though it WAS part of the OS  ;)

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software