Windows networking and security commands
In short: A quick reference of the Windows commands network and security engineers use most, grouped by task. Commands only.
Commands only. Replace values in angle brackets such as <ip> with your own. Only run commands on systems you own or are authorised to manage.
IP configuration
| Command | Purpose |
|---|---|
ipconfig | Show IP address, mask and default gateway |
ipconfig /all | Full details: MAC, DHCP server, DNS servers, lease times |
ipconfig /release | Release the DHCP address |
ipconfig /renew | Request a new DHCP address |
ipconfig /flushdns | Clear the local DNS cache |
ipconfig /displaydns | Show the local DNS cache |
Get-NetIPConfiguration | PowerShell: IP, gateway and DNS per adapter |
Connectivity and path testing
| Command | Purpose |
|---|---|
ping <ip> | Test reachability with ICMP echo |
ping -t <ip> | Ping continuously until Ctrl+C |
ping -n 10 -l 1400 <ip> | Send 10 pings of 1400 bytes |
tracert <ip> | Show each router hop to a destination |
tracert -d <ip> | Trace without resolving names (faster) |
pathping <ip> | Trace plus loss statistics per hop |
Test-NetConnection <host> -Port 443 | PowerShell: test whether a TCP port is open |
DNS and name resolution
| Command | Purpose |
|---|---|
nslookup <name> | Resolve a name with the default DNS server |
nslookup <name> <dns-server> | Resolve using a specific DNS server |
nslookup -type=mx <domain> | Look up mail servers |
Resolve-DnsName <name> -Type A | PowerShell DNS lookup |
hostname | Show this computer’s name |
Connections, ARP and routing
| Command | Purpose |
|---|---|
netstat -ano | All connections and listening ports with process ID |
netstat -b | Show the program behind each connection (run as administrator) |
arp -a | Show the ARP cache (IP to MAC) |
arp -d * | Clear the ARP cache |
route print | Show the routing table |
route add <network> mask <mask> <gateway> | Add a temporary static route |
Get-NetTCPConnection -State Listen | PowerShell: listening TCP ports |
Firewall
| Command | Purpose |
|---|---|
netsh advfirewall show allprofiles | Show firewall state for domain, private and public profiles |
netsh advfirewall set allprofiles state on | Turn the firewall on for all profiles |
netsh advfirewall firewall add rule name="Allow SSH" dir=in action=allow protocol=TCP localport=22 | Allow inbound TCP 22 |
netsh advfirewall firewall delete rule name="Allow SSH" | Remove a rule by name |
Get-NetFirewallProfile | PowerShell: firewall profile settings |
New-NetFirewallRule -DisplayName "Block Telnet" -Direction Inbound -Protocol TCP -LocalPort 23 -Action Block | PowerShell: block inbound Telnet |
Users, policy and system checks
| Command | Purpose |
|---|---|
whoami /all | Current user, groups and privileges |
net user | List local user accounts |
net localgroup administrators | List local administrators |
gpupdate /force | Re-apply Group Policy now |
gpresult /r | Show which Group Policies applied |
systeminfo | OS version, patches (hotfixes) and hardware summary |
sfc /scannow | Check and repair system files |
Real-world example: a hospital PC that could not open the records system
A ward PC in a hospital could not open the patient records web application, although email worked. The desktop support engineer worked outwards with the commands on this page. ipconfig /all showed a correct address, gateway and DNS servers. Pinging the gateway and the records server's IP address both succeeded, so the network path was fine. nslookup for the application's name, however, returned an old address.
The PC had a stale entry in its hosts file, added years earlier during a server migration. The engineer removed the entry, ran ipconfig /flushdns, and the application loaded at once. Following the same order every time, from the PC outwards, avoided a pointless escalation to the network team.
Key takeaways
- ipconfig, ping, tracert and nslookup cover most first-line troubleshooting.
- netstat -ano links open ports to process IDs.
- netsh advfirewall and the NetSecurity PowerShell cmdlets manage the firewall.
- whoami /all and net localgroup administrators show who has privileges.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.