Cheat Sheets

netsh Commands Cheat Sheet: Wi-Fi, Firewall, Port Proxy (PDF)

netsh isn’t dead. Microsoft’s own reference recommends PowerShell for network management, yet netsh still ships on every current Windows build, and a few jobs have no friendlier home: Wi-Fi profiles, the machine-wide WinHTTP proxy and port forwarding with portproxy all still run through it.

Original content from computingforgeeks.com - post 192161

The confusion comes from netsh’s age. Half its contexts are legacy, the error messages are vague, and several commands quietly do less than their names suggest. This netsh commands cheat sheet puts the useful ones in printable tables, then follows each one far enough to show what it actually changes. The walkthroughs below were run on Windows 11 and Windows Server 2025 from an administrator Command Prompt or as SYSTEM, and the page was last checked in December 2026.

netsh commands cheat sheet

Run every row from an elevated Command Prompt or PowerShell window. Read-only show commands work as a normal user, but anything that writes needs administrator rights. Replace Ethernet with the interface name from netsh interface show interface, and quote any name that contains a space. The rows that write files expect the folder to exist, so run mkdir C:\lab first, and type the advproxy JSON in cmd.exe, because PowerShell parses the braces itself.

Syntax and helpers

CommandWhat it does
netsh /?Lists the top-level contexts
netsh interface ipv4 /?Lists the commands inside one context
netsh show helperShows which DLL serves each context
netsh dumpPrints the current configuration as a netsh script
netsh -f C:\path\script.txtRuns a saved netsh script
netsh -r server01 interface show interfaceRuns a command on a remote computer (Remote Registry must be running there)

IP address, DNS and routes

CommandWhat it does
netsh interface show interfaceAdapters with admin state and connection state
netsh interface ipv4 show interfacesIndex, metric, MTU and state per interface
netsh interface ipv4 show config name="Ethernet"Address, gateway, DNS and DHCP state
netsh interface ipv4 show ipaddressesEvery address with its DAD state and lifetime
netsh interface ipv4 set address name="Ethernet" static 10.0.1.50 255.255.255.0 10.0.1.1Static address, mask and gateway
netsh interface ipv4 add address name="Ethernet" 10.0.1.51 255.255.255.0Adds a second address
netsh interface ipv4 set address name="Ethernet" source=dhcpBack to DHCP
netsh interface ipv4 set dnsservers name="Ethernet" static 10.0.1.1 primary validate=noSets the primary DNS server
netsh interface ipv4 add dnsservers name="Ethernet" 1.1.1.1 index=2 validate=noAdds a secondary DNS server
netsh interface ipv4 set dnsservers name="Ethernet" source=dhcpDNS from DHCP again
netsh interface ipv4 show routeRouting table
netsh interface ipv4 set subinterface "Ethernet" mtu=1450 store=persistentChanges the MTU
netsh interface ipv4 show tcpconnections localport=5985TCP sockets on one local port
netsh int tcp show globalTCP stack settings (autotuning, RSS, ECN)

Wi-Fi profiles (netsh wlan)

CommandWhat it does
netsh wlan show profilesSaved Wi-Fi profiles for all users and the current user
netsh wlan show profile name="HomeWiFi" key=clearOne profile, with the key in plain text (elevated prompt)
netsh wlan show interfacesConnected SSID, signal, channel and radio type
netsh wlan show driversDriver details and supported radio types
netsh wlan export profile folder=C:\wifi key=clearExports every profile to XML files
netsh wlan add profile filename=C:\wifi\Wi-Fi-HomeWiFi.xml user=allImports a profile for every user
netsh wlan connect name="HomeWiFi"Connects with a saved profile
netsh wlan delete profile name="HomeWiFi"Deletes a profile (wildcards allowed)
netsh wlan show wlanreportWrites an HTML report of recent Wi-Fi sessions

The lab VMs have no Wi-Fi radio, so the profile rows above (show profile key=clear, export, add, connect and delete) follow Microsoft’s netsh wlan reference rather than a capture. The Wi-Fi section shows what the VMs did print.

Firewall (netsh advfirewall)

