Network Troubleshooting

Essential commands for diagnosing and resolving network connectivity issues including interface status, DNS, and routing

Interface Status

ip link show

  • Shows all network interfaces
  • Up/down status and MAC addresses

ip addr show [interface]

  • Display IP addresses per interface
  • Shows subnet masks and scope

ifconfig [interface]

  • Legacy interface configuration tool
  • Shows stats: RX/TX packets, errors

Connectivity Testing

ping -c 4 [host]

  • Send 4 ICMP packets to target
  • Tests basic connectivity

traceroute [destination]

  • Shows path packets take to dest
  • Identifies routing issues

mtr [host]

  • Combines ping and traceroute
  • Real-time network diagnostics

DNS Resolution

nslookup [domain]

  • Query DNS for domain records
  • Shows configured DNS servers

dig [domain]

  • Advanced DNS lookup tool
  • More detailed output than nslookup

systemd-resolve --status

  • Shows DNS resolver configuration
  • Current DNS servers in use

Network Services

ss -tulpn

  • Show listening ports and services
  • TCP/UDP with process names

netstat -rn

  • Display routing table
  • Shows gateway and routes

systemctl status networking

  • Check network service status
  • Shows if networking is active

Configuration Files

cat /etc/network/interfaces

  • Static network configuration
  • Interface definitions

cat /etc/resolv.conf

  • DNS resolver configuration
  • Current nameservers

Example Troubleshooting

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Check interface status
ip addr show

# Test connectivity
ping -c 4 8.8.8.8

# Check DNS
dig google.com

# Restart networking
sudo systemctl restart networking