Understanding Linux Routing
The routing table determines how network packets travel from your server to their destination. Misconfigured routes cause connectivity failures, packet loss, and security vulnerabilities through unintended network paths.
Viewing the Routing Table
# Modern ip command
ip route show
ip -6 route show
# Legacy commands
route -n
netstat -rn
Default Gateway Verification
# Show default route
ip route show default
# Verify gateway reachability
ping -c 3 $(ip route show default | awk "/default/ {print \$3}")
# Check ARP entry for gateway
ip neigh show
Route Tracing and Debugging
# Trace route to destination
ip route get 8.8.8.8
traceroute -n 8.8.8.8
tracepath 8.8.8.8
# Check which interface handles traffic
ip route get 10.0.0.1
DNS Route Verification
Ensuring DNS servers are reachable through proper routes is essential for name resolution:
grep nameserver /etc/resolv.conf
ip route get $(grep nameserver /etc/resolv.conf | head -1 | awk "{print \$2}")
Interface-Specific Routes
# Show routes per interface
ip route show dev eth0
ip route show dev wlan0
# Add a static route
ip route add 192.168.2.0/24 via 192.168.1.1 dev eth0
Automated Analysis with dargslan-route-check
pip install dargslan-route-check
dargslan-route-check
dargslan-route-check --gateway
dargslan-route-check --trace 8.8.8.8