netsh

On this page 7

netsh, short for Network Shell, is a command-line scripting utility built into Windows that displays and modifies the network configuration of a local or remote computer. It organizes its functions into nested contexts such as interface, wlan, advfirewall, winhttp and trace, each provided by a helper library, and it can run single commands, an interactive session or a complete configuration script.

In Windows networking, netsh has been a core administration tool since Windows 2000. Many of its tasks now have PowerShell equivalents, yet netsh remains the quickest way to perform resets, export wireless profiles, configure system proxies and capture network traces on any supported Windows edition.

How netsh contexts and helpers are structured

netsh works as a shell with a command hierarchy. Each top-level context is implemented by a helper DLL registered with netsh, and contexts can contain subcontexts; for example, netsh interface ipv4 sits under the interface context. Typing a context name in interactive mode moves into it, and ? lists the available commands at that level.

The following table summarizes the contexts that administrators use most often on current Windows versions.

ContextPurposeExample command
interface ipv4 / ipv6Addresses, routes, DNS servers, MTUnetsh interface ipv4 show config
wlanWireless profiles, drivers, hosted settingsnetsh wlan show profiles
advfirewallWindows Defender Firewall profiles and rulesnetsh advfirewall show allprofiles
winhttpSystem-wide proxy for servicesnetsh winhttp show proxy
winsockWinsock catalog and layered providersnetsh winsock reset
tracePacket capture and diagnostic tracingnetsh trace start capture=yes
httpHTTP.sys URL reservations and certificatesnetsh http show urlacl
Frequently used netsh contexts

Commands that only read state run in a standard prompt, but anything that changes configuration requires an elevated session. Without elevation, netsh usually reports that the requested operation requires elevation and makes no change.

Modes of operation and scripting

netsh can be used in three modes, which makes it suitable both for quick troubleshooting and for repeatable configuration. The table below compares them.

ModeHow it is invokedTypical use
Single commandFull path typed on one lineQuick checks and batch files
Interactive shellnetsh followed by context navigationExploring options on a live system
Script filenetsh -f file.txt or exec inside the shellApplying a saved configuration
Ways to run netsh

The dump command writes the current configuration of a context as a script, which can be stored and replayed on another machine. The -r option targets a remote computer, although it depends on the Remote Registry service and is often blocked in hardened environments, where PowerShell remoting or WinRM is preferred.

Common administrative tasks with netsh

Most everyday use of netsh falls into a small set of repairs and configuration changes. Reset commands are the best known, because support teams use them to repair corrupted network stacks after malware removal, VPN client uninstallation or failed driver updates.

  • netsh winsock reset restores the Winsock catalog to its default state and removes faulty layered service providers; a restart is required.
  • netsh int ip reset rewrites TCP/IP registry settings to their defaults, which also clears manual addressing.
  • netsh wlan export profile saves wireless profiles as XML files for migration or deployment.
  • netsh winhttp import proxy source=ie copies the user proxy to the system WinHTTP proxy used by services such as Windows Update.
  • netsh interface portproxy add v4tov4 creates a TCP port forwarding rule, often used with virtual machines and WSL.

The trace context deserves special mention: netsh trace start capture=yes records packets and provider events into an ETL file without installing any capture driver. The file can be analyzed in Microsoft diagnostic tools or converted to the pcapng format for Wireshark.

netsh compared with PowerShell networking cmdlets

Microsoft has stated that netsh functionality may be removed in future versions and recommends PowerShell modules such as NetTCPIP, NetAdapter and NetSecurity for new automation. In practice, the two tools coexist, and each has clear strengths.

TasknetshPowerShell alternative
Set a static IP addressinterface ipv4 set addressNew-NetIPAddress
Create a firewall ruleadvfirewall firewall add ruleNew-NetFirewallRule
Export wireless profilesNative and simpleNo built-in cmdlet
Reset WinsockNative and simpleNo built-in cmdlet
Bulk changes across serversLimited remote supportObject pipeline and remoting
Choosing between netsh and PowerShell

PowerShell returns structured objects that are easier to filter and validate, while netsh returns text that scripts must parse. The older netsh firewall context is already deprecated in favor of advfirewall, and some legacy contexts no longer exist in current releases.

Limitations, risks and common mistakes

netsh acts immediately and has no undo function, so a mistyped command can disconnect a remote session or silently weaken a firewall. Experienced administrators export the relevant context with dump or advfirewall export before making changes.

MistakeConsequencePrevention
Changing the address of the remote session adapterLost connection to the serverUse console access or a scheduled rollback
Running resets as a first stepManual settings and VPN adapters lostDiagnose with show commands first
Revealing Wi-Fi keys with key=clearPassword exposed on screen or in logsRestrict to authorized support staff
Adding broad allow rulesUnintended exposure of servicesScope rules by profile, port and address
Typical netsh mistakes and their consequences

Output formats can also vary between Windows versions and display languages, so scripts that parse netsh text output are fragile. For long-lived automation, PowerShell or configuration management tools are the more robust choice.

Stripped to the essentials

netsh is a text-based control panel for networking in Windows. Instead of clicking through settings windows, a technician types short commands to see or change how the computer connects to networks.

It is especially handy for repairs. When internet access breaks in a strange way, a single netsh command can put the network settings back to factory defaults. It can also save Wi-Fi details, set proxy servers and record network traffic for analysis. Because it changes things instantly, it should be used with care and the right permissions.

Where it is applied

A help desk technician at a regional accounting firm receives a ticket from an employee whose laptop shows a Wi-Fi connection but cannot open any website after a third-party VPN client was removed. Other devices on the same network work normally.

In an elevated prompt, the technician first runs netsh winhttp show proxy and netsh interface ipv4 show config to rule out a stray proxy or a wrong DNS server. Both look correct, so the suspicion turns to a leftover layered service provider. The technician runs netsh winsock reset followed by a restart.

After the reboot, browsing works again. For the record, the technician also starts a short netsh trace capture to confirm normal DNS traffic and attaches it to the ticket. The fix takes about ten minutes without reinstalling network drivers or reimaging the laptop.