Skip to content

Network_troubleshooting

Network troubleshooting is an essential skill for Linux system administrators and DevOps engineers. This chapter covers comprehensive diagnostic tools, systematic troubleshooting approaches, common network issues and their solutions, and practical workflows for diagnosing and fixing network problems in production environments.


┌─────────────────────────────────────────────────────────────────────────┐
│ NETWORK TROUBLESHOOTING TOOLS │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ Connectivity Tests: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ ping - ICMP echo test │ │
│ │ ping6 - IPv6 ping │ │
│ │ arping - ARP ping (layer 2) │ │
│ │ fping - Multiple hosts │ │
│ │ hping3 - Advanced packet crafting │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Path Analysis: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ traceroute - Trace route (UDP/ICMP) │ │
│ │ tracepath - Trace with MTU discovery │ │
│ │ mtr - Combined ping + traceroute │ │
│ │ tcptraceroute - TCP traceroute │ │
│ │ nmap - Port scanning + more │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ DNS Tools: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ dig - DNS lookup utility │ │
│ │ nslookup - Interactive DNS client │ │
│ │ host - Simple DNS queries │ │
│ │ resolvectl - systemd-resolved control │ │
│ │ dig +trace - Full DNS resolution chain │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Socket/Port Tools: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ ss - Socket statistics (modern) │ │
│ │ netstat - Network statistics (legacy) │ │
│ │ lsof - List open files (network) │ │
│ │ nc/netcat - Network swiss army knife │ │
│ │ socat - Socket relay │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Interface Tools: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ ip - Modern interface management │ │
│ │ ifconfig - Legacy interface config │ │
│ │ ethtool - Ethernet device parameters │ │
│ │ iwconfig - Wireless interface config │ │
│ │ iwlist - Wireless device scanning │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Terminal window
# ============================================================
# CONNECTIVITY TESTS
# ============================================================
# Basic ping
ping -c 4 google.com
# Continuous ping
ping -i 0.2 google.com
# Flood ping (requires root)
ping -f google.com
# Ping from specific interface
ping -I eth0 google.com
# Packet size
ping -s 1000 google.com
# IPv6
ping6 -I eth0 ipv6.google.com
# ============================================================
# PATH ANALYSIS
# ============================================================
# UDP traceroute (default)
traceroute google.com
# ICMP traceroute
traceroute -I google.com
# TCP SYN traceroute (for firewalls)
traceroute -T -p 80 google.com
# MTU path discovery
tracepath google.com
# Continuous traceroute
mtr google.com
# Report mode
mtr -r -c 5 google.com
# ============================================================
# DNS LOOKUPS
# ============================================================
# Basic lookup
dig google.com
dig google.com +short
# Query specific record types
dig google.com A
dig google.com AAAA
dig google.com MX
dig google.com TXT
dig google.com NS
dig google.com CNAME
# Reverse DNS lookup
dig -x 8.8.8.8
host 8.8.8.8
# Query specific DNS server
dig @8.8.8.8 google.com
# Trace DNS resolution
dig google.com +trace
# DNS zone transfer (if allowed)
dig axfr example.com @ns1.example.com
Terminal window
# ============================================================
# PORT SCANNING WITH NMAP
# ============================================================
# Basic port scan
nmap target.com
# Service version detection
nmap -sV target.com
# OS detection
nmap -O target.com
# Scan specific ports
nmap -p 80,443,8080 target.com
# All ports
nmap -p- target.com
# TCP SYN scan (requires root)
sudo nmap -sS target.com
# UDP scan
sudo nmap -sU target.com
# Quick scan
nmap -T4 -F target.com
# ============================================================
# PORT CONNECTIVITY TESTING
# ============================================================
# Test port connectivity
nc -zv target.com 80
nc -zv target.com 80-90
# Banner grabbing
nc -zv target.com 80
# Telnet (legacy but useful)
telnet target.com 80
# Bash /dev/tcp (no external tools)
timeout 2 bash -c 'cat < /dev/tcp/target.com/80'
# HTTP request with curl
curl -v http://target.com
curl -I http://target.com
# Check listening ports
ss -tunapl
netstat -tunapl
# Process using port
lsof -i :80
fuser 80/tcp

