Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#linux-networking-tools

Linux Networking Tools Cheatsheet

A comprehensive reference for modern Linux network administration and troubleshooting using iproute2, ss, nmcli, tcpdump, dig, nmap, and netcat.


Network Interface & IP Management (ip)

The ip command replaces legacy tools like ifconfig and route.

# List all IP addresses and interface info
ip a
ip addr show
 
# Show status of link interfaces only
ip link show
 
# Bring an interface UP or DOWN
sudo ip link set eth0 up
sudo ip link set eth0 down
 
# Assign static IP address to an interface
sudo ip addr add 192.168.1.50/24 dev eth0
 
# Remove an IP address from an interface
sudo ip addr del 192.168.1.50/24 dev eth0
 
# View routing table
ip route show
 
# Add default gateway
sudo ip route add default via 192.168.1.1 dev eth0
 
# Delete default gateway
sudo ip route del default

NetworkManager CLI (nmcli)

# Show status of all NetworkManager network devices
nmcli device status
 
# List all active and saved network connections
nmcli connection show
 
# Connect to a Wi-Fi network
nmcli device wifi connect "SSID_NAME" password "WIFI_PASSWORD"
 
# Bring a connection up or down
nmcli connection up "eth0-profile"
nmcli connection down "eth0-profile"
 
# Set static IP on NetworkManager connection
nmcli connection modify "eth0" ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.method manual
nmcli connection up "eth0"

Connectivity & Routing Diagnostics

# Test connectivity via ICMP
ping example.com
 
# Send exactly 4 pings
ping -c 4 192.168.1.1
 
# Trace network route hop by hop
traceroute example.com
 
# Modern dynamic real-time traceroute & ping
mtr example.com
 
# Check ARP cache table (IP to MAC address mappings)
ip neighbor

DNS Diagnostics (dig, nslookup, host)

# Query A record using dig
dig example.com
 
# Query specific DNS record type (MX, TXT, NS, CNAME, AAAA)
dig -t MX example.com
dig -t TXT example.com
 
# Query DNS using a specific DNS server (e.g. Cloudflare 1.1.1.1)
dig @1.1.1.1 example.com
 
# Short clean IP output
dig +short example.com
 
# Reverse DNS lookup (IP to domain)
dig -x 8.8.8.8
 
# Simple host lookup
host example.com

Socket Statistics & Port Listening (ss)

ss replaces legacy netstat for displaying network socket information.

# List all active listening TCP and UDP sockets with numeric ports
ss -tuln
 
# Show listening TCP and UDP sockets with process IDs (requires sudo)
sudo ss -tulpn
 
# Display established TCP connections
ss -wat
 
# Display summary statistics of active sockets
ss -s

Port Scanning & Packet Analysis

Network Exploration (nmap)

# Scan a single host for open ports
nmap 192.168.1.10
 
# Scan entire subnet for active hosts
nmap -sn 192.168.1.0/24
 
# Scan specific ports with service version detection
nmap -sV -p 22,80,443,3306 example.com

Packet Capturing (tcpdump)

# Capture packets on eth0 interface
sudo tcpdump -i eth0
 
# Capture HTTP traffic (port 80) on eth0
sudo tcpdump -i eth0 port 80
 
# Capture packets from a specific IP
sudo tcpdump host 192.168.1.50
 
# Save capture to PCAP file (viewable in Wireshark)
sudo tcpdump -i eth0 -w /tmp/capture.pcap

Network Testing Tools (netcat / nc & iperf3)

# Test TCP port connection
nc -zv 192.168.1.1 80
 
# Listen on a port for incoming connections
nc -l -p 8080
 
# Measure network throughput bandwidth between two machines
# On server:
iperf3 -s
# On client:
iperf3 -c 192.168.1.10