Windows Networking Commands – Complete Guide for Network Troubleshooting and Administration
Introduction
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 - IP Configuration and Network Interface Information
ipconfig is the most frequently used Windows networking command. It displays IP configuration details for all network adapters.
Basic ipconfig Commands
ipconfig
Displays basic IP configuration for all adapters
ipconfig /all
Shows detailed configuration including MAC address, DHCP server, DNS servers, and lease information
DHCP Operations
ipconfig /release
Releases the current DHCP IP address
ipconfig /renew
Requests a new IP address from DHCP server
DNS Cache Management
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
Specific Adapter Operations
ipconfig /release "Ethernet" ipconfig /renew "Ethernet"
Performs operations on a specific network adapter
ping - Test Network Connectivity
ping tests connectivity to a remote host by sending ICMP echo requests.
Basic ping Commands
ping google.com
Sends 4 ICMP echo requests (default)
ping 8.8.8.8
Ping using IP address instead of hostname
Advanced ping Options
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 - Trace Route to Destination
tracert (traceroute) shows the path packets take to reach a destination.
Basic tracert Commands
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 - Combined Ping and Tracert
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 - DNS Query Tool
nslookup queries DNS servers to resolve hostnames or IP addresses.
Basic nslookup Commands
nslookup google.com
Query default DNS server for hostname
nslookup 8.8.8.8
Reverse DNS lookup (IP to hostname)
Query Specific DNS Server
nslookup google.com 8.8.8.8
Query Google's DNS server instead of default
Interactive Mode
nslookup > set type=MX > google.com > exit
Interactive mode for multiple queries
Query Specific Record Types
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 - Network Statistics and Connections
netstat displays active network connections, listening ports, and network statistics.
Display Active Connections
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)
Protocol-Specific Statistics
netstat -s
Displays statistics by protocol (TCP, UDP, ICMP, IP)
netstat -p tcp
Shows only TCP connections
netstat -p udp
Shows only UDP connections
Display Process Information
netstat -ano
Shows connections with Process ID (PID)
netstat -ab
Shows executable involved in each connection (requires admin privileges)
Routing Table
netstat -r
Displays routing table
Continuous Monitoring
netstat -an 5
Refresh display every 5 seconds
Find Specific Port Usage
netstat -ano | findstr :80
Find process using port 80
netstat -ano | findstr :3389
Check if RDP (Remote Desktop) is listening
arp - Address Resolution Protocol
arp displays and modifies the ARP cache (IP-to-MAC address mapping).
Basic arp Commands
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 - Routing Table Management
route displays and modifies the network routing table.
Display Routing Table
route print
Displays the complete routing table
Add Static Route
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
Add Persistent Route
route add 192.168.2.0 mask 255.255.255.0 192.168.1.1 -p
-p flag makes the route persistent (survives reboot)
Delete Route
route delete 192.168.2.0
Removes specified route
Change Existing Route
route change 192.168.2.0 mask 255.255.255.0 192.168.1.254
Modifies existing route
netsh - Network Shell (Advanced Configuration)
netsh is a powerful command-line scripting utility for network configuration.
Interface Configuration
netsh interface show interface
Shows all network interfaces and their status
netsh interface ip show config
Displays IP configuration for all interfaces
Set Static IP Address
netsh interface ip set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1
Set DNS Servers
netsh interface ip set dns "Ethernet" static 8.8.8.8 netsh interface ip add dns "Ethernet" 8.8.4.4 index=2
Enable DHCP
netsh interface ip set address "Ethernet" dhcp netsh interface ip set dns "Ethernet" dhcp
Firewall Configuration
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
Firewall Rules
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
WLAN Configuration
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
Port Forwarding
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 and getmac - System Identification
Display Computer Name
hostname
Shows the computer's hostname
Display MAC Addresses
getmac
Shows MAC addresses of all network adapters
getmac /v
Verbose output with adapter names
getmac /v /fo table
Format output as table
PowerShell Network Commands
Modern Windows versions include powerful PowerShell cmdlets for network management.
Get Network Adapter Information
Get-NetAdapter
Lists all network adapters
Get-NetAdapter | Select Name, Status, LinkSpeed, MacAddress
Custom formatted output
IP Configuration
Get-NetIPAddress
Shows IP addresses for all interfaces
Get-NetIPConfiguration
Detailed IP configuration (similar to ipconfig /all)
Get-NetIPConfiguration -Detailed
Even more detailed configuration
Set Static IP Address
New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set DNS Servers
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("8.8.8.8","8.8.4.4")
Enable/Disable Network Adapter
Disable-NetAdapter -Name "Ethernet" Enable-NetAdapter -Name "Ethernet"
DNS Cache Management
Get-DnsClientCache
Display DNS cache
Clear-DnsClientCache
Flush DNS cache
Test Network Connection
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
Routing Table
Get-NetRoute
Display routing table
New-NetRoute -DestinationPrefix "192.168.2.0/24" -NextHop "192.168.1.1" -InterfaceAlias "Ethernet"
Add new route
Firewall Rules
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
Network Troubleshooting Workflow
Step 1: Verify Local Configuration
ipconfig /all
Check IP address, subnet mask, default gateway, DNS servers
Step 2: Test Local Connectivity
ping 127.0.0.1
Test loopback interface (TCP/IP stack)
Step 3: Test Default Gateway
ping 192.168.1.1
Replace with your actual gateway IP
Step 4: Test External Connectivity
ping 8.8.8.8
Test connectivity to Google DNS (public IP)
Step 5: Test DNS Resolution
ping google.com
If this fails but IP ping works, DNS issue exists
nslookup google.com
Verify DNS resolution
Step 6: Trace Route
tracert google.com
Identify where connection fails
Step 7: Check Firewall
netsh advfirewall show allprofiles
Step 8: Check Active Connections
netstat -ano
Step 9: Flush and Renew
ipconfig /flushdns ipconfig /release ipconfig /renew
Common Network Issues and Solutions
Issue 1: No Internet Connection
# 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
Issue 2: DNS Not Resolving
# 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
Issue 3: Slow Network Performance
# 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
Issue 4: Cannot Access Specific Website
# Test connectivity ping website.com # Check DNS resolution nslookup website.com # Test specific port Test-NetConnection website.com -Port 443 # Flush DNS ipconfig /flushdns
Issue 5: IP Address Conflict
# Release current IP ipconfig /release # Check ARP cache arp -a # Renew IP ipconfig /renew
Advanced Diagnostic Commands
Network Adapter Reset
netsh winsock reset netsh int ip reset
Requires restart. Resets network stack to default
Enable/Disable Network Discovery
netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
View Network Shares
net share
Map Network Drive
net use Z: \\server\share /persistent:yes
Remove Network Drive
net use Z: /delete
View Network Sessions
net session
View Network Statistics by Protocol
netstat -e
Ethernet statistics
Quick Reference Command Summary
# 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
Best Practices
- Run Command Prompt or PowerShell as Administrator for full functionality
- Document network configuration before making changes
- Use continuous ping (-t) to monitor connectivity during troubleshooting
- Always test DNS resolution separately from connectivity
- Keep a record of default gateway and DNS server addresses
- Use PowerShell for modern Windows environments (more powerful and flexible)
- Create scripts for repetitive tasks to save time
- Test firewall rules after creation to ensure they work as expected
- Use pathping instead of tracert for detailed performance analysis
- Regular flush DNS cache on workstations to prevent stale entries
Conclusion
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.