netsh http://technet2.microsoft.com/WindowsServer/en/library/6c8cac27-f85a-4db3-ac8b-bc8737062e871033.mspx?mfr=true article 1 How to Use the Netsh.exe Tool and Command-Line Switches View products that this article applies to. Article ID : 242468 Last Review : November 21, 2003 Revision : 3.0 This article was previously published under Q242468 On This Page http://support.microsoft.com/?kbid=242468SUMMARY http://support.microsoft.com/?kbid=242468MORE INFORMATION http://support.microsoft.com/?kbid=242468Contexts http://support.microsoft.com/?kbid=242468Netsh.exe Commands http://support.microsoft.com/?kbid=242468Helper Dynamic Link Libraries Files Available http://support.microsoft.com/?kbid=242468Associated Registry Entries for Helper Dynamic Link Libraries Files .toc{display: none;} SUMMARY Netsh.exe is a tool an administrator can use to configure and monitor Windows-based computers at a command prompt. With the Netsh.exe tool, you can direct the context commands you enter to the appropriate helper, and the helper then carries out the command. A helper is a Dynamic Link Library (.dll) file that extends the functionality of the Netsh.exe tool by providing configuration, monitoring, and support for one or more services, utilities, or protocols. The helper may also be used to extend other helpers. Back to the top MORE INFORMATION You can use the Netsh.exe tool to perform the following tasks: • Configure interfaces. • Configure routing protocols. • Configure filters. • Configure routes. • Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service. • Display the configuration of a currently running router on any computer. • Use the scripting feature to run a collection of commands in batch mode against a specified router. The syntax for the Netsh.exe tool is: netsh [-r router name] [-a AliasFile] [-c Context] [Command | -f ScriptFile] To display a list of subcontexts and commands that can be used in a context, type the context name followed by a space and a ? at the netsh> command prompt. For example, to display a list of subcontext and commands that can be used in the /routing context, type routing ? at the netsh> command prompt, and then press ENTER. Back to the top Contexts Context strings are appended to the Netsh.exe tool command and are passed to an associated helper. The helper may have one or more entry points that map to contexts. Some of the contexts available in the Netsh.exe tool are: Context Command: /dhcp Result: Changes to the Dynamic Host Configuration Protocol (DHCP) context. Context Command: /ras Result: Changes to the Remote Access Server (RAS) context. Context Command: /routing Result: Changes to the routing context. Context Command: /wins Result: Changes to the Windows Internet Name Service (WINS) context. Contexts may also nest within other contexts. For example, the following contexts operate within the netsh>ras context: Context Command: /ip Result: Changes to the Internet Protocol (IP) context. Context Command: /ipx Result: Changes to the Internetwork Packet Exchange (IPX) context. Context Command: /netbeui Result: Changes to the NetBios Enhanced User Interface (NETBEUI) context. The following subcontexts operate within the netsh>routing ip context: Context Command: /autodhcp Result: Changes to the autodhcp subcontext. Context Command: /dnsproxy Result: Changes to the dnsproxy subcontext. Context Command: /igmp Result: Changes to the Internet Group Membership Protocol (IGMP) subcontext. Context Command: /mib Result: Changes to the Management Information Base (MIB) subcontext. Context Command: /nat Result: Changes to the Network Address Translation (NAT) subcontext. Context Command: /ospf Result: Changes to the Open Shortest Path First (OSPF) subcontext. Context Command: /relay Result: Changes to the relay subcontext. Context Command: /rip Result: Changes to the Routing Information Protocol (RIP) subcontext. Back to the top Netsh.exe Commands The following additional commands can be used with the Netsh.exe tool: NOTE: Optional parameters are shown in brackets ([ ]). Alternative entries are shown with a pipe (|) character between them. Context Command: /? Result: Displays help. Context Command: /abort Result: Discards any changes made in offline mode. No effect in online mode. Context Command: /add helper DLL-name Result: Installs the helper .dll file in netsh.exe. Context Command: /alias [alias-name] [string1] [string2 ...] Result: If /alias, lists all aliases. If /alias alias-name, displays the equivalent string. If /alias alias-name string1 string2 ..., sets alias-name to the specified strings. Context Command: /bye Result: Exits the program. Context Command: /commit Result: Commits any changes made in the offline mode to the router. No effect in the online mode. Context Command: /delete helper .dll file name Result: Removes the helper .dll file from Netsh.exe. Context Command: /dump -file name Result: Dumps or appends configuration to a text file. Context Command: /exec script file name Result: Loads the script file and executes commands from it. Context Command: /exit Result: Exits the program. Context Command: /h Result: Displays help. Context Command: /help Result: Displays help. Context Command: /offline Result: Sets the current mode to offline. Any changes made in this mode are saved, but require a "commit" or "online" command to be set in the router. Context Command: /online Result: Sets the current mode to online. Any changes in this mode are immediately reflected in the router. Context Command: /popd Result: Pops a context from the stack. Context Command: /pushd Result: Pushes current context onto the stack. Context Command: /quit Result: Exits the program. Context Command: /set mode [mode =] online | offline Result: Sets the current mode to online or offline. Context Command: /show alias | helper | mode Result: If /show alias, lists all defined aliases. If /show helper, lists all top-level helpers. If /show mode, shows the current mode. Context Command: /unalias alias name Result: Deletes the specified alias. Back to the top Helper Dynamic Link Libraries Files Available Routing & Remote Access IP Configuration - Ipmontr.dll Routing & Remote Access IPX Configuration - Ipxmontr.dll Interface - Ifmon.dll RAS - Rasmontr.dll DHCP - Dhcpmon.dll WINS - Winsmon.dll Back to the top Associated Registry Entries for Helper Dynamic Link Libraries Files HKEY_LOCAL_MACHINE/Software/Microsoft/NetSh/ REG_SZ: Ipmontr.dll REG_SZ: Ipxmontr.dll REG_SZ: Ifmon.dll REG_SZ: Rasmontr.dll REG_SZ: Dhcpmon.dll REG_SZ: Winsmon.dll NOTE: If attempts to use Netsh dump - to dump configurations to a file does not work, try using the syntax: netsh dump >filename or path\filename, from a command line. Back to the top APPLIES TO • Microsoft Windows 2000 Server • Microsoft Windows 2000 Advanced Server • Microsoft Windows 2000 Professional Edition • Microsoft Windows 2000 Datacenter Server Back to the top Keywords: kbinfo kbnetwork KB242468 Back to the top article 2 How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000 View products that this article applies to. Article ID : 257748 Last Review : December 3, 2003 Revision : 3.0 This article was previously published under Q257748 SUMMARY You can use the netsh command in Windows 2000 to script the process of changing a computer from a static Internet Protocol (IP) address to Dynamic Host Configuration Protocol (DHCP) or vice versa. The netsh command accomplishes this task without the need to restart the computer. This feature is particularly useful for laptops that move from one environment to another, when it is necessary to use statically assigned IP addresses at one location and DHCP assigned IP addresses at another. MORE INFORMATION To switch the specified adapter from a static address to DHCP, type the following command: netsh interface ip set address "Local Area Connection" dhcpNOTE: Typing this command changes the interface named "Local Area Connection" to DHCP. To display all of the adapters in the computer with their current IP addresses to determine the correct adapter name, type the following command: Netsh interface ip show configTo change to a static address, type the following command: netsh interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metricNOTE: Replace ipaddr with the static IP address, subnetmask with the subnet mask, gateway with the default gateway and, if necessary, metric with the appropriate metric. The following example changes the interface "Local Area Connection" to a static address of 192.168.0.10 with a subnet mask of 255.255.255.0, and the interface has a default gateway of 192.168.0.1 with a metric of 1: netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1 article 3 How can I configure TCP/IP settings from the Command Prompt? In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe. Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script in a text file for archival purposes or to help you configure other servers. Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003. You can use the Netsh.exe tool to perform the following tasks: * Configure interfaces * Configure routing protocols * Configure filters * Configure routes * Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service * Display the configuration of a currently running router on any computer * Use the scripting feature to run a collection of commands in batch mode against a specified router. What can we do with Netsh.exe? With Netsh.exe you can easily view your TCP/IP settings. Type the following command in a Command Prompt window (CMD.EXE): netsh interface ip show config With Netsh.exe, you can easily configure your computer's IP address and other TCP/IP related settings. For example: The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1: netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1 (The above line is one long line, copy paste it as one line) Netsh.exe can be also useful in certain scenarios such as when you have a portable computer that needs to be relocated between 2 or more office locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration. First, connect your portable computer to location #1, and then manually configure the required settings (such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses). Now, you need to export your current IP settings to a text file. Use the following command: netsh -c interface dump > c:\location1.txt When you reach location #2, do the same thing, only keep the new settings to a different file: netsh -c interface dump > c:\location2.txt You can go on with any other location you may need, but we'll keep it simple and only use 2 examples. Now, whenever you need to quickly import your IP settings and change them between location #1 and location #2, just enter the following command in a Command Prompt window (CMD.EXE): netsh -f c:\location1.txt or netsh -f c:\location2.txt and so on. You can also use the global EXEC switch instead of -F: netsh exec c:\location2.txt Netsh.exe can also be used to configure your NIC to automatically obtain an IP address from a DHCP server: netsh interface ip set address "Local Area Connection" dhcp Would you like to configure DNS and WINS addresses from the Command Prompt? You can. See this example for DNS: netsh interface ip set dns "Local Area Connection" static 192.168.0.200 and this one for WINS: netsh interface ip set wins "Local Area Connection" static 192.168.0.200 Or, if you want, you can configure your NIC to dynamically obtain it's DNS settings: netsh interface ip set dns "Local Area Connection" dhcp As you now see, Netsh.exe has many features you might find useful, and that goes beyond saying even without looking into the other valuable options that exist in the command. Links How to Use the Netsh.exe Tool and Command-Line Switches - 242468 How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000 - 257748 article 4 How To Change Network Interface Card (NIC) Settings Programmatically by Stanley Fong Why? This comes about when I have to use my notebook outside my office where a hardwired LAN is available. I have 2 work locations where 2 LAN's are connected via a leased line. Changing my NIC settings was easy because with Windows XP you don't need to reboot and in my case I only have to change one digit at the IP address. This job could be tedious at my client's office with a completely different LAN setup. A NIC can only have one set of settings; if you can afford few NIC's for your notebook then you can skip this article. How? Being lazy I didn't want to enter IP address, gateway, WINS, etc. every time I changed location, therefore I scoured the Internet for a solution. I love the Internet. I usually find what I want and learn something along the way. Methods A. MCSEworld by Daniel Petri Some little tricks are available at MCSEworld by Daniel Petri, see http://www.petri.co.il. The basic trick is to use netsh.exe to dump your current setting to a text or a data file. This can be done by typing below: Netsh interface dump > text.txt The netsh scripting tool allows you to import the setting by "executing" a text or data file. To do the reverse, just type below Netsh exec text.txt The trouble of course is all these have to be done manually at command prompt within a DOS window. At first I did try this, to my surprise it didn't work and all I got is error message like below 'register' is not a valid argument for this command. The syntax supplied for this command is not valid. Check help for the correct syntax. Usage: add dns [name=] [[index=]