Linux networking cheatsheet
Linux networking: Packet capture and firewall
8 common Linux networking tasks.
Capture traffic on an interface
Print packets on an interface without resolving names.
sudo tcpdump -i eth0 -nn
Save a capture for Wireshark
Write packets to a file you can open in Wireshark.
sudo tcpdump -i eth0 -w capture.pcap host 203.0.113.10
Show the firewall rules (ufw)
Show the status and numbered rules of Ubuntu's firewall front end.
sudo ufw status numbered
Allow a port (ufw)
Allow incoming SSH. Allow SSH before enabling the firewall.
sudo ufw allow 22/tcp
Caution: Enabling a firewall without allowing SSH can lock you out of a remote server.
List iptables rules
Show the filter table rules with counters and numeric addresses.
sudo iptables -L -n -v