Terminal window
# ============================================================
# INTERFACE INFORMATION
# ============================================================
# Show all interfaces
ip addr show
ip link show
# Statistics
ip -s link
ip -s link show eth0
# Detailed ethtool info
sudo ethtool eth0
sudo ethtool -S eth0 # Statistics
sudo ethtool -k eth0 # Offload features
sudo ethtool -g eth0 # Ring parameters
sudo ethtool -i eth0 # Driver info
# Wireless
iwconfig
iwlist scan
# Bonding info
cat /proc/net/bonding/bond0

┌─────────────────────────────────────────────────────────────────────────┐
│ NETWORK TROUBLESHOOTING WORKFLOW │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Step 1: Identify the Problem │ │
│ │ - What doesn't work? (ping, DNS, port, etc.) │ │
│ │ - When did it start? │ │
│ │ - What changed? │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Step 2: Isolate the Layer │ │
│ │ Layer 1: Physical (cable, link light) │ │
│ │ Layer 2: MAC, ARP │ │
│ │ Layer 3: IP, Routing │ │
│ │ Layer 4: TCP/UDP, Ports │ │
│ │ Layer 7: Application │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Step 3: Verify Each Layer │ │
│ │ - L1: ip link, ethtool │ │
│ │ - L2: arp, bridge show │ │
│ │ - L3: ip addr, ip route │ │
│ │ - L4: ss, iptables │ │
│ │ - L7: curl, telnet │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Step 4: Fix and Test │ │
│ │ - Apply fix │ │
│ │ - Verify with same tests │ │
│ │ - Monitor for recurrence │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Terminal window
# ============================================================
# NO CONNECTIVITY TROUBLESHOOTING
# ============================================================
# Step 1: Check IP address
ip addr show
# Should have IP in correct subnet
# Step 2: Check default route
ip route
ip route get 8.8.8.8
# Step 3: Check DNS
cat /etc/resolv.conf
resolvectl status
# Step 4: Test basic connectivity
ping -c 3 8.8.8.8 # Gateway first
ping -c 3 google.com # DNS test
# Step 5: Check firewall
iptables -L -n -v
ss -tunapl | grep -i reject
# Step 6: Check DNS resolution
nslookup google.com
dig google.com
# Common fixes:
# Add IP: ip addr add 192.168.1.100/24 dev eth0
# Add route: ip route add default via 192.168.1.1
# Set DNS: echo "nameserver 8.8.8.8" > /etc/resolv.conf
Terminal window
# ============================================================
# DNS TROUBLESHOOTING
# ============================================================
# Check current DNS servers
cat /etc/resolv.conf
resolvectl status
# Test specific DNS server
dig @8.8.8.8 google.com
dig @1.1.1.1 google.com
# Test resolution chain
dig +trace google.com
# Flush DNS cache
# systemd-resolved
sudo resolvectl flush-caches
# nscd (Name Service Cache Daemon)
sudo systemctl restart nscd
# Check for DNSSEC issues
dig +cd google.com # Checking disabled
# Local DNS issues
# /etc/hosts override
cat /etc/hosts
# Troubleshooting steps:
# 1. ping <hostname> fails, ping <IP> works -> DNS issue
# 2. Check /etc/resolv.conf
# 3. Try different DNS server
# 4. Check firewall blocking DNS (port 53)
Terminal window
# ============================================================
# FIREWALL TROUBLESHOOTING
# ============================================================
# List all rules
iptables -L -n -v
ip6tables -L -n -v
# Check NAT rules
iptables -t nat -L -n -v
# Check for dropped packets
iptables -L -n -v | grep DROP
# Check recent dropped
iptables -L INPUT -n -v --line-numbers
# ss to find listening services
ss -tunapl
# Check if port is listening
ss -tlnp | grep :80
# Common issues:
# - OUTPUT chain blocking (allow established)
# - Docker manipulating iptables
# - Cloud security groups
# - ufw/ufw status

