// linux

Linux Network Commands Cheat Sheet

The iproute2 + diagnostic commands engineers actually use on Linux boxes in production. ifconfig, netstat, route and arp are deprecated — these are their replacements.

Updated

Interfaces & addresses

CommandPurposeNotes
ip aList interfaces + addressesModern replacement for ifconfig. Add `ip -br a` for one-line-per-iface.
ip link set eth0 upBring an interface up/downUse `down` to disable. Survives until reboot only.
ip addr add 10.0.0.5/24 dev eth0Add an IPAdd `del` to remove. Not persistent — edit /etc/netplan or NetworkManager.
ethtool eth0Link speed, duplex, driver`ethtool -S eth0` for per-queue stats. `ethtool -i eth0` for driver/firmware.
ip -s link show eth0Interface countersRX/TX errors, drops, overruns — your first stop for NIC issues.

Routing & neighbors

CommandPurposeNotes
ip rRouting tableReplaces `route -n`. Add `ip r get 8.8.8.8` to ask which route a destination uses.
ip route add 10.1.0.0/16 via 10.0.0.1Add a static routeAdd `dev eth0` to pin to interface. `ip r del` to remove.
ip neighARP / NDP tableReplaces `arp -n`. Look for FAILED/STALE entries when L2 is suspicious.
ip -6 rIPv6 routingSame flow, different AF. Don't forget link-local fe80::/10.
ip rulePolicy routingMultiple tables (PBR). `ip route show table 100` for a specific table.

Connectivity & DNS

CommandPurposeNotes
ss -tulnpListening sockets + PIDsModern replacement for netstat. -t TCP, -u UDP, -l listening, -n no DNS, -p PID.
ss -tnp state establishedEstablished TCP sessionsFilter by state. Combine with `dst :443` to scope.
ping -c 4 -W 1 hostICMP reachability-W timeout per probe in seconds. -i 0.2 for faster probes.
mtr -rwzbc 100 hostContinuous traceroute + loss-r report mode, -w wide, -z ASN, -b show IPs, -c 100 cycles. Far better than plain traceroute.
traceroute -T -p 443 hostTCP traceroute on a portBypasses ICMP filtering. Use when normal traceroute hits a wall.
dig +short hostQuick DNS lookup`dig host @1.1.1.1` to bypass local resolver. `+trace` to walk the delegation chain.
nslookup -type=mx domainRecord-type lookupQuick when you don't want dig's verbosity.
host -a domainAll records for a nameFriendlier output than dig for a one-shot check.

Capture & throughput

CommandPurposeNotes
tcpdump -i any -nn 'port 443'Live capture-nn no name resolution, -i any all ifaces. See the tcpdump cheatsheet for BPF filters.
tcpdump -i eth0 -w cap.pcap host 10.0.0.5Save to file for WiresharkAdd `-C 100 -W 10` to rotate 100MB × 10 files.
iftop -i eth0 -nNPLive bandwidth per flowTop-talkers in real time. -P shows ports.
nload eth0Per-interface throughput graphQuick visual of in/out rates.
iperf3 -c host -P 4 -t 30Throughput testRun `iperf3 -s` on the other end. -P parallel streams, -R reverse direction.

Firewall & conntrack

CommandPurposeNotes
iptables -L -n -vShow rules + counters-n no DNS, -v counters. Add `--line-numbers` to delete by index.
nft list rulesetnftables equivalentMost modern distros use nftables under the hood.
ufw status verboseUFW firewall stateUbuntu's friendly frontend. `ufw allow 22/tcp` to add.
firewall-cmd --list-allfirewalld stateRHEL/CentOS. Add `--permanent` to persist; reload after.
conntrack -L -p tcpConnection tracking tableWhen NAT misbehaves, look here. `conntrack -S` for stats.

Want this as a portable toolkit?

ToolBox bundles these commands as one-liner aliases, a tmux dashboard, and a hardened SSH config you can drop on any jump host. Part of the pingtraceSSH Arsenal.

→ Get ToolBox
// free download

Get the Network Engineer Starter Pack

A printable 5-page PDF: first-60-seconds triage, modern Linux network commands, BGP show commands & path-selection order, and a symptom → root-cause map. Free, no fluff.

No spam. Unsubscribe anytime. We send occasional updates when we ship new tools or cheatsheets.

FAQ

What replaced ifconfig, netstat, route and arp?
All four are deprecated and replaced by the iproute2 suite: ifconfig → `ip a` / `ip link`, netstat → `ss`, route → `ip r`, arp → `ip neigh`. They're faster, more accurate, and the only reliable tools on modern interfaces with multiple addresses or VLANs.
Why does ss show more sockets than netstat did?
ss reads directly from kernel netlink, so it sees every namespace and every state. netstat parses /proc and missed sockets in certain states. Trust ss.
Why does my static route disappear after reboot?
`ip route add` is runtime only. Persist via /etc/netplan (Ubuntu), nmcli (NetworkManager), /etc/sysconfig/network-scripts (RHEL legacy), or /etc/systemd/network/*.network (systemd-networkd).
Why is ping working but my app can't connect?
ICMP and TCP take different paths in many firewalls. Use `nc -zv host port` or `curl -v telnet://host:port` to test the actual TCP port your app uses. Also check conntrack and iptables counters.
What's the difference between traceroute and mtr?
traceroute sends one round of probes per hop. mtr sends probes continuously and shows per-hop loss and latency over time — far more useful for diagnosing intermittent issues. Use mtr by default.

Related