December 30, 2003 07:30 PM

Cool Things to Do with Netsh

Change almost any network configuration setting with this powerful tool
Rating: (22)
Windows IT Pro
InstantDoc ID #41111

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.

ARTICLE TOOLS

Add a Comment

Very useful for configuring NIC.

vickov 12/17/2008 5:31:16 PM


Another helpful article is Mark Minasi's "Netsh Tricks"-- also at Windows IT Pro: see http://windowsitpro.com/article/articleid/50425/netsh-tricks.html

or go to the top of this page and type in 50425 in the InstantDoc ID box.

Cheers!

Caroline from editorial 11/13/2008 3:15:53 PM


Would anyone know why I am getting the following error with #3, which is the remote command.

When I run "netsh set machine virtual2000" I get the following response "WARNING: Could not obtain host information from machine: [10.1.2.106]. Some commands may not be available.
Access is denied"

The result is identical when I try "netsh -r virtual2000"

I have tried physical servers as well, but I get the same result. I tried to google the error, but I don't see anything.

The netsh interface works fine until you get to the "set IP address" portion". At that point, the available commands are blank.

fvianzon 2/2/2007 11:52:44 AM


Both commands work fine
ARTICLE-04. netsh dhcp dump > dhcpcfg.dat
KALIDOR-04. netsh dump dhcp > dhcpcfg.dat
But the second one goes in more detail with services. Cool!!

Anonymous User 9/5/2005 3:37:40 PM


Windows XP has DHCP server but it's disabled. Is any way to enable it and configure it in netsh? THX.

Anonymous User 9/2/2005 11:27:59 AM


I want to use the netsh command to view a remote computer's current dns settings. However, even though I am connecting to the remote computer (using -r computername) and run the "show dns" command, it returns my computer's dns settings and not the remote pc. I have tried this on multiple computers and same response. Is this right?

Anonymous User 8/14/2005 6:03:58 AM


How can i do this changes from static to dhcp on a win NT workstation?

tecnidi 6/27/2005 9:41:24 AM


Can you change only the subnet mask using netsh without changing the ip address also?

Anonymous User 6/8/2005 12:52:05 PM


This is how to Disable and enable an interface using Netsh

netsh int set interface name="Local Area Connection 3" admin=disabled
netsh int set interface name="Local Area Connection 3" admin=enabled

This

Anonymous User 4/30/2005 5:34:31 PM


wow that came out crappy

try this

c:\\devcon hwids =net

C:\\devcon>devcon hwids =net

PCI\\VEN_8086&DEV_100E&SUBSYS_01511028&REV_02\\4&1C660DD6&0&60F0

Name: Intel(R) PRO/1000 MT Network Connection

Hardware ID's:

PCI\\VEN_8086&DEV_100E&SUBSYS_01511028&REV_02

PCI\\VEN_8086&DEV_100E&SUBSYS_01511028

Compatible ID's:

PCI\\VEN_8086&DEV_1229&REV_08

PCI\\VEN_8086&DEV_100E

PCI\\VEN_8086&CC_020000

c:\\devcon disable "PCI\\VEN_8086&DEV_1229&REV_08"

PCI\\VEN_8086&DEV_100E&REV_02\\3&1070020&0&40 : Disabled

Disabled 1 device(s) disabled.


Anonymous User 4/28/2005 11:50:19 AM


You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

eBooks

Playbook for a Virtualized Datacenter | During challenging times, optimizing the IT infrastructure becomes imperative. Many organizations are looking to extend their virtualization efforts to encompass the entire datacenter. Get a step-through of your technology options and more.

White Papers

As the advances in USB devices have made them invaluable to most business users’, they have also exposed organizations to enormous risks. Learn how to easily enforce device/port control and data encryption policies without requiring new infrastructure and additional admin overhead.

WEB SEMINARS

Is Flexible Lockdown Possible? Join Darren Mar-Elia for this free web webinar exploring the various methods you should consider to protect and control your desktops while also understanding the impact on the end user community.
View Seminar On-Demand.

eLearning Series

Windows IT Pro brings the experts direct to you to share their real-world perspective, experience, and expertise. During each event, three sessions stream in real time, allowing you to learn, to ask questions, and to get solutions.
Upcoming event: SQL Server Consolidation

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.