Linux Networking Commands for Ops and SRE
ip - Interface and Route Management
ip addr show # all interfaces
ip -brief addr # compact view
ip addr add 192.168.1.10/24 dev eth0
ip link set eth0 up
ip route show
ip route add default via 192.168.1.1
ip neigh show # ARP table
---
ss - Socket Statistics
Replaces netstat. Much faster on busy systems.
ss -tlnp # TCP listening, numeric, with process
ss -ulnp # UDP listening
ss -s # summary counts
ss -t state established # active connections
ss dst 10.0.0.50 # connections to a host
ss -tlnp sport = :80 # filter by port
---
curl - HTTP Testing
curl -I https://example.com # headers only
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' https://api.example.com
# Timing breakdown
curl -o /dev/null -s -w "DNS:%{time_namelookup} Connect:%{time_connect} TTFB:%{time_starttransfer} Total:%{time_total}
" https://example.com
curl -L -s -o /dev/null -w "%{url_effective}
" https://example.com # follow redirects
---
dig - DNS Queries
dig shellgenius.com # A record
dig shellgenius.com MX # mail records
dig shellgenius.com TXT # SPF / DKIM
dig @8.8.8.8 shellgenius.com # query specific resolver
dig +short shellgenius.com # just the answer
dig +trace shellgenius.com # full resolution chain
dig -x 93.184.216.34 # reverse DNS
---
netcat - Raw TCP/UDP
nc -zv 10.0.0.50 5432 # test port connectivity
nc -zv -w 3 10.0.0.50 5432 # with timeout
nc -l 9999 # listen (server side)
nc 10.0.0.50 9999 # connect (client side)
---
tcpdump - Packet Capture
tcpdump -i eth0 port 80 # capture HTTP
tcpdump -i eth0 -w /tmp/capture.pcap # save for Wireshark
tcpdump -i eth0 host 10.0.0.50 # filter by host
tcpdump -i eth0 -A port 80 | grep "GET|POST" # show HTTP requests
---
Diagnosing Connectivity Systematically
ip link show eth0 # interface up?
ip addr show eth0 # has IP?
ping -c 3 $(ip route | awk '/default/ {print $3}') # gateway reachable?
dig +short google.com @8.8.8.8 # DNS resolving?
nc -zv targethost 443 # port open?
iptables -L -n | grep DROP # firewall blocking?
Practice in the ShellGenius Linux Labs — the network-diagnostics challenge covers real troubleshooting scenarios.