HxHippy

Network Debugging

Diagnose connectivity, DNS, and firewall issues.

Last updated: 2025-01-15

Network Debugging

Diagnose and fix network connectivity issues.

Quick Diagnostics

# Basic connectivity
ping -c 4 8.8.8.8
ping -c 4 google.com

# DNS resolution
nslookup google.com
dig google.com

# Network interfaces
ip addr
ip route

Connectivity Issues

Check Network Interface

# Interface status
ip link show
ip addr show eth0

# Bring interface up
sudo ip link set eth0 up

# Check for IP
ip addr show eth0 | grep inet

Check Gateway

# View routing table
ip route
route -n

# Test gateway
ping -c 4 $(ip route | grep default | awk '{print $3}')

# Traceroute
traceroute google.com
mtr google.com

Check Firewall

# UFW status
sudo ufw status verbose

# iptables rules
sudo iptables -L -n -v
sudo iptables -t nat -L -n

# Temporarily disable firewall (testing only!)
sudo ufw disable

DNS Issues

Test Resolution

# Using specific DNS server
nslookup google.com 8.8.8.8
dig @8.8.8.8 google.com

# Check /etc/resolv.conf
cat /etc/resolv.conf

# Test local resolution
getent hosts hostname

Fix DNS

# Temporary fix
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

# Permanent fix (systemd-resolved)
sudo nano /etc/systemd/resolved.conf
# Add: DNS=8.8.8.8 8.8.4.4

sudo systemctl restart systemd-resolved

Port Connectivity

Check Listening Ports

# All listening ports
ss -tuln
netstat -tuln

# Specific port
ss -tuln | grep :80

# What's using a port
sudo lsof -i :80
sudo fuser 80/tcp

Test Remote Ports

# TCP port test
nc -zv host 80
telnet host 80

# Multiple ports
nmap -p 80,443,22 host

# Check if port is blocked
sudo tcpdump -i eth0 port 80

Connection Issues

Check Established Connections

# All connections
ss -tn

# By state
ss -tn state established
ss -tn state time-wait

# Connection count
ss -s

Debug Application Connections

# HTTP test
curl -v http://example.com
curl -I http://example.com

# With timing
curl -w "@curl-format.txt" -o /dev/null -s http://example.com

# SSL/TLS test
openssl s_client -connect host:443

Common Issues & Fixes

Issue Diagnostic Fix
No IP ip addr sudo dhclient eth0
DNS fail nslookup Check /etc/resolv.conf
Port blocked nc -zv Check firewall rules
High latency mtr host Check for packet loss
Connection refused ss -tuln Start the service

Packet Capture

# Capture all traffic
sudo tcpdump -i eth0

# Specific host
sudo tcpdump -i eth0 host 192.168.1.1

# Specific port
sudo tcpdump -i eth0 port 80

# Save to file
sudo tcpdump -i eth0 -w capture.pcap
intermediate Troubleshooting Updated 2025-01-15
  • network
  • troubleshooting
  • dns
  • connectivity
  • firewall