Linux & shell: Packet capture & network debugging
10 Linux & shell commands: Packet capture & network debugging. Click a command to see what each part does.
Linux & shell: Packet capture & network debuggingIndex
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
Packet capture & network debugging10
sudo tcpdump -i any -nn port <port>Capture traffic on a portWhat each part does
tcpdumppacket capture-i anyall interfaces-nndon't resolve names or portsport <port>filter: only traffic on that port (also host <ip>, tcp, udp)
sudo tcpdump -i <interface> -w <file>.pcap -c 10000 host <ip>Save a capture for WiresharkWhat each part does
-w <file>.pcapwrite raw packets to a file-c 10000stop after 10,000 packetshost <ip>only traffic to or from this IP
ip route get <ip>Which route and source IP would be used?What each part does
ip route getthe exact route, gateway, interface and source address the kernel would use
mtr -rwc 50 <host>Path and packet loss to a hostWhat each part does
mtrtraceroute and ping combined, per hop-r -wreport mode with wide (untruncated) host names-c 5050 probes per hop
nmap -Pn -p 1-1024 <host>Scan a host's open portsWhat each part does
nmapport scanner (only scan hosts you're allowed to)-Pnskip the ping check (many hosts block ping)-p 1-1024port range (or -p 22,80,443)
ss -sSocket summaryWhat each part does
ss -stotals of TCP states: established, time-wait, orphaned; spot connection leaks
ss -tn state established | awk 'NR>1 {split($4,a,":"); print a[1]}' | sort | uniq -c | sort -rn | headConnections per remote IPWhat each part does
ss -tn state establishedopen TCP connections, numericawk '...'take the peer address column and strip the portsort | uniq -c | sort -rn | headcount per IP, busiest first
ip neighARP / neighbour tableWhat each part does
ip neighIP to MAC mappings; FAILED or INCOMPLETE entries point to layer 2 problems
curl -sv --resolve <host>:443:<ip> https://<host>/Test a URL against a specific IP (skip DNS)What each part does
--resolve <host>:443:<ip>use this IP for that host and port, keeping the right SNI and Host header-svquiet progress, verbose headers and TLS
nc -l <port>Listen on a port to test reachabilityWhat each part does
nc -l <port>listen; from another machine nc -zv <host> <port> or curl shows whether traffic gets through
Nothing matches.
My DevOps Playbook by Angelo John Calleja