Networking is at the heart of server administration. Whether you are diagnosing a connectivity issue, checking which ports are listening, or tracing the path packets take to a destination, Linux has a precise tool for every task. This guide covers the essential networking commands with real-world usage scenarios.
ip — The Modern Network Interface Tool
The ip command (from the iproute2 package) is the modern replacement for the older ifconfig. It handles interfaces, addresses, routes, and more.
ip addr show # Show all interfaces and IP addresses
ip addr show eth0 # Show specific interface
ip link show # Show interface state (up/down)
ip link set eth0 up # Bring interface up
ip link set eth0 down # Bring interface down
ip route show # Routing table
ip route add default via 192.168.1.1 # Add default gateway
ip route add 10.0.0.0/8 via 192.168.1.254 # Static route
ifconfig — The Classic Tool (Still Useful)
ifconfig # Show all active interfaces
ifconfig eth0 # Show specific interface
ifconfig eth0 192.168.1.100 # Assign IP (temporary)
ifconfig eth0 up # Bring interface up
Install if missing: sudo apt install net-tools or sudo dnf install net-tools.
ping — Test Connectivity
ping 8.8.8.8 # Ping Google DNS (Ctrl+C to stop)
ping -c 4 8.8.8.8 # Send 4 packets then stop
ping -i 0.5 8.8.8.8 # Send every 0.5 seconds
ping -s 1400 8.8.8.8 # Test with larger packet size (MTU testing)
ping6 2001:4860:4860::8888 # IPv6 ping
If ping fails: check DNS (ping 8.8.8.8 vs ping google.com), check the route, and check firewall rules.
traceroute — Trace the Network Path
traceroute 8.8.8.8 # Trace route to Google DNS
traceroute -n 8.8.8.8 # Skip DNS resolution (faster)
tracepath 8.8.8.8 # Similar, no root required
mtr 8.8.8.8 # Live traceroute (install mtr)
Each line shows a hop (router). *** means the router does not respond to probes — not necessarily a problem.
ss — Socket Statistics (Replaces netstat)
ss -tulnp # TCP+UDP listening sockets with process info
ss -tnp # TCP connections with process info
ss -s # Summary statistics
ss -anp | grep :80 # Connections on port 80
ss -o state established # Only established connections
Column guide: -t=TCP, -u=UDP, -l=listening, -n=no DNS resolution, -p=show process.
netstat — Classic Socket Info
netstat -tulnp # Listening sockets with processes
netstat -an | grep :443 # Connections on port 443
netstat -rn # Routing table
netstat -i # Interface statistics
Install: sudo apt install net-tools. On modern systems, prefer ss — it is faster and more accurate.
DNS Tools
dig google.com # DNS lookup (full detail)
dig google.com A # Only A records
dig google.com MX # MX records
dig @8.8.8.8 google.com # Query specific DNS server
dig -x 8.8.8.8 # Reverse DNS lookup
nslookup google.com # Simple DNS lookup
host google.com # Quick lookup
cat /etc/resolv.conf # Configured DNS servers
curl and wget — HTTP from the Command Line
curl https://example.com # Fetch page body
curl -I https://example.com # Headers only
curl -o /tmp/file.zip https://example.com/file.zip # Download
curl -u user:pass https://api.example.com # Basic auth
curl -X POST -d "key=value" https://api.example.com/endpoint
curl -v https://example.com # Verbose (debug)
wget https://example.com/file.tar.gz # Download file
wget -q -O /dev/null https://example.com # Quiet, discard output
Network Configuration Files
# Ubuntu/Debian (Netplan)
cat /etc/netplan/00-installer-config.yaml
sudo netplan apply
# RHEL/Rocky (NetworkManager)
nmcli con show # List connections
nmcli con show eth0 # Details
nmcli con mod eth0 ipv4.addresses 192.168.1.100/24
nmcli con up eth0
# Static files (older RHEL)
cat /etc/sysconfig/network-scripts/ifcfg-eth0
Firewall Quick Check
sudo ufw status verbose # Ubuntu firewall status
sudo firewall-cmd --list-all # RHEL/Rocky firewall status
sudo iptables -L -n -v # Raw iptables rules
Summary
Linux networking commands let you inspect, diagnose, and configure the network stack from the command line. Use ip for interface management, ss for socket inspection, ping and traceroute for connectivity testing, and dig for DNS. These tools together cover the majority of network troubleshooting scenarios you will encounter on Linux servers.