Some notes on Linux networking

naruto · Dec 21, 2025 Public

1. Network Interfaces

  • List interfaces: ip link, ip addr
  • Bring up/down: ip link set eth0 up|down
  • Assign IP: ip addr add 192.168.1.10/24 dev eth0
  • Loopback: lo (127.0.0.1)

2. IP Addressing

  • IPv4 CIDR: /24 = 255.255.255.0
  • View routes: ip route
  • Default gateway: default via 192.168.1.1
  • ARP cache: ip neigh

3. Routing

  • Add route: ip route add 10.0.0.0/24 via 192.168.1.1
  • Delete route: ip route del …
  • Policy routing: ip rule, multiple routing tables

4. DNS

  • Resolver config: /etc/resolv.conf
  • Test DNS: dig, nslookup
  • Local hosts override: /etc/hosts
  • systemd-resolved status: resolvectl status

5. Ports & Sockets

  • List listening ports: ss -lntup
  • Old tool: netstat -tulnp
  • TCP vs UDP:
    • TCP: reliable, ordered
    • UDP: fast, no guarantee

6. Firewall (iptables / nftables)

  • Modern backend: nftables
  • Allow port (iptables):

    iptables -A INPUT -p tcp --dport 22 -j ACCEPT

  • Check rules: iptables -L -n
  • UFW (simple):

    ufw allow 80 ufw enable 


7. Network Debugging

  • Ping: ping 8.8.8.8
  • Path tracing: traceroute, tracepath
  • Packet capture: tcpdump -i eth0
  • Test port: nc -zv host port, telnet

8. Bandwidth & Traffic

  • Interface stats: ip -s link
  • Live traffic: iftop, nload
  • Per-process: ss, lsof -i

9. Network Services

  • SSH: port 22
  • HTTP/HTTPS: 80 / 443
  • DNS: 53
  • Check service bind:

    ss -lntp | grep 80


10. Namespaces & Containers (Important)

  • Network namespace: isolated network stack
  • Docker:
    • bridge (default)
    • host (no isolation)
    • overlay (multi-node)
  • View namespaces: ip netns

11. Common Files

  • /etc/hosts
  • /etc/resolv.conf
  • /etc/network/interfaces (Debian legacy)
  • /etc/netplan/*.yaml (Ubuntu)

12. Quick Commands Cheat

ip a ip r ss -tulnp ping dig tcpdump curl