COMMAND
netshNetwork shell for interface, firewall and Wi-Fi
netsh (network shell) configures nearly every part of Windows networking from the command line: interface addresses, Windows Defender Firewall rules, Wi-Fi profiles, the dynamic port range, and stack resets. It is organised into contexts such as interface, advfirewall and wlan, each with its own commands.
Purpose
netsh is a single command that reaches deep into Windows networking through a tree of contexts. You either enter a context interactively or give the full path on one line.
Contexts you will actually use
| Context | For |
|---|---|
interface ipv4 / ipv6 | Addresses, DNS, the dynamic port range |
advfirewall firewall | Windows Defender Firewall rules |
wlan | Wireless profiles and diagnostics |
winsock | Reset the Winsock catalog |
int tcp | TCP global settings |
Set a static IP address
netsh interface ipv4 set address name="Ethernet" static 192.168.1.50 255.255.255.0 192.168.1.1
netsh interface ipv4 set dns name="Ethernet" static 1.1.1.1
netsh interface ipv4 add dns name="Ethernet" 1.0.0.1 index=2Return to DHCP:
netsh interface ipv4 set address name="Ethernet" dhcp
netsh interface ipv4 set dns name="Ethernet" dhcpSee static vs dynamic IP.
Firewall rules
netsh advfirewall firewall add rule name="Allow RDP from mgmt" dir=in action=allow protocol=TCP localport=3389 remoteip=10.20.0.0/16
netsh advfirewall firewall show rule name=all
netsh advfirewall set allprofiles state onThe firewall basics record explains profiles and scoping; port 3389 covers RDP exposure.
Wi-Fi
netsh wlan show profiles
netsh wlan show profile name="MyNetwork" key=clear
netsh wlan show interfacesReset the stack
netsh winsock reset
netsh int ip resetReboot afterward. This is a standard repair for corrupted network configuration, layered service providers left by removed software, or a machine that shows a valid IP but cannot pass traffic.
The dynamic port range
netsh int ipv4 show dynamicport tcp
netsh int ipv4 set dynamicport tcp start=10000 num=55000See ephemeral ports for when to change it.
Common mistakes
- Not running elevated. Show commands work unprivileged; every change needs administrator rights.
- Wrong interface name. It must match
netsh interface show interfaceexactly, quotes included. - Resetting the stack as a first step. It is disruptive; try ipconfig and driver checks first.
Frequently asked questions
How do I reset the network stack with netsh?
From an elevated prompt: netsh winsock reset and netsh int ip reset, then reboot. This rebuilds the Winsock catalog and TCP/IP settings and fixes many "connected but no internet" problems caused by damaged network software.
How do I see a saved Wi-Fi password?
netsh wlan show profile name="SSID" key=clear shows the key under "Key Content" for networks this machine has connected to, if you have administrator rights.
Is netsh deprecated?
The interface and some contexts are stable, but Microsoft steers new work toward PowerShell NetTCPIP, NetAdapter and NetSecurity modules. netsh remains fully supported and is still the quickest way to do several tasks.