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 settingsThe 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 configurationNetsh 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 addressThe 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 addressWhen 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 addressWhen 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 serverNetsh 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 interfacesNetsh 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 systemsOne 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 configurationThe 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 configurationThe 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.
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!
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
I am unable to get this to work when I try to specify the interface name. "Local Area Connection" is considered invalid, and gets me no where. When I dump the netsh info, it lists all my interfaces as some gibberish like "{ADB7473C-C67B-49DE-B0D9-A25E990A39F5}", but even using that, and otherwise following the examples, the interface is called invalid.
tmsm -July 20, 2004
i also got the problem that tmsm come across.
who give the way to solve it.
paco555 -September 14, 2004
can you use it to set a secondary gateway?
Anonymous User -October 14, 2004
good doc
Anonymous User -October 28, 2004
re tmsm:
the problem occur because
you stop the "remote registry service".start it!Everything will be ok.
Anonymous User -November 10, 2004
Thanks to the help here I figured out how to do multiple DNS servers. from the command line it will look like this:
C:\>netsh
netsh>interface ip
interface ip>add dns "Local Area Connection" 10.0.0.1
Ok.
interface ip>bye
__________
Once you go into netsh.exe it seems to go into some ftp type commands. You need to go to : interface ip . From there you can add or delete DNS servers, as many as you like. To put a DNS server in a specific location add on the end of the command: index= (and the number, 2 or 3 or whatever). You do not have to specify the position to delete them, it finds it by number.
handy1 -November 17, 2004
sorry, that doesn't look right, I'll try again.
C:\>netsh
netsh>interface ip
interface ip>add dns "Local Area Connection" 10.0.0.1
Ok.
interface ip>bye
handy1 -November 17, 2004
To add multiple DNS entries you need to type:
netsh interface ip set dns name="Wireless Network Connection" source=static addr=192.168.1.200 register=PRIMARY
netsh interface ip add dns name="Wireless Network Connection" addr=192.168.1.5 index=2
They need to be entered on a separate line.
rldutch1 -November 21, 2004
To add multiple DNS entries you need to type:
netsh interface ip set dns name="Wireless Network Connection" source=static addr=192.168.1.200 register=PRIMARY
netsh interface ip add dns name="Wireless Network Connection" addr=192.168.1.5 index=2
Just for fun I tried to just add the Secondary DNS (index=2) without first having a Primary and netsh put the IP address in the primary position. I guess you need to have a Primary DNS entered before you can add Secondary and Tertiary DNS entries.
rldutch1 -November 21, 2004
Find your interface name & set multiple dns entries like this:
C:\WINNT\system32>netsh
netsh>interface
interface>show interface
Admin State State Type Interface Name
-------------------------------------------------------------------------
Enabled Dedicated Local Area Connection
Enabled Internal Internal
Enabled Loopback Loopback
(Note: Look for "Dedicated" connection types with any name other than a GUID)
interface>ip
interface ip>delete dns "Local Area Connection" all
interface ip>set dns "Local Area Connection" static 10.10.10.2
interface ip>add dns "Local Area Connection" 10.10.10.3 index=2
Anonymous User -November 22, 2004
Wow, that came out ugly, let me try again:
C:\WINNT\system32>netsh
netsh>interface
interface>show interface
Admin State State Type Interface Name
-------------------------------------------------------------------------
Enabled Dedicated Local Area Connection
Enabled Internal Internal
Enabled Loopback Loopback
(Note: Look for "Dedicated" connection types with any name other than a GUID)
interface>ip
interface ip>delete dns "Local Area Connection" all
interface ip>set dns "Local Area Connection" static 10.10.10.2
interface ip>add dns "Local Area Connection" 10.10.10.3 index=2
Anonymous User -November 22, 2004
I am unable to use netsh to access a remote computer. Has anyone actually done this with NETSH on Windows 2000 Pro?
jesae -November 24, 2004
how can i change the "workgroup" also?
i need to use my laptop in three different home networks (peer to peer), in which the workgroup name is different...
tnx in advance
rosanna
italy
Anonymous User -November 26, 2004
Is it possible in WIN 2000 to "disable" "Local Area Connection" using NetSh? What are the commands?
Anonymous User -December 01, 2004
I have the same problem connecting to remote computers using either set machine or netsh -r. It changes the command prompt to the remote computer but it is actually still controlling the local computer
Anonymous User -December 10, 2004
I am unable to get this to work when I try to specify the interface name. "Local Area Connection" is considered invalid, and gets me no where. When I dump the netsh info, it lists all my interfaces as some gibberish like "{ADB7473C-C67B-49DE-B0D9-A25E990A39F5}", but even using that, and otherwise following the examples, the interface is called invalid.
i have enabled remote registry service then it's working but can some one hlep me to resolve this without enabling remote registry service becaue some security issue i can not enable remote registry service
RSDS
Anonymous User -December 27, 2004
Does anybody know a hack allowing to set 127.0.0.1 as DNS server? The netsh command claims that 127.0.0.1 is not an acceptable value for addr.
Thanks.
Anonymous User -January 11, 2005
This works great for Win2k Pro. I put this in a batch file and run it together.
Set IP address subnet gateway
Set DNS Primary
Set DNS Secondary
netsh interface ip set address "Local Area Connection" static 10.1.1.15 255.255.255.0 10.1.1.1 1
netsh interface ip set dns "Local Area Connection" static 172.16.0.5 primary
netsh interface ip add dns name="Local Area Connection" addr=172.16.0.15 index=2
Anonymous User -January 12, 2005
Well, I'm not really sure, the last comment was in reply to the one before (that I've posted anonymously ;) ). But if it is, I want just to say that I was talking about the loopback (127.0.0.1) address.
netsh interface ip set dns "Local Area Connection" static 127.0.0.1
Anonymous User -January 14, 2005
Use:
DEVCON FIND =NET
To find network devices.
Use
DEVCON disable @ROOT\NET\0000
to disable and
DEVCON enable @ROOT\NET\0000
to enable.
Anonymous User -January 18, 2005
I too ran into this problem. Do this: 1. Create a batch file called netsh.bat ( for example ) with the netsh commands you would like to run ( just as they would run locally on your PC ) 2. Copy netsh.bat to C:\ (for example) on all of the nodes that need the change ( you can copy netsh.bat across your LAN via another batch file ). 3. With another batch file, schedule an AT job on each node that needs the change: this at job should run c:\netsh.bat ( that has already been copied to each node that needs the change ). This works becuase the job is running locally on each PC, rather than being pushed from another. Thanks, and good luck. -LP
Anonymous User -February 25, 2005
Great it is very very usefull.
It is great subject for IT people.
How to use NETSH command explained very very intresting.
Thanks to all to producing such a kind of technical services
Anonymous User -April 12, 2005
usage of devcon to disable network adapter
use the 'hwids =net' to find the compatible id for your adapter
c:\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
PCI\VEN_8086&DEV_100E&CC_020000
PCI\VEN_8086&DEV_100E&CC_0200
Compatible ID's:
PCI\VEN_8086&DEV_100E&REV_02
PCI\VEN_8086&DEV_100E
PCI\VEN_8086&CC_020000
PCI\VEN_8086&CC_0200
PCI\VEN_8086
PCI\CC_020000
PCI\CC_0200
c:\devcon disable "PCI\VEN_8086&DEV_100E&REV_02"
PCI\VEN_8086&DEV_100E&REV_02\3&1070020&0&40 : Disabled
1 device(s) disabled.
Anonymous User -April 28, 2005
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 -April 28, 2005
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 -April 30, 2005
Can you change only the subnet mask using netsh without changing the ip address also?
Anonymous User -June 08, 2005
How can i do this changes from static to dhcp on a win NT workstation?
tecnidi -June 27, 2005
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 -August 14, 2005
Windows XP has DHCP server but it's disabled. Is any way to enable it and configure it in netsh? THX.
Anonymous User -September 02, 2005
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 -September 05, 2005
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 -February 02, 2007
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!
Free CDs Offer Fundamental Content for IT Pros Are you up to speed on the latest technologies and solutions? Don't miss out on your chance to get up to speed quickly on fundamental, in-depth information on some of the hottest topics in our library of content.
Let Your Users Reset Their Own Passwords: Free Download Try a 30 day free trial of Desktop Authority Password Self-Service – it provides an easy-to-use, robust system for allowing users to reset their own forgotten passwords or locked accounts.
Get Windows IT Pro & Mark Minasi’s Favorite Power Tools Guide Order Windows IT Pro now and get "More of Mark Minasi's Favorite Power Tools"--a in-depth guide to the most useful Windows commands --FREE with your paid order! Subscribe today, and save 58% off the cover price!
Deep Dive into VMware vSphere, eLearning Series Join John Savill to explore the major functionality capabilities of the vSphere virtualization platform, including identification of the changes from ESX 3.5.