CommandWhat it does
netsh advfirewall show allprofiles stateOn or off for Domain, Private and Public
netsh advfirewall show currentprofileActive profile, default policy and logging
netsh advfirewall firewall add rule name="Allow TCP 8080" dir=in action=allow protocol=TCP localport=8080Opens an inbound TCP port
netsh advfirewall firewall add rule name="Allow SSH from admin net" dir=in action=allow protocol=TCP localport=22 remoteip=10.0.1.0/24Opens a port to one subnet only
netsh advfirewall firewall add rule name="Allow ICMPv4 echo" dir=in action=allow protocol=icmpv4:8,anyAllows ping
netsh advfirewall firewall add rule name="Block outbound SMB" dir=out action=block protocol=TCP remoteport=445Blocks an outbound port
netsh advfirewall firewall show rule name="Allow TCP 8080"Shows every rule with that name
netsh advfirewall firewall set rule name="Allow SSH from admin net" new remoteip=10.0.1.0/24,10.0.2.15Edits an existing rule
netsh advfirewall firewall set rule group="Remote Desktop" new enable=yesEnables a built-in rule group
netsh advfirewall firewall delete rule name="Allow TCP 8080"Deletes every rule with that name
netsh advfirewall set allprofiles logging droppedconnections enableLogs dropped packets to pfirewall.log
netsh advfirewall export "C:\lab\fw-before.wfw"Backs up the whole policy
netsh advfirewall import "C:\lab\fw-before.wfw"Restores a saved policy
netsh advfirewall resetRestores the default policy and drops custom rules

Port forwarding (netsh interface portproxy)

CommandWhat it does
netsh interface portproxy add v4tov4 listenport=8080 connectaddress=127.0.0.1 connectport=9000Forwards port 8080 on every IPv4 address
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=10.0.1.51 connectaddress=127.0.0.1 connectport=9000Forwards on one address only
netsh interface portproxy add v4tov6 listenport=8443 connectaddress=::1 connectport=443IPv4 listener to an IPv6 backend
netsh interface portproxy show allEvery forwarding entry
netsh interface portproxy delete v4tov4 listenport=8080Removes the wildcard entry
netsh interface portproxy resetRemoves every entry

WinHTTP proxy (netsh winhttp)

CommandWhat it does
netsh winhttp show proxyLegacy machine proxy setting
netsh winhttp show advproxyAdvanced proxy setting (JSON)
netsh winhttp set proxy proxy-server="10.0.1.20:3128" bypass-list="*.corp.example.com;<local>"Sets the legacy proxy
netsh winhttp reset proxyLegacy proxy back to direct access
netsh winhttp import proxy source=ieCopies the calling user’s Internet Options proxy
netsh winhttp set advproxy setting-scope=machine settings={...}Sets the advanced proxy (full JSON below)

Resets and diagnostics

CommandWhat it does
netsh winsock resetResets the Winsock catalog (reboot required)
netsh int ip resetResets TCP/IP (IPv4) settings, static addressing included (reboot required)
netsh int ipv6 resetResets IPv6 settings only
netsh winsock show catalogLists Winsock providers
netsh trace start capture=yes tracefile=C:\lab\nettrace.etl maxsize=64Starts a packet capture
netsh trace stopStops it and builds the .etl and .cab

Those tables tell you what to type, not what happens next. So which commands lie to you? Below, each family runs on a real machine, and you see the places where the output misleads you, because a command that prints “Ok.” is not always a command that did what you meant.

Contexts are DLLs, and quoting decides the parse

netsh is a shell that loads helper DLLs, and every context you type is one of them. Because each DLL parses its own arguments, the same tool covers the firewall, Wi-Fi and the TCP stack with completely different grammar, so you cannot carry syntax from one context to another. netsh show helper lists the mapping, and on the Server 2025 VM the families from this cheat sheet resolve like this:

netsh show helper

The output is long, so here are the relevant rows trimmed from it:

