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.
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
| Command | What it does |
|---|---|
netsh /? | Lists the top-level contexts |
netsh interface ipv4 /? | Lists the commands inside one context |
netsh show helper | Shows which DLL serves each context |
netsh dump | Prints the current configuration as a netsh script |
netsh -f C:\path\script.txt | Runs a saved netsh script |
netsh -r server01 interface show interface | Runs a command on a remote computer (Remote Registry must be running there) |
IP address, DNS and routes
| Command | What it does |
|---|---|
netsh interface show interface | Adapters with admin state and connection state |
netsh interface ipv4 show interfaces | Index, metric, MTU and state per interface |
netsh interface ipv4 show config name="Ethernet" | Address, gateway, DNS and DHCP state |
netsh interface ipv4 show ipaddresses | Every 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.1 | Static address, mask and gateway |
netsh interface ipv4 add address name="Ethernet" 10.0.1.51 255.255.255.0 | Adds a second address |
netsh interface ipv4 set address name="Ethernet" source=dhcp | Back to DHCP |
netsh interface ipv4 set dnsservers name="Ethernet" static 10.0.1.1 primary validate=no | Sets the primary DNS server |
netsh interface ipv4 add dnsservers name="Ethernet" 1.1.1.1 index=2 validate=no | Adds a secondary DNS server |
netsh interface ipv4 set dnsservers name="Ethernet" source=dhcp | DNS from DHCP again |
netsh interface ipv4 show route | Routing table |
netsh interface ipv4 set subinterface "Ethernet" mtu=1450 store=persistent | Changes the MTU |
netsh interface ipv4 show tcpconnections localport=5985 | TCP sockets on one local port |
netsh int tcp show global | TCP stack settings (autotuning, RSS, ECN) |
Wi-Fi profiles (netsh wlan)
| Command | What it does |
|---|---|
netsh wlan show profiles | Saved Wi-Fi profiles for all users and the current user |
netsh wlan show profile name="HomeWiFi" key=clear | One profile, with the key in plain text (elevated prompt) |
netsh wlan show interfaces | Connected SSID, signal, channel and radio type |
netsh wlan show drivers | Driver details and supported radio types |
netsh wlan export profile folder=C:\wifi key=clear | Exports every profile to XML files |
netsh wlan add profile filename=C:\wifi\Wi-Fi-HomeWiFi.xml user=all | Imports 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 wlanreport | Writes 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)
| Command | What it does |
|---|---|
netsh advfirewall show allprofiles state | On or off for Domain, Private and Public |
netsh advfirewall show currentprofile | Active profile, default policy and logging |
netsh advfirewall firewall add rule name="Allow TCP 8080" dir=in action=allow protocol=TCP localport=8080 | Opens 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/24 | Opens a port to one subnet only |
netsh advfirewall firewall add rule name="Allow ICMPv4 echo" dir=in action=allow protocol=icmpv4:8,any | Allows ping |
netsh advfirewall firewall add rule name="Block outbound SMB" dir=out action=block protocol=TCP remoteport=445 | Blocks 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.15 | Edits an existing rule |
netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes | Enables 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 enable | Logs 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 reset | Restores the default policy and drops custom rules |
Port forwarding (netsh interface portproxy)
| Command | What it does |
|---|---|
netsh interface portproxy add v4tov4 listenport=8080 connectaddress=127.0.0.1 connectport=9000 | Forwards port 8080 on every IPv4 address |
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=10.0.1.51 connectaddress=127.0.0.1 connectport=9000 | Forwards on one address only |
netsh interface portproxy add v4tov6 listenport=8443 connectaddress=::1 connectport=443 | IPv4 listener to an IPv6 backend |
netsh interface portproxy show all | Every forwarding entry |
netsh interface portproxy delete v4tov4 listenport=8080 | Removes the wildcard entry |
netsh interface portproxy reset | Removes every entry |
WinHTTP proxy (netsh winhttp)
| Command | What it does |
|---|---|
netsh winhttp show proxy | Legacy machine proxy setting |
netsh winhttp show advproxy | Advanced 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 proxy | Legacy proxy back to direct access |
netsh winhttp import proxy source=ie | Copies 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
| Command | What it does |
|---|---|
netsh winsock reset | Resets the Winsock catalog (reboot required) |
netsh int ip reset | Resets TCP/IP (IPv4) settings, static addressing included (reboot required) |
netsh int ipv6 reset | Resets IPv6 settings only |
netsh winsock show catalog | Lists Winsock providers |
netsh trace start capture=yes tracefile=C:\lab\nettrace.etl maxsize=64 | Starts a packet capture |
netsh trace stop | Stops 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:
- Quote the name:
name="Ethernet 2". - Use the interface index from
netsh interface ipv4 show interfaces, for examplename=6. - 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:

The two messages point at different layers, in the order netsh checks them:
- 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. - 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 driverson 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=allshow profile name=... key=cleardelete 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:

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:

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:
- the portproxy entry in the registry
iphlpsvcrunning to open the socket- an inbound firewall rule for the listen port
- 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:

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:
netsh winhttp show advproxynetsh winhttp show proxy- 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:

“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:

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.