Let's be honest when your production server goes down at 3 AM, you don't have time to Google "how to debug network issues." You need to know these commands like the back of your hand.
I've been there, frantically troubleshooting connectivity issues while stakeholders breathe down my neck. After years in the trenches, here are the 20 networking commands that have saved my bacon more times than I can count.
The Connection Checkers
1. ping Your First Line of Defense
ping google.com
ping -c 4 192.168.1.1The classic. If ping fails, you know the network path is broken. The -c flag limits the count so you're not sitting there watching packets forever. It's simple, but it tells you immediately if you can reach the destination.
2. traceroute Where Did My Packets Go?
traceroute google.comWhen ping fails, traceroute shows you exactly where along the path things went wrong. Each hop represents a router your packet traversed. If you see asterisks or timeouts at a specific hop, you've found your culprit.
3. mtr Traceroute's Cooler Cousin
mtr google.comThink of mtr as traceroute on steroids. It combines ping and traceroute, continuously updating with packet loss statistics. Perfect for spotting intermittent network issues that traditional tools might miss.
DNS Troubleshooting
4. dig The DNS Swiss Army Knife
dig example.com
dig @8.8.8.8 example.com
dig example.com +shortDig is your go-to for DNS troubleshooting. The @ syntax lets you query specific DNS servers, and +short gives you just the IP without the noise. When DNS is acting weird, dig tells you why.
5. nslookup The Old Reliable
nslookup example.comLess powerful than dig but simpler for quick lookups. Some old-school admins swear by it. I use dig, but nslookup gets the job done when you just need a quick DNS resolution check.
6. host Quick and Dirty DNS
host example.com
host -a example.comEven simpler than nslookup. The -a flag shows you all DNS record types. Great for scripting because the output is cleaner and easier to parse.
Network Configuration
7. ifconfig Know Your Network Interface
ifconfig
ifconfig eth0Shows your network interfaces, IP addresses, MAC addresses, and statistics. Yes, it's being replaced by ip, but it's still everywhere and the syntax is more intuitive for beginners.
8. ip The Modern Way
ip addr show
ip route show
ip link set eth0 upThe newer, more powerful replacement for ifconfig. If you're serious about Linux networking, learn this one. It handles addresses, routes, and links all in one command.
9. iwconfig For Wireless Networks
iwconfig wlan0Like ifconfig but specifically for wireless interfaces. Shows signal strength, frequency, encryption status , everything you need when Wi-Fi is being flaky.
Port and Connection Management
10. netstat What's Actually Connected?
netstat -tulpn
netstat -an | grep ESTABLISHEDShows all active connections, listening ports, and routing tables. The -tulpn flags show TCP/UDP listening ports with program names. Essential for security audits and debugging what's actually running.
11. ss Netstat's Faster Replacement
ss -tulpn
ss -sDoes everything netstat does but faster. Modern systems are moving toward ss because it leverages kernel data structures more efficiently. Same flags, better performance.
12. nmap The Network Scanner
nmap 192.168.1.0/24
nmap -sV localhostThe legendary port scanner. Discovers hosts, scans open ports, detects services and versions. Every pentester's favorite tool, but also invaluable for legitimate network mapping and security auditing.
13. lsof What Files Are Open?
lsof -i :80
lsof -i TCPLists open files, including network connections. The -i flag filters for internet connections. Perfect for finding which process is hogging port 80 when you're trying to start your web server.
Traffic Analysis
14. tcpdump Capture Everything
tcpdump -i eth0
tcpdump -i any port 80 -w capture.pcapThe ultimate packet sniffer. Captures raw network traffic for deep analysis. The -w flag writes to a file that you can open in Wireshark later. When weird stuff happens, tcpdump shows you exactly what's going over the wire.
15. iftop Real-Time Bandwidth Monitor
iftop -i eth0Shows bandwidth usage by connection in real-time. It's like top but for network traffic. When something is maxing out your bandwidth, iftop tells you what.
16. wget Download and Test
wget http://example.com/file.zip
wget --spider http://example.comEveryone knows wget downloads files, but it's also perfect for testing HTTP connectivity and troubleshooting web servers. The --spider flag checks if a URL exists without downloading.
17. curl The HTTP Testing Powerhouse
curl -I http://example.com
curl -X POST -d "key=value" http://api.example.comMore versatile than wget. Tests APIs, checks headers, supports every HTTP method imaginable. If you work with web services, curl is indispensable.
Advanced Tools
18. arp Who's on My Local Network?
arp -a
arp -d 192.168.1.100Shows the ARP table mapping IP addresses to MAC addresses. Useful for detecting ARP spoofing attacks or finding devices on your local network.
19. route Where Do Packets Go?
route -n
route add default gw 192.168.1.1Displays and manipulates the routing table. When packets aren't reaching their destination, the routing table is often the problem. The -n flag shows numerical addresses instead of trying to resolve hostnames.
20. hostname Who Am I?
hostname
hostname -ISimple but essential. Shows your system's hostname and IP addresses. The -I flag displays all network addresses. Great for scripting and quick identity checks.
The Underrated Heroes
Bonus: iperf Test Network Performance
# On server
iperf -s
# On client
iperf -c server_ipMeasures maximum TCP/UDP bandwidth between two hosts. Perfect for baseline testing when you suspect network performance issues.
Bonus: ethtool Hardware-Level Diagnostics
ethtool eth0
ethtool -S eth0Shows detailed driver information, statistics, and diagnostics. When you need to verify link speed, duplex settings, or troubleshoot at the hardware level.
Real-World Debugging Flow
Here's how I actually use these tools when something breaks:
pingCan I reach the destination?tracerouteWhere's it failing?digIs DNS working?netstat/ssWhat's listening and connected?tcpdumpWhat's actually happening on the wire?
This sequence solves 90% of network issues I encounter.
The Truth About Networking Commands
You don't need to memorize all these commands immediately. Start with the basics: ping, netstat, and ifconfig. As you encounter different problems, your toolkit will naturally expand.
But when that production outage hits, you'll be glad you invested time learning these tools. The difference between an engineer who knows their networking commands and one who doesn't? About three hours of downtime.
Keep this list bookmarked. Your future self will thank you when the network inevitably goes sideways at the worst possible moment.
Now get out there and debug some network issues!