Helper GUID                             DLL Filename  Command
--------------------------------------  ------------  -------
{02BC1F81-D927-4EC5-8CBC-8DD65E3E38E8}  AUTHFWCFG.DLL  advfirewall
{0705ECA1-7AAC-11D2-89DC-006008B0E5B9}  IFMON.DLL     interface
{725588AC-7A11-4220-A121-C92C915E8B73}  NETIOHLP.DLL    ipv4
{1C151866-F35B-4780-8CD2-E1924E9F03E1}  NETIOHLP.DLL    portproxy
{D3E9D893-852F-4E22-B05D-99293065773D}  NETTRACE.DLL  trace
{0BFDC146-56A3-4311-A7D5-7D9953F8326E}  WHHELPER.DLL  winhttp
{B2C0EEF4-CCE5-4F55-934E-ABF60F3DCF56}  WSHELPER.DLL  winsock
{D424E730-1DB7-4287-8C9B-0774F5AD0576}  WLANCFG.DLL   wlan

Quoting is the other thing you will get wrong at least once. netsh splits arguments on spaces before it reads name=, so an interface called Ethernet 2 without quotes becomes two arguments, and the second one lands in the wrong slot:

netsh interface ipv4 set address name=Ethernet 2 static 10.0.1.50 255.255.255.0

The error doesn’t mention the name at all, so you go hunting for a bad source value that you never typed:

Invalid source parameter (2).

You have three ways to avoid it, in order of preference:

  1. Quote the name: name="Ethernet 2".
  2. Use the interface index from netsh interface ipv4 show interfaces, for example name=6.
  3. Rename the adapter once with netsh interface set interface name="Ethernet 2" newname="LAN".

In the interface ipv4 and ipv6 contexts an index works where a name does. On the lab VM netsh interface ipv4 set address name=6 source=dhcp hit the same interface as name="Ethernet". If your script runs on many machines, use the quoted name anyway, because the index changes between hardware and a hardcoded 6 can reconfigure the wrong adapter.

Static addresses apply before they show

Setting a static address with netsh is one line: address, mask and gateway in that order. The command prints nothing when it succeeds, so you need a show right after it to know it worked. Run it from the console, not over RDP or SSH, because the address changes under your session the moment you press Enter:

netsh interface ipv4 set address name="Ethernet" static 10.0.1.50 255.255.255.0 10.0.1.1
netsh interface ipv4 set dnsservers name="Ethernet" static 10.0.1.1 primary validate=no
netsh interface ipv4 add dnsservers name="Ethernet" 1.1.1.1 index=2 validate=no
netsh interface ipv4 show config name="Ethernet"

What happens when you check immediately is the part that sends people back to the GUI. The gateway and DNS servers are there, but the IP Address line is missing:

Configuration for interface "Ethernet"
    DHCP enabled:                         No
    Default Gateway:                      10.0.1.1
    Gateway Metric:                       1
    InterfaceMetric:                      25
    Statically Configured DNS Servers:    10.0.1.1
                                          1.1.1.1
    Register with which suffix:           Primary only
    Statically Configured WINS Servers:   None

Your address isn’t lost. Windows runs duplicate address detection before it marks a new address usable, and on the lab VM show config left the address out until that finished, so a script that checks too early reports a failure that never happened. About five seconds later show ipaddresses lists it as Preferred:

netsh interface ipv4 show ipaddresses

Read the DAD State column first. Preferred means the address passed detection and is in use:

Interface 6: Ethernet

Addr Type  DAD State   Valid Life Pref. Life Address
---------  ----------- ---------- ---------- ------------------------
Manual     Preferred     infinite   infinite 10.0.1.50

Going back to DHCP takes two commands, one for the address and one for DNS. Forget the second and the machine keeps your static resolvers on a DHCP lease, which is a common reason a laptop resolves fine in the office and fails everywhere else. Running source=dhcp on an interface that already uses DHCP is harmless: netsh replies “DHCP is already enabled on this interface.” and changes nothing. MTU changes work the same way, with set subinterface "Ethernet" mtu=1450 store=persistent and show subinterfaces to confirm the new value. For the PowerShell side of the same settings, the PowerShell cheat sheet covers Get-NetIPConfiguration and its neighbours.

netsh wlan needs a running service and a radio

netsh wlan show profiles is the most searched netsh command, and it fails in two distinct ways before it ever lists a profile. The lab VMs have no Wi-Fi adapter, which makes both failures easy to reproduce:

netsh wlan show profiles on Windows 11 failing with wlansvc not running, then There is no wireless interface on the system after net start wlansvc

The two messages point at different layers, in the order netsh checks them:

  1. The Wireless AutoConfig Service (wlansvc) is not running. The WLAN AutoConfig service is stopped. It was stopped on the radio-less Windows 11 lab VM, and on Server 2025 it is a manual-start service. Start it with net start wlansvc.
  2. There is no wireless interface on the system. The service runs, but the Wi-Fi adapter is missing, disabled or has no driver. Check Device Manager or netsh wlan show drivers on a machine that should have one.

Every wlan command that touches a profile hit the second error on the lab VMs:

  • add profile filename=... user=all
  • show profile name=... key=clear
  • delete profile name=...

So the profile syntax in the table comes from Microsoft’s netsh wlan reference, not from a lab capture. Two details from that page matter in practice. export profile ... key=clear writes the key in plain text only when you run it as a local administrator, otherwise the key in the XML stays encrypted. And the export writes one XML file per profile named after the interface and profile, into a folder that must already exist on a local drive. For show profile key=clear, use an elevated prompt.

netsh wlan show wlanreport is the one wlan command that ran without a radio on Windows 11. It collected events and wrote C:\ProgramData\Microsoft\Windows\WlanReport\wlan-report-latest.html. The same command on Server 2025 stopped halfway with an unhelpful code:

Generating report ...
Querying WLAN Events ...
Querying NCSI Events ...
Querying NDIS Events ...
failed, error is 0x2

Error 0x2 is the Windows code for “file not found”, and it appeared even though wlansvc exists on Server 2025 and starts cleanly. Treat wlanreport as a client tool: run it on the laptop with the Wi-Fi problem, not on a server.

advfirewall accepts duplicate rule names

A rule name in Windows Firewall is a label, not a key. add rule never checks whether the name exists, so a script that runs twice leaves two identical rules behind, and delete rule name= removes every match at once:

netsh advfirewall firewall add rule accepting the same rule name twice and delete rule reporting Deleted 2 rule(s)

Watch for “Deleted 2 rule(s).” in that output. If you manage rules from a script, delete by name first and then add, so a rerun converges on one rule instead of stacking copies. The same name matching applies to set rule: it edits every rule with that name, and it reports how many it touched.

netsh advfirewall firewall set rule name="Allow SSH from admin net" new remoteip=10.0.1.0/24,10.0.2.15

The reply counts the rules it changed:

Updated 1 rule(s).
Ok.

Check the result with show rule, filtered to the one field you edited:

netsh advfirewall firewall show rule name="Allow SSH from admin net" | findstr /c:"RemoteIP"

The single address comes back normalised to a /32:

RemoteIP:                             10.0.1.0/24,10.0.2.15/32

set rule group="Remote Desktop" new enable=yes uses the same mechanism on a built-in group and reported “Updated 3 rule(s).” on Windows 11. A name that matches nothing prints “No rules match the specified criteria.”, so a cleanup script should read that text rather than assume the delete removed something. The guide to opening a port in Windows Server firewall does the same job from the GUI and PowerShell if you’d rather see both.

Before you experiment, take a backup. An export holds the whole policy, including every built-in rule, so you can undo a bad afternoon with one import instead of rebuilding rules by hand. Run the reset from the console: it returns to the default policy, which can switch off the rule that lets your RDP or SSH session in:

netsh advfirewall export "C:\lab\fw-before.wfw"
netsh advfirewall reset
netsh advfirewall import "C:\lab\fw-before.wfw"

On the lab VM the export was 331,776 bytes. After reset the custom SSH rule was gone, and after import it was back with its RemoteIP list intact. If you turned on droppedconnections logging, check netsh advfirewall show publicprofile logging after a reset before you trust pfirewall.log.

portproxy lives inside the IP Helper service

netsh interface portproxy is a userland TCP relay, not a NAT rule. When you add an entry, the IP Helper service (iphlpsvc) opens a real listening socket and copies bytes to the backend. The lab forwarded port 8080 to a small HTTP listener on 127.0.0.1:9000:

netsh interface portproxy add v4tov4 listenport=8080 connectport=9000 connectaddress=127.0.0.1

The add command prints nothing on success. show all and netstat together confirm the entry and the socket:

netsh interface portproxy show all listing 8080 to 127.0.0.1:9000 and netstat showing 0.0.0.0:8080 LISTENING on Windows 11

The PID on that LISTENING line belongs to svchost. In the text capture of the same step netstat reported PID 3116, and tasklist /svc names the service behind it:

Image Name                     PID Services
========================= ======== ============================================
svchost.exe                   3116 iphlpsvc

That ownership explains the behaviour people report as random. Stop IP Helper and every forward dies at once: on the lab VM the 8080 listener vanished from netstat and curl got nothing back. The entries themselves survive, because the configuration lives in the registry under HKLM\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4\tcp, so starting the service again reopens the listeners from that key under a new PID. In order, a forward needs:

  1. the portproxy entry in the registry
  2. iphlpsvc running to open the socket
  3. an inbound firewall rule for the listen port
  4. a backend that accepts the connection

Most guides skip the third item. portproxy doesn’t touch the firewall, so your forward works from localhost and times out from everywhere else until you add the rule. The entry also survived a reboot and both netsh int ip reset and netsh winsock reset on the lab VM, so a stale forward from an old WSL or Docker experiment can sit there for years.

Audit with show all before you trust a port as free. netsh interface portproxy reset clears every entry, and deleting one that doesn’t exist fails with “The system cannot find the file specified.”, which is the registry error leaking through rather than a missing file on disk.

Two more combinations are worth knowing. v4tov6 lets an IPv4 client reach an IPv6-only backend, and on Server 2025 show all labels it “Listen on ipv4: / Connect to ipv6:”. An entry with listenaddress=127.0.0.1 can coexist with a wildcard entry on the same port, and netstat then shows both sockets.

WinHTTP keeps two proxy settings that ignore each other

The machine-wide WinHTTP proxy is what Windows Update, many services and anything running as SYSTEM use, and it has nothing to do with the browser proxy in Settings. Microsoft’s WinHTTP netsh reference marks set proxy and show proxy as deprecated in favour of set advproxy and show advproxy. What it doesn’t spell out is that the two settings are stored separately and neither command reads the other’s, so you can check one, see no proxy, and still have a proxy in force.

The advproxy setting takes a JSON object, and the quotes inside it must be escaped with backslashes when you type it in cmd.exe. All four keys have to be present:

