Windows provides a comprehensive set of command-line tools for network troubleshooting, configuration, and administration. Whether you're diagnosing connectivity issues, managing network settings, or monitoring network traffic, mastering these commands is essential for IT professionals and system administrators.
This guide covers both classic Command Prompt (CMD) commands and modern PowerShell cmdlets for network management, troubleshooting, and diagnostics.
ipconfig is the most frequently used Windows networking command. It displays IP configuration details for all network adapters.
ipconfig
Displays basic IP configuration for all adapters
ipconfig /all
Shows detailed configuration including MAC address, DHCP server, DNS servers, and lease information
ipconfig /release
Releases the current DHCP IP address
ipconfig /renew
Requests a new IP address from DHCP server
ipconfig /displaydns
Displays the DNS resolver cache contents
ipconfig /flushdns
Clears the DNS resolver cache (useful for resolving DNS issues)
ipconfig /registerdns
Refreshes DHCP leases and re-registers DNS names
ipconfig /release "Ethernet" ipconfig /renew "Ethernet"
Performs operations on a specific network adapter
ping tests connectivity to a remote host by sending ICMP echo requests.
ping google.com
Sends 4 ICMP echo requests (default)
ping 8.8.8.8
Ping using IP address instead of hostname
ping -t google.com
Continuous ping until manually stopped (Ctrl+C)
ping -n 10 google.com
Send specific number of echo requests (10 in this example)
ping -l 1000 google.com
Set packet size in bytes (default is 32 bytes)
ping -a 192.168.1.1
Resolve IP address to hostname
ping -i 128 google.com
Set TTL (Time To Live) value
ping -w 5000 google.com
Set timeout in milliseconds (5000ms = 5 seconds)
ping -4 google.com
Force IPv4
ping -6 google.com
Force IPv6
tracert (traceroute) shows the path packets take to reach a destination.
tracert google.com
Traces route to destination showing all hops
tracert -d google.com
Don't resolve IP addresses to hostnames (faster)
tracert -h 20 google.com
Set maximum number of hops (default is 30)
tracert -w 1000 google.com
Set timeout for each reply in milliseconds
pathping combines functionality of ping and tracert, providing detailed statistics.
pathping google.com
Traces route and provides packet loss statistics for each hop
pathping -n google.com
Don't resolve hostnames (faster execution)
pathping -h 15 google.com
Set maximum hops
pathping -q 10 google.com
Set number of queries per hop
nslookup queries DNS servers to resolve hostnames or IP addresses.
nslookup google.com
Query default DNS server for hostname
nslookup 8.8.8.8
Reverse DNS lookup (IP to hostname)
nslookup google.com 8.8.8.8
Query Google's DNS server instead of default
nslookup > set type=MX > google.com > exit
Interactive mode for multiple queries
nslookup -type=MX google.com
Query MX (Mail Exchange) records
nslookup -type=A google.com
Query A (Address) records
nslookup -type=NS google.com
Query NS (Name Server) records
nslookup -type=TXT google.com
Query TXT records
nslookup -type=SOA google.com
Query SOA (Start of Authority) records
netstat displays active network connections, listening ports, and network statistics.
netstat
Shows all active TCP connections
netstat -a
Shows all connections and listening ports
netstat -an
Shows all connections in numerical format (no name resolution)
netstat -s
Displays statistics by protocol (TCP, UDP, ICMP, IP)
netstat -p tcp
Shows only TCP connections
netstat -p udp
Shows only UDP connections
netstat -ano
Shows connections with Process ID (PID)
netstat -ab
Shows executable involved in each connection (requires admin privileges)
netstat -r
Displays routing table
netstat -an 5
Refresh display every 5 seconds
netstat -ano | findstr :80
Find process using port 80
netstat -ano | findstr :3389
Check if RDP (Remote Desktop) is listening
arp displays and modifies the ARP cache (IP-to-MAC address mapping).
arp -a
Displays the ARP cache for all interfaces
arp -a 192.168.1.1
Display ARP entry for specific IP
arp -d
Delete all ARP cache entries
arp -d 192.168.1.100
Delete specific ARP entry
arp -s 192.168.1.100 00-AA-BB-CC-DD-EE
Add static ARP entry
route displays and modifies the network routing table.
route print
Displays the complete routing table
route add 192.168.2.0 mask 255.255.255.0 192.168.1.1
Adds route to 192.168.2.0/24 network via gateway 192.168.1.1
route add 0.0.0.0 mask 0.0.0.0 192.168.1.1
Add default gateway
route add 192.168.2.0 mask 255.255.255.0 192.168.1.1 -p
-p flag makes the route persistent (survives reboot)
route delete 192.168.2.0
Removes specified route
route change 192.168.2.0 mask 255.255.255.0 192.168.1.254
Modifies existing route
netsh is a powerful command-line scripting utility for network configuration.
netsh interface show interface
Shows all network interfaces and their status
netsh interface ip show config
Displays IP configuration for all interfaces
netsh interface ip set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1
netsh interface ip set dns "Ethernet" static 8.8.8.8 netsh interface ip add dns "Ethernet" 8.8.4.4 index=2
netsh interface ip set address "Ethernet" dhcp netsh interface ip set dns "Ethernet" dhcp
netsh advfirewall show allprofiles
Shows firewall status for all profiles
netsh advfirewall set allprofiles state on
Enable firewall for all profiles
netsh advfirewall set allprofiles state off
Disable firewall for all profiles
netsh advfirewall firewall show rule name=all
Display all firewall rules
netsh advfirewall firewall add rule name="Allow Port 80" dir=in action=allow protocol=TCP localport=80
Add inbound rule to allow port 80
netsh advfirewall firewall delete rule name="Allow Port 80"
Delete specific firewall rule
netsh wlan show interfaces
Shows wireless interface information
netsh wlan show profiles
Lists all saved Wi-Fi profiles
netsh wlan show profile name="WiFi-Name" key=clear
Shows Wi-Fi password for specific profile
netsh wlan delete profile name="WiFi-Name"
Delete Wi-Fi profile
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=80 connectaddress=192.168.1.100
Forward port 8080 to port 80 on 192.168.1.100
netsh interface portproxy show all
Display all port forwarding rules
netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0
Remove port forwarding rule
hostname
Shows the computer's hostname
getmac
Shows MAC addresses of all network adapters
getmac /v
Verbose output with adapter names
getmac /v /fo table
Format output as table
Modern Windows versions include powerful PowerShell cmdlets for network management.
Get-NetAdapter
Lists all network adapters
Get-NetAdapter | Select Name, Status, LinkSpeed, MacAddress
Custom formatted output
Get-NetIPAddress
Shows IP addresses for all interfaces
Get-NetIPConfiguration
Detailed IP configuration (similar to ipconfig /all)
Get-NetIPConfiguration -Detailed
Even more detailed configuration
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("8.8.8.8","8.8.4.4")
Disable-NetAdapter -Name "Ethernet" Enable-NetAdapter -Name "Ethernet"
Get-DnsClientCache
Display DNS cache
Clear-DnsClientCache
Flush DNS cache
Test-Connection google.com
PowerShell equivalent of ping
Test-Connection -ComputerName google.com -Count 5
Send 5 pings
Test-NetConnection google.com
Advanced connectivity test
Test-NetConnection google.com -Port 443
Test specific port connectivity
Get-NetRoute
Display routing table
New-NetRoute -DestinationPrefix "192.168.2.0/24" -NextHop "192.168.1.1" -InterfaceAlias "Ethernet"
Add new route
Get-NetFirewallRule
List all firewall rules
New-NetFirewallRule -DisplayName "Allow Port 80" -Direction Inbound -LocalPort 80 -Protocol TCP -Action Allow
Create new firewall rule
Remove-NetFirewallRule -DisplayName "Allow Port 80"
Remove firewall rule
ipconfig /all
Check IP address, subnet mask, default gateway, DNS servers
ping 127.0.0.1
Test loopback interface (TCP/IP stack)
ping 192.168.1.1
Replace with your actual gateway IP
ping 8.8.8.8
Test connectivity to Google DNS (public IP)
ping google.com
If this fails but IP ping works, DNS issue exists
nslookup google.com
Verify DNS resolution
tracert google.com
Identify where connection fails
netsh advfirewall show allprofiles
netstat -ano
ipconfig /flushdns ipconfig /release ipconfig /renew
# Check physical connection Get-NetAdapter | Select Name, Status # Release and renew IP ipconfig /release ipconfig /renew # Flush DNS ipconfig /flushdns # Reset TCP/IP stack netsh int ip reset netsh winsock reset
Note: Restart computer after reset commands
# Flush DNS cache ipconfig /flushdns # Check DNS configuration ipconfig /all # Test with different DNS nslookup google.com 8.8.8.8 # Set Google DNS netsh interface ip set dns "Ethernet" static 8.8.8.8
# Check network adapter speed Get-NetAdapter | Select Name, LinkSpeed # Check for packet loss ping -t google.com # Detailed path analysis pathping google.com # Check active connections netstat -an
# Test connectivity ping website.com # Check DNS resolution nslookup website.com # Test specific port Test-NetConnection website.com -Port 443 # Flush DNS ipconfig /flushdns
# Release current IP ipconfig /release # Check ARP cache arp -a # Renew IP ipconfig /renew
netsh winsock reset netsh int ip reset
Requires restart. Resets network stack to default
netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
net share
net use Z: \\server\share /persistent:yes
net use Z: /delete
net session
netstat -e
Ethernet statistics
# Basic Diagnostics ipconfig /all # Detailed IP configuration ping google.com # Test connectivity tracert google.com # Trace route nslookup google.com # DNS lookup # Network Status netstat -an # Active connections arp -a # ARP cache route print # Routing table hostname # Computer name getmac # MAC addresses # Troubleshooting ipconfig /flushdns # Clear DNS cache ipconfig /release # Release IP ipconfig /renew # Renew IP netsh int ip reset # Reset TCP/IP netsh winsock reset # Reset Winsock # PowerShell Get-NetAdapter # Network adapters Get-NetIPConfiguration # IP configuration Test-NetConnection # Test connection Get-NetRoute # Routing table Clear-DnsClientCache # Flush DNS # Firewall netsh advfirewall show allprofiles Get-NetFirewallRule
Mastering Windows networking commands is essential for effective network troubleshooting and administration. The combination of classic CMD commands and modern PowerShell cmdlets provides comprehensive tools for diagnosing connectivity issues, managing network configuration, and monitoring network activity.
Whether you're troubleshooting a simple connectivity issue or performing advanced network configuration, these commands form the foundation of Windows network administration. Regular practice with these tools in various scenarios will build confidence and efficiency in resolving network problems quickly.