┌─────────────────────────────────────────────────────────────────────────┐
│ NETWORK TROUBLESHOOTING INTERVIEW QUESTIONS │
├─────────────────────────────────────────────────────────────────────────┤
Q1: How do you troubleshoot no network connectivity? │
A1: │
1. Check IP: ip addr show │
2. Check route: ip route, ip route get 8.8.8.8 │
3. Check DNS: cat /etc/resolv.conf │
4. Test ping: first gateway, then external IP, then hostname │
5. Check firewall: iptables -L │
6. Check interface: ip link, ethtool │
─────────────────────────────────────────────────────────────────────────┤
Q2: What is the difference between ping and traceroute? │
A2: │
- ping: Tests connectivity, measures RTT │
- traceroute: Shows path (each hop), identifies where packets fail │
- ping uses ICMP echo request │
- traceroute uses varying TTL to probe each hop │
- mtr combines both continuously │
─────────────────────────────────────────────────────────────────────────┤
Q3: How do you check if a specific port is open? │
A3: │
- nc -zv host port │
- telnet host port │
- ss -tlnp | grep port │
- nmap -p port host │
- lsof -i :port │
─────────────────────────────────────────────────────────────────────────┤
Q4: What is the difference between ss and netstat? │
A4: │
- ss: Modern tool, faster, more detailed │
- netstat: Legacy, slower │
- ss uses netlink, netstat reads /proc/net │
- ss -tunapl shows all socket info │
─────────────────────────────────────────────────────────────────────────┤
Q5: How do you troubleshoot DNS issues? │
A5: │
1. Check /etc/resolv.conf │
2. Test with specific DNS: dig @8.8.8.8 │
3. Check if ping to IP works │
4. Flush cache: resolvectl flush-caches │
5. Check /etc/hosts for overrides │
6. Use dig +trace to see full resolution │
─────────────────────────────────────────────────────────────────────────┤
Q6: How does traceroute work? │
A6: │
- Sends packets with incrementing TTL │
- TTL=1 reaches first hop (router), returns ICMP time exceeded │
- TTL=2 reaches second hop, etc. │
- When reaches destination, returns ICMP port unreachable │
- Shows IP and hostname of each hop │
- Can use UDP, ICMP, or TCP SYN │
─────────────────────────────────────────────────────────────────────────┤
Q7: What could cause intermittent network issues? │
A7: │
- Network congestion │
- Duplex mismatch (half/full) │
- Cable/connector issues │
- Driver bugs │
- Firewall (stateful) issues │
- DNS resolution problems │
- MTU/fragmentation issues │
- Hardware issues (NIC, switch, router) │
- Rate limiting │
─────────────────────────────────────────────────────────────────────────┤
Q8: How do you check if network interface is up? │
A8: │
- ip link show │
- ip addr show │
- cat /sys/class/net/eth0/operstate │
- ethtool eth0 │
- mii-tool eth0 (legacy) │
─────────────────────────────────────────────────────────────────────────┤
Q9: What is the difference between TCP and UDP traceroute? │
A9: │
- UDP: Default, uses high-numbered ports │
- ICMP (traceroute -I): Uses ICMP echo │
- TCP SYN (traceroute -T): Uses TCP SYN to port 80/443 │
- TCP often gets through firewalls better │
- Different tools: tcptraceroute for TCP │
─────────────────────────────────────────────────────────────────────────┤
Q10: How do you measure network bandwidth? │
A10: │
- iperf/iperf3: Point-to-point bandwidth test │
- speedtest-cli: Internet speed test │
- curl with timing: Measures download speed │
- iftop: Per-connection bandwidth │
- nethogs: Per-process bandwidth │
└─────────────────────────────────────────────────────────────────────────┘

Terminal window
# Connectivity
ping -c 4 host
traceroute host
mtr host
# DNS
dig host
nslookup host
host host
# Ports
nc -zv host port
ss -tlnp
# Interface
ip addr show
ip route show
ethtool eth0
# Troubleshooting flow
ping gateway ping 8.8.8.8 ping google.com check DNS

  • Tools: ping, traceroute, mtr, dig, nmap, ss, ethtool
  • Workflow: Identify → Isolate → Verify → Fix
  • Layers: Physical → Data Link → Network → Transport → Application
  • Common issues: IP, routing, DNS, firewall

Chapter 25: Advanced Networking


Last Updated: February 2026