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

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...

WinInfo Short Takes: Week of October 13, 2008

An often irreverent look at some of the week's other news... ...


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

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

Latest Advancements in SSL Technology
There are a variety of different kinds of SSL to explore to ensure customer data is kept confidential and secure. In this paper, we will discuss some of these SSL advances to help you decide which would be best for your organization.

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Solving PST Management Problems
In this white paper, read about the top PST issues and how to administer local/network PST Files.

Get Protected -- Data Protection Manager 2007
Protect your virtualized environment with Data Protection Manager

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.

Maximize Your SharePoint Investment: Get Your Data Moving
Watch this web seminar now to learn how to maximize your SharePoint investment! Join us as we take a look at the complex business of securing, accessing and managing vast amounts of information in a global network and various ways to get your data moving.
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 Technology Resource 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