Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


January 2004

Cool Things to Do with Netsh

Change almost any network configuration setting with this powerful tool
RSS
Subscribe to Windows IT Pro | See More Resource Kit Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

The Netsh command is a powerful command-line tool for Windows Server 2003, Windows XP, and Windows 2000. Netsh is available in the Microsoft Windows 2000 Server Resource Kit and is standard in Windows 2003 and XP. Netsh lets you change almost any network configuration setting as well as document network configurations. You can use the command in a batch file or from its own command shell. Netsh has a useful Help system that you can access by adding /? to almost any of its subcommands. Here are 10 cool things that you can use Netsh to do.

10. Show TCP/IP settings—The command

netsh interface ip show config

shows the system's current TCP/IP configuration settings. You can see whether the system is using DHCP or static addressing as well as view the system's current IP address, subnet mask, gateway address, and DNS servers.

9. Change network configuration—Netsh can change the current network configuration. The command

netsh interface ip set
  address "Local Area 
  Connection" static 
  192.168.0.10 255.255.255.0
  192.168.0.254

sets the IP address of the system configuration Local Area Connection to 192.168.0.10, the subnet mask to 255.255.255.0, and the gateway address to 192.168.0.254. This use of Netsh comes in handy for laptops that must switch between static and dynamic addressed networks.

8. Use a dynamic DHCP assigned address—The command

netsh interface ip set
  address "Local Area 
  Connection" dhcp

sets the IP address of the Local Area Connection system configuration to use DHCP addressing.

7. Change a DNS server address—When you change the system's IP address type, you almost always have to change the DNS server's address as well. The command

netsh interface ip set dns
  "Local Area Connection" 
  static 192.168.0.2

configures the Local Area Connection to use a DNS server whose address is 192.168.0.2.

6. Dynamically assign the DNS server address—When you switch to dynamic DHCP addressing, you typically also want the DNS server address to be assigned dynamically. The command

netsh interface ip set dns 
"Local Area Connection" dhcp

sets the Local Area Connection interface to use a DHCP-assigned DNS address.

5.Configure a WINS server—Netsh also lets you configure WINS servers. The following command configures a system's Local Area Connection interface to use a WINS server that has the IP address 192.168.100.3.

netsh interface ip set wins 
  "Local Area Connection" 
  static 192.168.100.3

4. Work with other interfaces—Netsh works with DHCP, Internet Authentication Service (IAS), and RAS interfaces as well as the local network interface. The command

netsh dhcp dump > dhcpcfg.dat

dumps the local DHCP server's configuration to the dhcpcfg.dat file. You can use this file in conjunction with Netsh to recreate the DHCP server.

3. Work with remote systems—One of Netsh's best hidden features is its ability to work with remote systems. The command

netsh set machine remotecomputer

sets the current computer to a different system on the network.

2. Save the current configuration—The Interface Dump subcommand saves your current network configuration and generates a script that you can use to regenerate the configuration. The command

netsh interface dump > 
  mycfg.dat

redirects the Dump command to the mycfg.dat file.

1. Restore network configuration—The Netsh Exec command runs a Netsh script file. The command

netsh exec mycfg.dat

restores to your system the network configuration data that the preceding sample command saved.

End of Article



Reader Comments
How do you use netsh to set more than one DNS server? We've been able to use the following to set multiple WINS servers:

netsh interface ip set wins name="Local Area Connection" static 192.168.1.1
netsh interface ip add wins name="Local Area Connection" 192.168.1.2

However, this syntax doesn't work for setting multiple DNS servers.

Thanks in advance for any help.



Robert Logan February 10, 2004


In order to add multiple DNS servers, use the following syntax:

add dns "Local Area Connection" 10.0.0.1
add dns "Local Area Connection" 10.0.0.3 index=2

index=2 adds the IP as a secondary dns server.

Cameron Fairbairn May 06, 2004


The sentence "The Netsh command is a powerful command-line tool for Windows Server 2003, Windows XP, and Windows 2000. Netsh is available in the Microsoft Windows 2000 Server Resource Kit and is standard in Windows 2003 and XP." should be changed to "The Netsh command is a powerful command-line tool that is installed by default for Windows Server 2003, Windows XP, and Windows 2000."

Netsh is included with Windows 2000, not as part of the Windows 2000 Server Resource Kit.

Thanks.

Joseph Davies May 25, 2004


How migrate DHCP and Wins of Windows 2000 Active Directory to Windows 2003 Active Directory

martin June 04, 2004


Roger, could you please provide the complete statement for doing the multiple DNS bit that you wrote, please...

I can be PM'd at wyc@bigfoot.com

THANKS!

wYc88 June 17, 2004


Is it possible to use netsh to disable and then enable an interface? Been trying to figure out a way do do that from a cmd line.
thx

tschreier June 27, 2004


tschreier: I'm not sure if Devcon can do this, but I've done this before using another powerful command line utility: DevCon.exe (check out http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272 for a copy). Devcon DDK (Device/Driver Developer Kit) Tool is a command line version of Device Manager. To disable a network connection, you're actually disabling the network adapter associated with the connection. Using some customized scripting and devcon.exe, you can identify the adapter and enable or disable it on the fly. One word of advice, be sure to "escape" the ampersands (&) in the device IDs using the "hat" charector (^) when running it from the command line by specifying them as ^& otherwise you could end up in a major bind!

yhamade June 30, 2004


#4 netsh dhcp dump > dhcpcfg.dat
should read
netsh dump dhcp > dhcpcfg.dat

Kalidor July 01, 2004


The commands in the article need to be corrected as follows:

10. netsh interface ip show config

09. Netsh interface ip set address name=”Local Area Connection” source=static addr=192.168.0.10 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1

08. Netsh interface ip set address name=”Local Area Connection” source=dhcp

07. Netsh interface ip set dns name=”Local Area Connection” source=static addr=192.168.0.2 register=none

06. netsh interface ip set dns name="Local Area Connection" source=dhcp

05. Netsh interface ip set wins name=”Local Area Connection” source=static addr=192.168.100.3

To configure WINS from DHCP:
Netsh interface ip set wins name=”Local Area Connection” source=dhcp

04. netsh dump dhcp > dhcpcfg.dat

03. OK

02. netsh dump interface > mycfg.dat

01. OK

Robert Holland July 03, 2004


This DEVCON.EXE don't exit with ad usable errorlevel...in every cases it return "0" :-(
I can't find a IFCONFIG porting for win32 :-) ...

mauroedp July 07, 2004


 See More Comments  1   2   3   4   5 

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

IT Connections
Dive into the new Microsoft platforms and products you implement and support with the experts from Microsoft, TechNet Magazine, Windows ITPro and industry gurus. There are 70+ sessions and interactive panels with networking opportunities.

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes and add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Get SQL Server 2008 at WinConnections
Don’t miss Microsoft Exchange and Windows Connections conferences, the premier events for Microsoft IT Professionals in Las Vegas, November 10-13. Every attendee will receive a copy of SQL Server 2008 Standard Edition with one CAL.



Interested in Email Encryption?
Read about the advantages of identity-based encryption in this free report.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing