The Netsh Command-Line Utility

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

The Netsh command-line utility

Netsh is a command-line and scripting utility for networking components for local or remote computers. The Netsh utility can also save a configuration script in a text file for archival purposes or for configuring other servers.

The Netsh utility is a shell that can support multiple components through the addition of Netsh helper DLLs. A Netsh helper DLL extends Netsh functionality by providing additional commands to monitor or configure a specific networking component. Each Netsh helper DLL provides a context, a group of commands for a specific networking component. Within each context, subcontexts can exist. For example, within the routing context, the subcontext ip exists to group IP routing commands together.

Netsh command-line options include the following:

  • -aAliasFile

    Specifies that an alias file is used. An alias file contains a list of netsh commands and an aliased version so that you can use the aliased command line in place of the netsh command. You can use alias files to map commands that may be more familiar in other platforms to the appropriate netsh command.

  • -cContext

    Specifies the context of the command that corresponds to an installed helper DLL.

  • Command

    Specifies the netsh command to execute.

  • -fScriptFile

    Specifies that all of the netsh commands in the ScriptFile file are run.

  • -rRemoteMachine

    Specifies that the netsh commands are run on a remote computer specified by either its name or IP address.

You can abbreviate commands to the shortest unambiguous string. For example, issuing the command sh ip int is equivalent to issuing show ip interface. Netsh commands can be either global or context-specific. Global commands can be issued in any context and are used for general Netsh utility functions. Context-specific commands vary according to the context. You can log commands issued to a log file to create an audit trail of a netsh command session.

The following table lists the netsh global commands.

Command Description

..

Moves up one context level.

? or help

Displays command-line Help.

show version

Displays the current version of Windows and the Netsh utility.

show netdlls

Displays the current version of installed Netsh helper DLLs.

add helper

Add a Netsh helper DLL.

delete helper

Removes a Netsh helper DLL.

show helper

Displays the installed Netsh helper DLLs.

cmd

Creates a command window.

online

Sets the current mode to online.

offline

Sets the current mode to offline.

set mode

Sets the current mode to online or offline.

show mode

Displays the current mode.

flush

Discards any changes in offline mode.

commit

Commits changes made in offline mode.

set audit-logging

Turns on or off the logging facility.

show audit-logging

Displays current audit logging settings.

set loglevel

Sets level of logging information.

show loglevel

Displays the level of logging information.

set machine

Configures the computer on which the netsh commands are executed.

show machine

Displays the computer on which the netsh commands are executed.

exec

Executes a script file containing netsh commands.

quit or bye or exit

Exits the Netsh utility.

add alias

Adds an alias to an existing command.

delete alias

Deletes an alias to an existing command.

show alias

Displays all defined aliases.

dump

Writes configuration to a text file.

popd

A scripting command that pops a context from the stack.

pushd

A scripting command that pushes the current context on the stack.

The Netsh utility has the following command modes:

  • Online

    In online mode, commands issued at a Netsh command prompt are executed immediately.

  • Offline

    In offline mode, commands issued at a Netsh command prompt are accumulated and executed as a batch by issuing the commit global command. You can discard accumulated commands by issuing the flush global command.

  • Script

    With either the -f command-line option or by issuing the exec global command at a Netsh command prompt, all the netsh commands in the specified file are executed.

To create a script of the current configuration, use the global dump command. The dump command outputs the current running configuration in terms of netsh commands. You can use the script created by this command to configure a new server or to reconfigure the existing server. If you are making extensive changes to the configuration of a component, it is recommended that you begin the configuration session with the dump command, in case you need to restore the configuration prior to changes being made.

For more information on netsh commands for the Routing and Remote Access service, see: