# Netsh – how to manage networks with Netsh commands

Anyone who works with Windows network configurations will sooner or later come across the Network Shell (Netsh). The term refers to an **interface between users and the operating system**, which enables the administration and configuration of local, and remote network settings.

The range of applications includes settings for the Windows firewall and LAN/WLAN management as well as IP and server configuration. Moreover, networked infrastructure can also be protected from external attack. Using the command line tool, it’s also possible to **diagnose problems** and carry out repairs in the network. A big advantage of Netsh is that network-related administration tasks can be performed quickly and conveniently, and can be **automated with scripts**.

## Netsh commands: starting the command prompt

It’s necessary to access the **command line** in order to use Netsh. There, you can open the “Run” menu as follows:

1. Press the key combination \[Windows\] + \[R\]
2. Enter “cmd” in the entry field (1)
3. Click the “OK” button (2)

[![Image: Opening the “Run” menu](https://www.ionos.com/digitalguide/fileadmin/_processed_/3/3/csm_Opening-the-Run-menu_aa24d132b7.webp "Opening the “Run” menu")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Opening-the-Run-menu.png) Opening the “Run” menu The command prompt will then launch. The service program will open after you enter “netsh” and confirm with \[Enter\].

[![Image: Command prompt for Netsh commands](https://www.ionos.com/digitalguide/fileadmin/_processed_/5/7/csm_Command-prompt-for-Netsh-commands_8fa73c2868.webp "Command prompt for Netsh commands")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Command-prompt-for-Netsh-commands.png) Command prompt for Netsh commands If Netsh commands and scripts aren’t run or if more fundamental interventions in the network configuration are planned, you’ll need to start **Network Shell with administrator rights**. These steps are required on Windows 10:

1. Right-click on the Windows symbol on the left side of the task bar or press the key combination \[Windows\] + \[X\].
2. Choose the entry “Command Prompt (Admin)” in the context menu that appears:

[![Image: Context menu opened via the Windows task bar symbol](https://www.ionos.com/digitalguide/fileadmin/_processed_/d/3/csm_Context-menu-opened-via-the-Windows-task-bar-symbol_c0061d957a.webp "Context menu opened via the Windows task bar symbol")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Context-menu-opened-via-the-Windows-task-bar-symbol.png) Context menu opened via the Windows task bar symbol Netsh includes the **program file *netsh.exe*** located in the Windows system folder (*%windir%\\system32*). Directly opening the file streamlines the Netsh command entry procedure. You can enter the path *C:\\Windows\\System32\\netsh.exe* into the address line of Windows Explorer and press \[Enter\]. You can then enter Netsh commands straight away in the entry window that appears.

Launching the file is even faster by using a **shortcut**. Once created, a simple mouse click will be enough to launch the command entry:

1. Right-click on the Windows desktop. Click on the menu entry “New” (1) and then click on “Shortcut” in the next context menu (2):

[![Image: Creating a context menu shortcut](https://www.ionos.com/digitalguide/fileadmin/_processed_/9/1/csm_Creating-a-context-menu-shortcut_7ea5058427.webp "Creating a context menu shortcut")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Creating-a-context-menu-shortcut.png) Creating a context menu shortcut 1. In the **shortcut assistant**, enter the path *C:\\Windows\\System32\\netsh.exe* (1) and click on “Next” (2):

[![Image: Path entry for the Netsh shortcut](https://www.ionos.com/digitalguide/fileadmin/_processed_/d/d/csm_Path-entry-for-the-Netsh-shortcut_4f63b0e940.webp "Path entry for the Netsh shortcut")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Path-entry-for-the-Netsh-shortcut.png) Path entry for the Netsh shortcut 1. You should give the shortcut a **suitable name** (1); the shortcut will then be placed on the desktop after clicking “Finish” (2):

[![Image: Entering a name for the Netsh shortcut](https://www.ionos.com/digitalguide/fileadmin/_processed_/b/7/csm_Entering-a-name-for-the-Netsh-shortcut_1b7c9b425d.webp "Entering a name for the Netsh shortcut")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Entering-a-name-for-the-Netsh-shortcut.png) Entering a name for the Netsh shortcut ## How Netsh works

The service program Netsh provides an **extensive command syntax**. If you want to complete certain tasks, you’ll need to familiarize yourself with the specific structure of the Network Shell. The structure of the service program is based on **contexts** that represent various administration levels. Each context encompasses a certain network functionality (e.g. IP, LAN and firewall configuration). The program uses the files of the Dynamic-Link Library (DLL) for context-bound interaction with other Windows components. For instance, Netsh utilizes *Dhcpmon.dll* to change and manage DHCP settings.

To use a context, it’s necessary to switch to it in the command prompt of Windows. For example, the **“LAN administration” context** is accessed as follows:

1. After opening the command prompt, enter “netsh” and confirm with \[Enter\].
2. Then enter “lan” and confirm with \[Enter\].
3. The command prompt will now show the context change: *netsh lan&gt;*

[![Image: Context changes in Netsh](https://www.ionos.com/digitalguide/fileadmin/_processed_/5/9/csm_Context-changes-in-Netsh_5b38bd0470.webp "Context changes in Netsh")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Context-changes-in-Netsh.png) Context changes in Netsh After changing to the “LAN” context, a number of **context-specific and cross-context commands** will be available. The context-specific commands include “set” (which configures settings at interfaces). An example for a general and cross-context Netsh command is the help command “/?”, which lists the available sub-contexts and commands in each section. Entering it in the “LAN” section will produce the following list of context-specific and cross-context commands:

[![Image: Commands in the “LAN” Netsh context](https://www.ionos.com/digitalguide/fileadmin/_processed_/0/c/csm_Commands-in-the-LAN-Netsh-context_e78e59b3cc.webp "Commands in the “LAN” Netsh context")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Commands-in-the-LAN-Netsh-context.png) Commands in the “LAN” Netsh context For instance, if you switch to the **firewall context**, the associated command reference will look like this:

[![Image: Commands in the “firewall” Netsh context](https://www.ionos.com/digitalguide/fileadmin/_processed_/1/8/csm_Commands-in-the-firewall-Netsh-context_43dbb6ec4e.webp "Commands in the “firewall” Netsh context")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Commands-in-the-firewall-Netsh-context.png) Commands in the “firewall” Netsh context Besides the context-bound structure, there are other special points to consider when using the program. Netsh can either be used in a non-interactive or interactive mode. In the **non-interactive mode**, for example, important network settings are exported to a text file and reimported for subsequent recovery.

In the **interactive mode**, direct requests can be initiated. If you enter “netsh interface ip show address”, the current IP address of the computer will be displayed. The interactive mode can be used **online or offline**. The online model directly implements operations, while the offline mode saves actions and runs them later. The saved actions are activated at the desired time via the Netsh command “commit”.

## Netsh commands and their contexts

We’ve summarized the **main Netsh commands** with a short explanation of the contexts in the table below. In the case of general, cross-context commands, additional explanations are not necessary (right-hand column). Depending on the operating system version and the role in the network (client or server), the available **commands may vary** in some instances. The command entry on a computer with a Windows Server 2016 data center is as follows:

<table>
  <thead>
    <tr>
      <th>Command</th>
      <th>Implementation</th>
      <th>Netsh context managed</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>..</td>
      <td>Switches to a context level higher</td>
      <td></td>
    </tr>
    <tr>
      <td>?</td>
      <td>Displays a list of commands</td>
      <td></td>
    </tr>
    <tr>
      <td>abort</td>
      <td>Discards changes made in offline mode</td>
      <td></td>
    </tr>
    <tr>
      <td>add</td>
      <td>Adds a configuration entry to the list</td>
      <td></td>
    </tr>
    <tr>
      <td>advfirewall</td>
      <td>Switches to the “netsh advfirewall” context</td>
      <td>Firewall (policies and configuration)</td>
    </tr>
    <tr>
      <td>alias</td>
      <td>Adds an alias</td>
      <td></td>
    </tr>
    <tr>
      <td>branchcache</td>
      <td>Switches to the “netsh branchcache” context</td>
      <td>Branch cache settings</td>
    </tr>
    <tr>
      <td>bridge</td>
      <td>Switches to the “netsh bridge” context</td>
      <td>Network bridge</td>
    </tr>
    <tr>
      <td>bye</td>
      <td>Ends the program</td>
      <td></td>
    </tr>
    <tr>
      <td>commit</td>
      <td>Applies changes made in offline mode</td>
      <td></td>
    </tr>
    <tr>
      <td>delete</td>
      <td>Deletes a configuration entry from the list of entries</td>
      <td></td>
    </tr>
    <tr>
      <td>dhcpclient</td>
      <td>Switches to the “netsh dhcpclient” context</td>
      <td>DHCP client</td>
    </tr>
    <tr>
      <td>dnsclient</td>
      <td>Switches to the “netsh dnsclient” context</td>
      <td>DNS client settings</td>
    </tr>
    <tr>
      <td>dump</td>
      <td>Displays a configuration script</td>
      <td></td>
    </tr>
    <tr>
      <td>exec</td>
      <td>Runs a script file</td>
      <td></td>
    </tr>
    <tr>
      <td>exit</td>
      <td>Ends the program</td>
      <td></td>
    </tr>
    <tr>
      <td>firewall</td>
      <td>Switches to the “netsh firewall” context</td>
      <td>Firewall (policies and configuration)</td>
    </tr>
    <tr>
      <td>help</td>
      <td>Displays a list of commands</td>
      <td></td>
    </tr>
    <tr>
      <td>http</td>
      <td>Switches to the “netsh http” context</td>
      <td>HTTP server driver (http.sys)</td>
    </tr>
    <tr>
      <td>interface</td>
      <td>Switches to the “netsh interface” context</td>
      <td>IP configuration (v4, v6)</td>
    </tr>
    <tr>
      <td>ipsec</td>
      <td>Switches to the “netsh ipsec” context</td>
      <td>IPSEC policies</td>
    </tr>
    <tr>
      <td>ipsecdosprotection</td>
      <td>Switches to the “netsh ipsecdosprotection” context</td>
      <td>Protection against IPSEC denial-of-service attacks</td>
    </tr>
    <tr>
      <td>lan</td>
      <td>Switches to the “netsh lan” context</td>
      <td>Wired network interfaces</td>
    </tr>
    <tr>
      <td>namespace</td>
      <td>Switches to the “netsh namespace” context</td>
      <td>DNS client policies</td>
    </tr>
    <tr>
      <td>netio</td>
      <td>Switches to the “netsh netio” context</td>
      <td>Commitment filters</td>
    </tr>
    <tr>
      <td>offline</td>
      <td>Sets the current mode to offline</td>
      <td></td>
    </tr>
    <tr>
      <td>online</td>
      <td>Sets the current mode to online</td>
      <td></td>
    </tr>
    <tr>
      <td>popd</td>
      <td>Switches to the context saved via pushd in the stack</td>
      <td></td>
    </tr>
    <tr>
      <td>pushd</td>
      <td>Applies the current context to the stack</td>
      <td></td>
    </tr>
    <tr>
      <td>quit</td>
      <td>Ends the program</td>
      <td></td>
    </tr>
    <tr>
      <td>ras</td>
      <td>Switches to the “netsh ras” context</td>
      <td>Remote-access server</td>
    </tr>
    <tr>
      <td>rpc</td>
      <td>Switches to the “netsh rpc” context</td>
      <td>RPC service configuration</td>
    </tr>
    <tr>
      <td>set</td>
      <td>Updates the configuration settings</td>
      <td></td>
    </tr>
    <tr>
      <td>show</td>
      <td>Displays information</td>
      <td></td>
    </tr>
    <tr>
      <td>trace</td>
      <td>Switches to the “netsh trace” context</td>
      <td></td>
    </tr>
    <tr>
      <td>unalias</td>
      <td>Deletes an alias name</td>
      <td></td>
    </tr>
    <tr>
      <td>wfp</td>
      <td>Switches to the “netsh wfp” context</td>
      <td>Windows filtering platform</td>
    </tr>
    <tr>
      <td>winhttp</td>
      <td>Switches to the “netsh winhttp” context</td>
      <td>Proxy and tracing settings of the Windows HTTP client</td>
    </tr>
    <tr>
      <td>winsock</td>
      <td>Switches to the “netsh winsock” context</td>
      <td>Winsock configuration</td>
    </tr>
    <tr>
      <td>wlan</td>
      <td>Switches to the “netsh wlan” context</td>
      <td>Wireless network interfaces</td>
    </tr>
  </tbody>
</table>

## Syntax parameters for Netsh – what do they mean?

To implement specific actions and tasks, Netsh commands can be given **optional parameters**. The syntax scheme for the combination of Netsh commands and parameters is as follows:

```none
netsh [-a AliasFile] [-c Context] [-r RemoteComputer] [-u [DomainName\]UserName] [-p Password | *] [command | -f ScriptFile]
```

The following parameters are **all optional**, so they can be added and used where needed.

<table>
  <thead>
    <tr>
      <th>-a</th>
      <th>Return to Netsh command prompt after running the alias file</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>AliasFile</td>
      <td>Specifies the name of the text file that contains at least one Netsh command</td>
    </tr>
    <tr>
      <td>-c</td>
      <td>Switches to the specified Netsh context</td>
    </tr>
    <tr>
      <td>Context</td>
      <td>Placeholder for the context to be entered (e.g. WLAN)</td>
    </tr>
    <tr>
      <td>-r</td>
      <td>Causes the command to be run on a remote computer; the remote registration service must be executed there.</td>
    </tr>
    <tr>
      <td>RemoteComputer</td>
      <td>Name of the remote computer that is configured</td>
    </tr>
    <tr>
      <td>-u</td>
      <td>Indicates that the Netsh command is run under a user account</td>
    </tr>
    <tr>
      <td>DomainName\\</td>
      <td>Designates the user account domain (the standard value is the local domain if no special domain is specified)</td>
    </tr>
    <tr>
      <td>UserName</td>
      <td>Name of the user account</td>
    </tr>
    <tr>
      <td>-p</td>
      <td>A password can be entered for the user account</td>
    </tr>
    <tr>
      <td>Password</td>
      <td>Specifies the password for the user account that is stated with -u UserName</td>
    </tr>
    <tr>
      <td>NetshCommand</td>
      <td>Netsh command to be run</td>
    </tr>
    <tr>
      <td>-f</td>
      <td>Ends Netsh after running the script file</td>
    </tr>
    <tr>
      <td>ScriptFile</td>
      <td>Script to be run</td>
    </tr>
  </tbody>
</table>

### Resetting the TCP/IP Stack with Netsh

A common use for Netsh commands is to **reset the TCP/IP stack**, which provides for the exchange of data packages in networks. In the event of network and internet issues, this measure can help to remove defective or incorrectly configured [TCP/IP protocols](https://www.ionos.com/digitalguide/server/know-how/introduction-to-tcp/ "Introduction to TCP") for example. The following **repair command** executes a reset and re-installs TCP/IPv4:

```none
netsh int ip reset
```

A **protocol file** can also be created that logs the changes made:

```none
netsh int ip reset c:\tcpipreset.txt
```

After running the reset, the **computer will need to be restarted**.

Tip Netsh commands can also be used in batch files (*\*.bat*) to automate routine tasks. Find out more in our guide “[Removing Batch Files](https://www.ionos.com/digitalguide/server/tools/creating-a-batch-file/ "Creating a batch file")”.

### Importing and exporting network settings

Netsh allows you to export **current network settings** into a plain text file. In case of network problems, a functioning and error-free configuration can then be quickly restored.

In the first step (export), the **network configuration is read out**, written into a text file (*netcnfig.txt*)), and saved in the example directory “Network Configuration” on the *C:\\* drive. Before the first export, you’ll need to manually create the “Network Configuration” folder on the destination drive (Netsh does not perform this step automatically). Then, switch to the command prompt and enter the code below:

```none
netsh -c interface dump>c:\Network Configuration\netcnfig.txt
```

The following command entry is required for subsequently **importing the settings**:

```none
netsh -f c:\Network Configuration\netcnfig.txt
```

Tip Windows 10 also supports **copy and paste** in the command prompt. You can simply copy the command syntax from this article and insert it into the entry window.

### IP configuration with Netsh

A prevalent use case for Netsh is **changing IP settings**. If a computer in the network doesn’t contain a static IP address but an automatically assigned one, the [Dynamic Host Configuration Protocol](https://www.ionos.com/digitalguide/server/configuration/dhcp-an-overview-of-the-clientserver-protocol/ "DHCP: An overview of the Client/Server protocol") (DHCP) is used. This communication protocol automatically assigns IP addresses to clients in a network, and other required configuration data. This process takes multiple steps:

In the first step, the current settings and **names of the available network adapters** are requested:

```none
netsh interface ipv4 show interface
```

[![Image: Display of network adapters](https://www.ionos.com/digitalguide/fileadmin/_processed_/0/4/csm_Display-of-network-adapters_b9f1407837.webp "Display of network adapters")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2020/Display-of-network-adapters.png) Display of network adapters Now a **certain LAN adapter** (in this case: Ethernet) is determined as the addressee for the IP assignment via DHCP.

```none
netsh interface ipv4 set address name="Ethernet" source=dhcp
```

Next, DHCP applies the **dynamic administration for network settings** that relate to the Ethernet adapter.

### Activating and deactivating Windows firewall

If you wish to **activate or deactivate the Windows firewall**, all you need is a simple Netsh command syntax. A firewall is activated as follows:

```none
netsh firewall set opmode enable
```

Firewall deactivation requires the following command:

```none
netsh firewall set opmode disable
```

Note In some contexts, Windows will recommend alternatives to network administration with Netsh. Here, [Windows PowerShell](https://www.ionos.com/digitalguide/server/know-how/windows-powershell/ "Windows PowerShell") is often suggested and you can find an introduction to it in our Digital Guide.


This is a markdown version of: [https://www.ionos.com/digitalguide/server/tools/netsh/](https://www.ionos.com/digitalguide/server/tools/netsh/) for AI/LLM consumption.