Network Troubleshooting Commands

When troubleshooting a network, there are several command-line tools available for diagnosing and resolving issues. Here’s a comprehensive list of network troubleshooting commands commonly used in both Windows and Linux/Unix environments. These commands help you identify problems with connectivity, latency, DNS, routing, and more.

1. Basic Connectivity and Latency Tests

Ping

  • Windows/Linux/Unix: ping [destination IP or domain]
    • Tests the reachability of a host and measures round-trip time.
    • Example:
      ping google.com
      ping 192.168.1.1
 

Traceroute / Tracert

  • Windows: tracert [destination IP or domain]
  • Linux/Unix: traceroute [destination IP or domain]
    • Traces the path packets take to reach the destination and identifies where delays or failures occur.
    • Example:
      tracert google.com
      traceroute google.com
 

MTR (My Traceroute)

  • Linux/Unix: mtr [destination IP or domain]
    • Combines the functionality of ping and traceroute to provide a real-time report of network latency and packet loss across multiple hops.
    • Example:
      mtr google.com

2. DNS Troubleshooting

Nslookup

  • Windows/Linux/Unix: nslookup [domain name]
    • Queries DNS servers to resolve domain names into IP addresses and troubleshoot DNS issues.
    • Example:
      nslookup google.com
      nslookup 8.8.8.8

Dig (Domain Information Groper)

  • Linux/Unix: dig [domain name]
    • A more powerful DNS lookup tool with extended capabilities compared to nslookup.
    • Example:
      dig google.com
      dig @8.8.8.8 google.com
 

Host

  • Linux/Unix: host [domain name]
    • Performs DNS lookups and provides a straightforward way to query DNS records.
    • Example:
      host google.com
      host 8.8.8.8

3. Routing and IP Configuration

IPConfig (Windows)

  • Windows: ipconfig [options]
    • Displays network adapter configurations, including IP addresses, subnet mask, and gateway.
    • Example:
      ipconfig
      ipconfig /all
      ipconfig /release
      ipconfig /renew
 

Ifconfig (Linux/Unix)

  • Linux/Unix: ifconfig
    • Displays or configures network interfaces and their IP addresses.
    • Example:
      ifconfig
      ifconfig eth0
 

IP (Linux/Unix)

  • Linux/Unix: ip [options]
    • Replaces ifconfig in many modern Linux distributions. It can be used to configure network interfaces, routing, and IP addresses.
    • Example:
      ip a
      ip link show
      ip route show
 

Route (Windows/Linux/Unix)

  • Windows: route print
  • Linux/Unix: route -n
    • Displays the routing table, which shows how traffic is routed to different networks.
    • Example:
      route print
      route -n

4. Network Interface and Packet Capture

Netstat

  • Windows/Linux/Unix: netstat [options]
    • Displays active network connections, routing tables, interface statistics, and more.
    • Example:
      netstat -a
      netstat -tuln
      netstat -r
 

Tcpdump

  • Linux/Unix: tcpdump [options]
    • Captures packets on a network interface and allows analysis of traffic.
    • Example:
      tcpdump -i eth0
      tcpdump -i eth0 port 80
      tcpdump -i eth0 -w capture.pcap
 

Wireshark (GUI tool)

  • Linux/Unix/Windows: Wireshark is the GUI version of tcpdump, but you can run it from the command line with tshark.
    • Example:
      tshark -i eth0
      tshark -r capture.pcap

5. Testing Network Performance

Iperf

  • Windows/Linux/Unix: iperf3
    • Measures the bandwidth between two hosts. You need to run the iperf server on one host and the client on the other.
    • Example:
      iperf3 -s # On server
      iperf3 -c [server IP] # On client
 

Speedtest-cli

  • Linux/Unix: speedtest-cli
    • A command-line tool for testing internet speed using Speedtest.net servers.
    • Example:
      speedtest-cli
 

6. TCP/IP Stack and Firewall Troubleshooting

Telnet

  • Windows/Linux/Unix: telnet [hostname or IP] [port]
    • Tests if a specific port on a host is open and accessible.
    • Example:
      telnet google.com 80
      telnet 192.168.1.1 22
 

SSH

  • Linux/Unix/Windows: ssh [user]@[hostname or IP]
    • Securely connects to a remote system for troubleshooting and administration.
    • Example:
      ssh user@192.168.1.1
 

Curl

  • Linux/Unix/Windows: curl [options] [URL]
    • Makes HTTP requests and can be used to check web server status or retrieve data from URLs.
    • Example:
      curl google.com
      curl -I google.com
 

Firewall (Windows/Linux/Unix)

  • Windows: netsh advfirewall firewall show rule name=all
  • Linux/Unix: iptables -L
    • Checks firewall rules that could block network traffic.
    • Example:
      iptables -L

7. Checking for Packet Loss or Errors

Ping with Packet Size

  • Windows/Linux/Unix: ping -l [size] [destination] (Windows) or ping -s [size] [destination] (Linux)
    • Helps check if the network is dropping packets or having issues with larger payloads.
    • Example:
      ping -l 1500 google.com # Windows
      ping -s 1500 google.com # Linux
 

Pathping (Windows)

  • Windows: pathping [destination IP or domain]
    • Combines ping and traceroute, providing both route and packet loss information.
    • Example:
      bash
      pathping google.com
 

Netcat (nc)

  • Linux/Unix/Windows: nc [options]
    • A versatile network utility for debugging and investigating the network, including port scanning and banner grabbing.
    • Example:
      bash
      nc -zv google.com 80
      nc -l 12345
 

8. Checking ARP Table

ARP (Address Resolution Protocol)

  • Windows: arp -a
  • Linux/Unix: arp -n
    • Displays or modifies the ARP (Address Resolution Protocol) table, showing IP-to-MAC address mappings.
    • Example:
      arp -a
      arp -n

Summary of Common Network Troubleshooting Commands:

CommandPurposeExample Usage
pingCheck connectivityping google.com
tracertTrace route to a destinationtracert google.com
nslookupDNS resolutionnslookup google.com
ifconfigView network interface configurationifconfig (Linux/Unix)
ipconfigView network interface configurationipconfig (Windows)
netstatNetwork statistics and active connectionsnetstat -a
mtrCombine ping and traceroutemtr google.com
tcpdumpCapture network packetstcpdump -i eth0
iperfMeasure bandwidthiperf3 -c serverIP
curlMake HTTP requests and check URLscurl -I google.com
telnetTest port connectivitytelnet google.com 80
netcat (nc)Network testing tool`nc –