Netsh Command-Line Tool

Netsh is a command-line and scripting tool for Windows 2000 networking components for local or remote computers. Netsh is supplied with Windows 2000. Netsh also provides the ability to save a configuration script in a text file for archival purposes or for configuring other servers.

Netsh is a shell that can support multiple Windows 2000 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 Windows 2000 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 subcontexts ip and ipx exist to group IP routing and IPX routing commands together.

Netsh command-line options include the following:

–a AliasFile    Specifies that an alias file be used. An alias file contains a list of Netsh commands and an aliased version so that the aliased command line can be used in place of the Netsh command. Alias files can be used to map commands to the appropriate Netsh command that might be more familiar in other platforms.

–c Context    Specifies the context of the command corresponding to an installed helper DLL.

Command    Specifies the Netsh command to carry out.

–f ScriptFile    Specifies that all of the Netsh commands in the file ScriptFile be run.

–r Remote Computer Name or IP Address    Specifies that Netsh commands are run on the remote computer specified by its name or IP address.

Commands can be abbreviated to the shortest unambiguous string. For example, issuing the command ro ip sh int is equivalent to issuing routing ip show interface . Netsh commands can be either global or context specific. Global commands can be issued in any context and are used for general Netsh functions. Context-specific commands vary according to the context.

Table 2.2 lists the netsh global commands.

Table 2.2 Global Netsh Commands

Command

Description

..

Moves up one context level.

? or help

Displays command-line Help.

add helper

Add a Netsh helper DLL.

delete helper

Removes a Netsh helper DLL.

show helper

Displays the installed Netsh helper DLLs.

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.

show machine

Displays the computer on which the Netsh commands are carried out.

exec

Executes a script file containing Netsh commands.

quit or bye or exit

Exits Netsh.

add alias

Adds an alias to an existing command.

delete alias

Deletes an alias from an existing command.

show alias

Displays all defined aliases.

dump

Writes configuration.

popd

A scripting command that pops a context from the stack.

pushd

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

Netsh has the following command modes:

  • Online
    In online mode, commands issued at a Netsh command prompt are carried out immediately.

  • Offline
    In offline mode, commands issued at a Netsh command prompt are accumulated and carried out as a batch by issuing the commit global command. Accumulated commands can be discarded by issuing the flush global command.

You can also run a script (a text file with a list of Netsh commands) by using either the – f command-line option or by issuing the exec global command at a Netsh command prompt.

To create a script of the current configuration, use the global dump command. The dump command generates

the current running configuration in terms of Netsh commands. You can then 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 to begin the configuration session with the dump command, in case you need to restore the configuration prior to changes being made.

For the Routing and Remote Access service, Netsh has the following contexts:

  • ras
    Use commands in the ras context to configure remote access configuration.

  • aaaa
    Use commands in the aaaa context to configure the AAAA component used by both Routing and Remote Access and Internet Authentication Service.

  • routing
    Use commands in the routing context to configure IP and IPX routing.

  • interface
    Use commands in the interface context to configure demand-dial interfaces.

For more information about context-specific commands, see Windows 2000 Server Help and the help provided by the Netsh tool.