Appendix A: Cheat sheet
The most important commands, numbers and pitfalls from Days 0 to 16.
The days are in parentheses. Replace placeholders in angle brackets.
ip -n <ns> is the short form of
ip netns exec <ns> ip.
Addresses, links, routes (Days 1, 4)
ip -br a # alle Adressen kurz
ip -br link # alle Links kurz
ip -d link show <dev> # Details: Typ, VLAN-ID, Bridge, MTU
ip addr add <ip>/<len> dev <dev>
ip link set <dev> up | down | mtu <n>
ip route # Tabelle main
ip route get <ziel> [from <quelle> iif <dev>] [ipproto tcp sport <p> dport <p>]
ip neigh show # ARP/NDP-Tabelle
ip neigh flush dev <dev>
ip rule # Policy Routing: welche Tabelle für welche Pakete
ip route show table <n>
sysctl net.ipv4.ip_forward # 0 in jedem neuen Namespace
| Pitfall |
Day |
| Link down silently deletes routes via that interface |
1 |
Always use netplan try with --config-file;
netplan apply does not delete virtual devices |
1 |
A route marked linkdown keeps being used, unless
ignore_routes_with_linkdown=1 |
4 |
rp_filter applies the maximum of all and
the interface; new namespaces start with 2 |
4, 16 |
ip route shows only main. Check policy
rules with ip rule |
4, Appendix B |
Namespaces, veth, bridges, VLANs, bonds (Days 2, 3)
ip netns add <ns>; ip netns list; ip netns del <ns>
ip netns exec <ns> <befehl>
ip netns pids <ns> # Prozesse im Namespace
ip netns identify <pid>
ip -n <a> link add <dev> type veth peer name <dev2> netns <b>
ip link add br0 type bridge [vlan_filtering 1]
ip link set <port> master br0
bridge fdb show br br0 # gelernte MAC-Adressen
bridge vlan show
ip link add <dev>.<vid> link <dev> type vlan id <vid>
ip link add bond0 type bond mode active-backup
DNS in a namespace: /etc/netns/<ns>/resolv.conf,
otherwise the host’s applies, with 127.0.0.53 (Day 2).
Connections (Day 5)
ss -tulpn # wer lauscht wo
ss -tan state established
ss -tni 'dport = :<port>' # rtt, cwnd, mss einer Verbindung
nc -zv -w1 <ip> <port>[-<port>] # Port prüfen
nc -l -N <port> > datei; nc -N <ip> <port> < datei
conntrack -L | -C | -E | -F | -S
sysctl net.netfilter.nf_conntrack_max # nur im Root-Namespace setzbar
TIME-WAIT is normal; growing numbers of
CLOSE-WAIT are a program bug. Full conntrack table:
table full, dropping packet in dmesg.
DNS and DHCP (Days 6, 15)
dig +short <name> [@<server>]
resolvectl status
dnsmasq --test --conf-file=<datei>
ip netns exec <ns> dnsmasq --conf-file=<datei>
ip netns exec <ns> dhcpcd -4 -1 -t 30 --noipv4ll -C resolv.conf eth0
| dnsmasq option |
Purpose |
interface=, bind-interfaces,
except-interface=lo |
listen only there, no conflict with systemd-resolved |
bind-dynamic |
also bind addresses that appear later (VIP!) |
no-hosts, no-resolv |
do not hand out the host’s /etc/hosts and
/etc/resolv.conf |
dhcp-range,
dhcp-option=option:router,… |
range and gateway |
host-record=, address=/…/ |
your own names |
Capturing (Day 7)
tcpdump -i <dev|any> -n [-v] [-e] [-c <n>] [-s 128] '<filter>'
tcpdump -i <dev> -w datei.pcap -C 1 -W 3 -Z ubuntu '<filter>' # Ringpuffer
tcpdump -r datei.pcap -n [-S]
tshark -r datei.pcap [-Y '<anzeigefilter>'] [-T fields -e <feld>]
tshark -r datei.pcap -q -z conv,tcp | -z expert | -z follow,tcp,ascii,0
| BPF filter |
Display filter (tshark) |
host 10.0.0.1, net 10.0.0.0/24 |
ip.addr == 10.0.0.1 |
tcp port 8080 |
tcp.port == 8080 |
tcp[tcpflags] & tcp-rst != 0 |
tcp.flags.reset == 1 |
not port 22 |
tcp.analysis.retransmission,
tcp.analysis.zero_window |
Retransmits and duplicate ACKs: loss along the way. Zero window: the
receiver cannot keep up. Forged reset: TTL one hop too high (Day 7).
MTU and overlays (Day 8)
ping -M do -s <mtu − 28> <ziel> # größtes Paket mit DF
tracepath -n <ziel> # Path MTU und wo sie sinkt
ip route get <ziel> # gelernte PMTU: "cache expires … mtu 1400"
ip route flush cache
nft add rule … tcp flags syn tcp option maxseg size set rt mtu # MSS-Clamping
ip link add vx0 type vxlan id <vni> local <a> remote <b> dstport 4789 dev <dev>
| Encapsulation |
costs |
| VXLAN |
50 bytes |
| PPPoE |
8 bytes (MTU 1492) |
| WireGuard |
60 to 80 bytes |
Never block ICMP “destination unreachable”. “Ping works, large
downloads hang” means MTU.
Measuring and disrupting (Day 9)
iperf3 -s -D # Server im Hintergrund
iperf3 -c <ip> -t 5 [-R] [-P 4] [-u -b 100M]
mtr -n -r -c 100 [-i 0.2] <ziel>
ethtool -i <dev>; ethtool <dev>; ethtool -k <dev>; ethtool -S <dev>
tc qdisc add dev <dev> root netem delay 50ms [20ms] | loss 5%
tc qdisc add dev <dev> root handle 1: tbf rate 100mbit burst 32kb latency 400ms
tc qdisc add dev <dev> parent 1:1 fq_codel
tc -s qdisc show dev <dev>; tc qdisc del dev <dev> root
nstat -n; nstat -z <zähler> # Zähler seit dem letzten -n
tc acts only on outgoing traffic. mtr loss that
disappears at the destination is reply rate limiting. Throughput of a
connection ≤ window ÷ round-trip time.
| Measured in the lab |
Value |
| veth, one TCP connection |
14.9 Gbit/s |
| 50 ms delay |
580 Mbit/s |
| 10% loss |
7.55 Mbit/s |
| without TSO/GSO |
2.6 Gbit/s |
| ping under load without / with fq_codel |
210 ms / 1 ms |
FRR (Days 10 to 15)
# einmalig: jede Instanz frr@<ns> läuft im Namespace <ns>
printf '[Service]\nNetworkNamespacePath=/run/netns/%%i\n' | sudo tee /etc/systemd/system/[email protected]/netns.conf
# pro Router: /etc/frr/<ns>/daemons (ospfd=yes, bgpd=yes, bfdd=yes), frr.conf, vtysh.conf, Eigentümer frr
systemctl start frr@<ns>
vtysh -N <ns> -c 'configure terminal' -c '…' -c 'end' -c 'write memory'
| Command |
shows |
show ip ospf neighbor |
neighbors, target state Full |
show ip ospf interface <dev> |
area, network type, timers, MTU |
show ip ospf database router (or
external) |
the map |
show ip route ospf (or bgp,
<präfix>) |
learned routes |
show bgp ipv4 unicast summary |
sessions, received/sent prefixes, (Policy) |
show bgp ipv4 unicast <präfix> |
all paths and why one is best |
show bgp ipv4 unicast neighbors <ip> received-routes |
before the filter (needs
soft-reconfiguration inbound) |
show bfd peers [brief] |
BFD sessions |
| OSPF state stuck in |
Usual cause |
| no adjacency |
area, timers, netmask, authentication |
Init |
hellos in one direction only |
ExStart/Exchange |
MTU mismatch |
BGP: without a route-map in both directions, no routes (RFC 8212).
Local preference controls your own egress, AS-path prepending the
ingress. Always change OSPF costs on both ends.
| Convergence on silent failure (Day 11) |
measured |
| OSPF default (10/40 s) |
approx. 33 s |
| Hello 1 s, Dead 3 s |
approx. 2.3 s |
| BFD 3 × 100 ms |
approx. 0.26 s |
ECMP and anycast (Day 13)
sysctl -w net.ipv4.fib_multipath_hash_policy=1 # Ports in den Hash, pro Router
ip route show <ziel> # mehrere nexthop-Zeilen
Anycast absorbs the failure of the path, not of the service. Tie the
announcement to a health check.
keepalived (Days 14, 15)
keepalived -P -s <ns> -f /etc/keepalived/<ns>.conf
kill -HUP $(cat /run/keepalived/<ns>/keepalived.pid) # neu laden
kill $(cat /run/keepalived/<ns>/keepalived.pid) # sauber beenden, übergibt sofort
journalctl -t Keepalived_vrrp_<ns>
arping -c 4 -I eth0 <vip> # zwei MACs = Split Brain
tcpdump -i eth0 -n vrrp
| Event |
measured |
| clean stop, return with preemption |
0 packets lost |
| MASTER’s link gone |
approx. 2.6 s |
uplink gone with track_interface (FAULT) |
approx. 2.4 s |
vRouter: BGP gone, track_script |
approx. 1.6 s, NAT connections break |
kill -9 leaves the VIP in place. Services on the VIP
need bind-dynamic or 0.0.0.0.
The pitfalls from the book
| Pitfall |
Day |
pkill -f <muster> in an SSH command line hits
your own shell; use [m]uster or ^prozess |
7, 13 |
| Giant segments and wrong checksums in a capture are offload |
7, 9 |
Without ip netns exec, frr@<ns> runs
in the VM’s namespace |
10 |
The FRR hostname stays netz; identify routers by their
router ID |
10 |
Change the OSPF area only with no ip ospf area
first |
Appendix B |
BFD on one side only: session down, protects nothing,
but does no harm either |
11 |
| Server link in OSPF: the forward address breaks ECMP for anycast
after a flap |
13 |
| Ports below 1024 are blocked for normal users |
13 |
dhcpcd without --noipv4ll sometimes ends
up on 169.254.x.x |
6, 15 |
| Split-scope DHCP: whoever offers first wins |
15 |