Cheat SheetsLinuxNetworking

Networking — Cheat Sheet

Linux · 1 topics. Download the PDF or the Instagram carousel and share it.

Cheat Sheet · AiCanCode.org
Networking
Linux1 topicsQuick revision reference
1

Linux Networking — Tools & Diagnostics

Diagnose and configure Linux networking with ip, ss, netstat, curl, dig, tcpdump, and iptables. These tools are essential for debugging connectivity issues, inspecting sockets, and tracing requests.

  • ip replaces ifconfig and route; ss replaces netstat — prefer the modern tools.
  • ss -tlnp shows all listening TCP ports with owning process — first step when "port already in use".
  • dig @8.8.8.8 tests DNS resolution against a specific server, isolating local resolver issues.
  • curl -v shows request/response headers — essential for debugging auth and redirect issues.
  • tcpdump captures raw packets — use when you need to see exactly what is on the wire.
  • lsof -i :PORT shows which process owns a port — useful when ss output lacks process info.
bash — ip command (modern ifconfig replacement)
# Show network interfaces and IP addresses
ip addr show                   # all interfaces
ip addr show eth0              # specific interface
ip -4 addr show                # IPv4 only

# Output example:
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
#     inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic eth0
#     valid_lft 86397sec preferred_lft 86397sec

# Routing table
ip route show
# default via 192.168.1.1 dev eth0    ← default gateway
# 192.168.1.0/24 dev eth0             ← local subnet

# Add/remove routes
ip route add 10.0.0.0/8 via 192.168.1.1   # route 10.x.x.x through gateway
ip route del 10.0.0.0/8

# Bring interface up/down
ip link set eth0 up
ip link set eth0 down

# ARP cache (IP → MAC mappings)
ip neigh show

# Network namespaces (used by Docker/Kubernetes)
ip netns list
ip netns exec container1 ip addr show
Learn this free with Aria, your AI tutor → AiCanCode.org/learn/linux