netsh winhttp set advproxy setting-scope=machine settings={\"Proxy\":\"10.0.1.20:3128\",\"ProxyBypass\":\"<local>\",\"AutoconfigUrl\":\"\",\"AutoDetect\":false}

Now ask both commands what the proxy is. Highlighted below is the line that causes the confusion:

netsh winhttp show proxy reporting Direct access while show advproxy reports ProxyIsEnabled true on Windows 11

show proxy says “Direct access (no proxy server)” while the advanced setting has a proxy enabled. Run it the other way round and you get the mirror image: set proxy writes the WinHttpSettings binary value, show proxy shows it, and show advproxy still reports "ProxyIsEnabled": false. So when a server can’t reach the internet, check both, in this order:

  1. netsh winhttp show advproxy
  2. netsh winhttp show proxy
  3. the user’s own proxy in Settings, for anything that runs as that user

Clearing them is asymmetric too. netsh winhttp reset proxy only resets the legacy value, and there is no reset advproxy: netsh answers “The following command was not found: winhttp reset advproxy.” To clear the advanced setting, set it again with an empty proxy:

netsh winhttp set advproxy setting-scope=machine settings={\"Proxy\":\"\",\"ProxyBypass\":\"\",\"AutoconfigUrl\":\"\",\"AutoDetect\":true}

The reply shows the cleared state, with PerUserProxySettings false because the scope was machine:

Current WinHTTP advanced proxy settings:

{
	"ProxyIsEnabled":	false,
	"AutoConfigIsEnabled":	false,
	"AutoDetect":	true,
	"PerUserProxySettings":	false
}

Leave out any of the four keys and netsh prints the current settings unchanged, followed by “The data is invalid.” Did your change apply? You only know from that last line, because the JSON above it looks perfectly sane. The out-of-box value on both lab machines was AutoDetect true with PerUserProxySettings true, and setting-scope=user puts that flag back if you want the per-user behaviour again.

Resets rewrite state and wait for a reboot

netsh winsock reset and netsh int ip reset are the classic fixes for a broken network stack. Neither takes effect until you restart, and neither touched the portproxy entries on the lab VMs. Both VMs were on DHCP, though, and Microsoft documents the IP reset as removing all user-configured settings. On a server with a static address, save netsh interface ipv4 show config or netsh dump output first and make sure you have console access before the reboot, because the address, gateway and DNS may not come back. The winsock reset prints a two-line message, typo included:

Sucessfully reset the Winsock Catalog.
You must restart the computer in order to complete the reset.

The IP reset output worries people more, because one line fails even from an elevated prompt:

netsh int ip reset output on Windows 11 with one Resetting failed Access is denied line and Restart the computer to complete this action

“Resetting , failed. Access is denied.” appeared on Windows 11 and on Server 2025, both running as SYSTEM. Blank names in that list are entries netsh does not label, and one of them refuses the write. You can ignore it: the command still ends with “Restart the computer to complete this action.”, and both VMs came back from the reboot with DHCP addresses. The Server also had its firewall on, answered outbound HTTP with a 200 and listed 28 Winsock providers before and after.

Older guides add a log file path, as in netsh int ip reset C:\lab\ipreset.log. On Server 2025 that ran the reset but never created the file, so don’t plan on the log for evidence. For a real capture, netsh trace start capture=yes and netsh trace stop produce an .etl plus a .cab of diagnostics. The stop step takes a while because it collects data, so don’t kill the window while it sits there.

Prove it from outside

A forward that works from localhost proves only the first two steps of the portproxy chain. The honest test runs from another machine, so the Server 2025 VM probed the Windows 11 box (10.0.1.60 in these captures) on port 8080 with the proxy entry in place and no firewall rule yet:

curl.exe -s -m 8 -o NUL -w "%{http_code} %{errormsg}\n" http://10.0.1.60:8080/

A timeout, not a refusal, which is what the default inbound block looks like from the other side:

000 Connection timed out after 8001 milliseconds

On the Windows 11 machine, open the listen port and confirm the rule exists:

netsh advfirewall firewall add rule name="portproxy 8080" dir=in action=allow protocol=TCP localport=8080
netsh advfirewall firewall show rule name="portproxy 8080"

The rule covers all three profiles, which matters because the lab VM sat on the Public profile:

netsh advfirewall firewall show rule name portproxy 8080 showing an inbound TCP 8080 allow rule on all profiles

Run the same probe from the Server again, this time printing the body:

curl.exe -s -m 8 http://10.0.1.60:8080/

The reply comes from the backend bound to loopback on the other machine, relayed by iphlpsvc:

hello from backend on 127.0.0.1:9000 (CFG-WIN11)

Nothing else changed between the two probes. One rule is the difference between a forward that works on the box and one that works on the network, so run the same outside check after every firewall change you make with netsh.

For the cmd.exe tools around netsh, the Windows CMD commands cheat sheet has the rest, the Windows Run commands list opens wf.msc and ncpa.cpl when you want the GUI to confirm, and the full set of printable sheets lives on the cheat sheets page. If the backend you forward to is SSH, OpenSSH Server on Windows Server covers the service side.

Keep reading

Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) AI Claude Code Cheat Sheet: Commands, Shortcuts and Flags (PDF) OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) AI OpenAI Codex CLI Cheat Sheet: Shortcuts, Commands, Flags (PDF) Linux and DevOps Cheat Sheets (Free PDF Pack) Cheat Sheets Linux and DevOps Cheat Sheets (Free PDF Pack) Install Grok Build on Windows 11 (Formerly Cursor) AI Install Grok Build on Windows 11 (Formerly Cursor) Dev Drive vs NTFS on Windows 11: Where the Speed Comes From Windows Dev Drive vs NTFS on Windows 11: Where the Speed Comes From Fix Windows Error “running scripts is disabled on this system” Windows Fix Windows Error “running scripts is disabled on this system”

Leave a Comment

Press ESC to close