Day 16: Competition – the broken network path
Goal: In five rounds and a double round, find and fix faults along the entire path – from the namespace network through DNS and TLS into the Kubernetes cluster –, against the clock and with the measurement as proof · Duration: approx. 90 min · Prerequisite: Days 0–15
Briefing
- The playing field is the training ground you built in this course:
client→router→webwith DNS (dnsmasq in the router), HTTP and TLS (nginx inweb), plus the kind clusterndbgwith Cilium, Hubble and the serviceweb. - Six times something breaks. You only see what a user sees: a timeout, an error message, a page that does not load.
- Each fault comes from a day of the course. Which one is only revealed in the solution.
- Tools: everything you know –
ip,ping,tcpdump,dig,curl,openssl,nft,iptables,kubectl,cilium-dbg,hubble.
Round Symptom Target time
1 client can no longer reach web 4 min
2 Names fail, IP addresses work 4 min
3 https://shop.firma.lab reports a certificate error 5 min
4 In the cluster: web does not respond 5 min
5 In the cluster: nothing works after a security policy 6 min
D Double round: the NodePort from outside 8 min
Rules of the Game
- In each round, the referee runs their commands – a colleague or you yourself without looking: copy the block, paste it into a second terminal, close the window. Then start the clock.
- Find the cause, fix it, prove it with a measurement. Only then stop the clock.
- Fix the cause, not the symptom. If you delete a firewall table entirely, remove all NetworkPolicies or restart Docker, you get zero points for the round.
- Read the hint only after the target time has run out.
Playing Field
Once before the first round: is everything running? Five checks, each one layer of the path.
# on netz
# shortcuts: commands in the client namespace and in the tools pod
C="sudo ip netns exec client"
W="kubectl exec werkzeug --"
# Hubble port forward from Day 14 in the background (if it is already running, this call only reports an error)
cilium hubble port-forward > /dev/null 2>&1 &
# 1 name + path: ping web.firma.lab (-q summary only, grep shows only the reply count)
$C ping -c1 -W1 -q web.firma.lab | grep -o "1 received"
# 2 HTTP via the name (-w prints only the status code)
$C curl -s -m3 -o /dev/null -w "http %{http_code}\n" http://web.firma.lab/
# 3 TLS verified against your own CA from Day 8 (--resolve: name → IP without DNS)
$C curl -s -m3 -o /dev/null -w "tls %{http_code}\n" --cacert ~/ndbg/pki/ca-chain.crt --resolve shop.firma.lab:8443:10.2.0.10 https://shop.firma.lab:8443/
# 4 service in the cluster, from the tools pod (only the first three characters of the pod name)
$W curl -s -m3 http://web/hostname | cut -c1-3
# 5 NodePort from outside, from the client namespace (Day 12)
$C curl -s -m3 http://172.18.0.3:30080/hostname | cut -c1-3Expected:
1 received
http 200
tls 200
web
web
Five lines, healthy five times. After each round this block must look exactly like this again – that is your proof that you did not break anything else while fixing.
Round 1: client can no longer reach web
Referee:
# on netz
sudo ip -n web route del defaultSymptom:
# on netz
$C curl -sS -m3 http://web.firma.lab/ -o /dev/null; echo "exit=$?"
$C ping -c2 -W1 -q 10.2.0.10 | tail -2curl: (28) Connection timed out after 3002 milliseconds
exit=28
2 packets transmitted, 0 received, 100% packet loss, time 1000ms
Hint: Do the packets arrive at web? And
where would web send its reply?
Solution round 1
# on netz
# The outbound path is correct: client → router → web
$C ip route get 10.2.0.10
sudo ip netns exec router ip route get 10.2.0.10
# Do the pings arrive at web? Capture in the background, 4 s, then two pings
sudo timeout 4 ip netns exec web tcpdump -ni eth0 -c 4 icmp 2>/dev/null &
sleep 1; $C ping -c2 -W1 -q 10.2.0.10 > /dev/null; wait
# And the return path?
sudo ip -n web route
sudo ip netns exec web ip route get 10.1.0.10Expected:
10.2.0.10 via 10.1.0.1 dev eth0 src 10.1.0.10 uid 0
cache
10.2.0.10 dev eth-b src 10.2.0.1 uid 0
cache
12:26:43.856033 IP 10.1.0.10 > 10.2.0.10: ICMP echo request, id 57909, seq 1, length 64
12:26:44.880422 IP 10.1.0.10 > 10.2.0.10: ICMP echo request, id 57909, seq 2, length 64
10.2.0.0/24 dev eth0 proto kernel scope link src 10.2.0.10
10.10.0.0/24 dev stor0 proto kernel scope link src 10.10.0.10
RTNETLINK answers: Network is unreachable
The requests arrive, but no reply ever goes out: web no
longer has a default route and does not know where to send packets for
10.1.0.10. From the outside this looks exactly like a
firewall – only the capture at the destination
separates “does not arrive” from “does not reply” (Day 2 and Day
10).
# on netz
sudo ip -n web route add default via 10.2.0.1
$C ping -c2 -W1 -q 10.2.0.10 | grep -o "2 received"Expected:
2 received
Save your progress? Sign up for free
Round 2: Names fail, IP addresses work
Referee:
# on netz
sudo ip netns exec router nft add table inet wartung
sudo ip netns exec router nft add chain inet wartung eingang '{ type filter hook input priority 0; }'
sudo ip netns exec router nft add rule inet wartung eingang udp dport 53 dropSymptom:
# on netz
time $C curl -sS -m10 http://web.firma.lab/ -o /dev/null
$C ping -c1 -W1 -q 10.2.0.10 | grep -o "1 received"curl: (28) Resolving timed out after 10000 milliseconds
real 0m10.081s
user 0m0.015s
sys 0m0.043s
1 received
Hint: DNS speaks UDP – and TCP if needed.
Solution round 2
# on netz
# one query, one attempt, wait 2 s (+time, +tries)
$C dig +time=2 +tries=1 web.firma.lab | grep -E "timed out|status:|^web"
# the same query over TCP
$C dig +tcp +time=2 +tries=1 web.firma.lab | grep -E "status:|^web"
# is dnsmasq running? And which rules does the router have?
sudo systemctl is-active dns-router
sudo ip netns exec router nft list tables
sudo ip netns exec router nft list table inet wartungExpected:
;; communications error to 10.1.0.1#53: timed out
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38860
web.firma.lab. 0 IN A 10.2.0.10
active
table ip nat
table inet wartung
table inet wartung {
chain eingang {
type filter hook input priority filter; policy accept;
udp dport 53 drop
}
}
Over UDP no reply arrives, over TCP one comes instantly: the service
is running, but a rule drops UDP on port 53 – in a table whose name
sounds like maintenance (“wartung”) and supposedly has nothing to do
with DNS. dig +tcp is the fastest test of whether “DNS
broken” is down to the service or the path (Day 6 and Day 9).
# on netz
sudo ip netns exec router nft delete table inet wartung
$C dig +short web.firma.labExpected:
10.2.0.10
Save your progress? Sign up for free
Round 3: Certificate error at shop.firma.lab
Referee:
# on netz
sed -i '28s|shop-full.crt|api-full.crt|; 29s|shop.key|api.key|' ~/ndbg/nginx.conf
sudo systemctl restart web-nginxSymptom:
# on netz
$C curl -sS -m3 --cacert ~/ndbg/pki/ca-chain.crt --resolve shop.firma.lab:8443:10.2.0.10 https://shop.firma.lab:8443/ -o /dev/null 2>&1 | head -1curl: (60) SSL: no alternative certificate subject name matches target host name 'shop.firma.lab'
Hint: Which certificate does the server present when
you ask for shop.firma.lab?
Solution round 3
# on netz
# connection with SNI shop.firma.lab, verified against your own CA: who does the certificate belong to?
$C openssl s_client -connect 10.2.0.10:8443 -servername shop.firma.lab -CAfile ~/ndbg/pki/ca-chain.crt </dev/null 2>/dev/null | grep -E "^subject=|Verify return code"
# which names does it contain (-ext subjectAltName)?
$C sh -c 'openssl s_client -connect 10.2.0.10:8443 -servername shop.firma.lab </dev/null 2>/dev/null | openssl x509 -noout -ext subjectAltName'
# and what does the configuration say for the shop block?
grep -n -A6 "server_name shop" ~/ndbg/nginx.conf | grep -E "server_name|ssl_certificate"Expected:
subject=CN = api.firma.lab
Verify return code: 0 (ok)
X509v3 Subject Alternative Name:
DNS:api.firma.lab
14: server_name shop.firma.lab;
27: server_name shop.firma.lab;
28- ssl_certificate /home/ubuntu/ndbg/pki/api-full.crt;
29- ssl_certificate_key /home/ubuntu/ndbg/pki/api.key;
The chain is flawless (Verify return code: 0) – the
certificate comes from your CA, is valid and complete. It just belongs
to the wrong name: the shop block serves the certificate of
api.firma.lab. “Trusted” and “for this name” are two
separate checks (Day 8).
# on netz
sed -i '28s|api-full.crt|shop-full.crt|; 29s|api.key|shop.key|' ~/ndbg/nginx.conf
sudo systemctl restart web-nginx
$C curl -s -m3 -o /dev/null -w "%{http_code}\n" --cacert ~/ndbg/pki/ca-chain.crt --resolve shop.firma.lab:8443:10.2.0.10 https://shop.firma.lab:8443/Expected:
200
Save your progress? Sign up for free
Round 4: In the cluster, web does not respond
Referee:
# on netz
kubectl patch service web -p '{"spec":{"selector":{"app":"web","version":"v2"}}}' > /dev/null
sleep 3Symptom:
# on netz
$W curl -sS -m3 http://web/hostname; echo " exit=$?"curl: (7) Failed to connect to web:80 after 35 ms: Could not connect to server
command terminated with exit code 7
exit=7
Hint: The name resolves. Where does the service point?
Solution round 4
# on netz
$W getent hosts web
kubectl get endpointslices -l kubernetes.io/service-name=web
kubectl get service web -o jsonpath='{.spec.selector}'; echo
kubectl get pods -l app=web --show-labels
# what Cilium has entered for the ClusterIP (Day 12; your IP will differ)
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg service list 2>/dev/null | grep "10.96.157.184:80"Expected (pod names and IPs differ):
10.96.157.184 web.default.svc.cluster.local web.default.svc.cluster.local web
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
web-2lp95 IPv4 <unset> <unset> 14h
{"app":"web","version":"v2"}
NAME READY STATUS RESTARTS AGE LABELS
web-69856b5777-2np6w 1/1 Running 0 14h app=web,pod-template-hash=69856b5777
web-69856b5777-p9vjn 1/1 Running 0 14h app=web,pod-template-hash=69856b5777
6 10.96.157.184:80/TCP ClusterIP
DNS is correct, the pods are running and ready – but the service
looks for pods with version=v2, and there are none. Without
endpoints, Cilium has not a single backend for the ClusterIP and rejects
the connection immediately: Could not connect after 35 ms,
no timeout. Empty EndpointSlices are almost always a selector problem or
a readiness probe (Day 12).
# on netz
# remove the extra key version from the selector (JSON patch, op remove)
kubectl patch service web --type=json -p '[{"op":"remove","path":"/spec/selector/version"}]'
sleep 2
$W curl -s -m3 http://web/hostname | cut -c1-3Expected:
service/web patched
web
Save your progress? Sign up for free
Round 5: After the security policy, nothing works anymore
Referee:
# on netz
kubectl apply -f - > /dev/null <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: sicherheit-basis}
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to:
- podSelector: {matchLabels: {app: web}}
ports:
- {protocol: TCP, port: http}
EOF
sleep 2Symptom:
# on netz
$W curl -sS -m5 http://web/hostname; echo " exit=$?"curl: (28) Resolving timed out after 5000 milliseconds
command terminated with exit code 28
exit=28
Hint: The policy is supposed to stay. You can add to policies without changing them.
Solution round 5
# on netz
hubble observe --from-pod default/werkzeug --verdict DROPPED --since 15s --last 2
kubectl get networkpolicy
kubectl get networkpolicy sicherheit-basis -o jsonpath='{.spec.policyTypes} {.spec.egress[*].ports}'; echoExpected (times and pod names differ):
Nov 27 12:28:38.846: default/werkzeug:51180 (ID:1853) <> kube-system/coredns-559f6c778d-jhrg6:53 (ID:52881) policy-verdict:none EGRESS DENIED (UDP)
Nov 27 12:28:38.846: default/werkzeug:51180 (ID:1853) <> kube-system/coredns-559f6c778d-jhrg6:53 (ID:52881) Policy denied DROPPED (UDP)
NAME POD-SELECTOR AGE
sicherheit-basis <none> 9s
["Egress"] [{"port":"http","protocol":"TCP"}]
The classic from Day 14, this time for the whole namespace: outbound
only web on port http, DNS is forgotten. The
policy stays as it is – policies add up, so a second one comes along
that allows exactly DNS:
# on netz
kubectl apply -f - <<'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: dns-erlauben}
spec:
podSelector: {}
policyTypes: [Egress]
egress:
- to:
- namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}}
podSelector: {matchLabels: {k8s-app: kube-dns}}
ports:
- {protocol: UDP, port: 53}
- {protocol: TCP, port: 53}
EOF
$W curl -s -m5 http://web/hostname | cut -c1-3Expected:
networkpolicy.networking.k8s.io/dns-erlauben created
web
In practice, a separate DNS policy is better than copying the rule into every policy: it applies to all pods of the namespace and can be maintained centrally (Enterprise note from Day 14).
Save your progress? Sign up for free
Scoring
within target time 3 points
up to double time 2 points
later 1 point
read the hint −1 point
fixed symptom, not cause 0 points for the round
Maximum after five rounds: 15. From 12 points you have mastered the path; below 8 it is worth redoing the days of the rounds you missed.
Challenge: the double round
Two faults on one path – you only see the second once the first is fixed.
Referee:
# on netz
BR=br-$(sudo docker network inspect kind -f '{{.Id}}' | cut -c1-12)
sudo iptables -D DOCKER-USER -i up0 -o $BR -j ACCEPT
kubectl scale deployment web --replicas=0 > /dev/null
sleep 5Symptom:
# on netz
$C curl -sS -m3 http://172.18.0.3:30080/hostname; echo " exit=$?"curl: (28) Connection timed out after 3002 milliseconds
exit=28
Hint: Test the same NodePort once from
netz itself instead of from the client
namespace.
Solution
# on netz
# the same request directly from netz – without the path via up0
curl -sS -m3 http://172.18.0.3:30080/hostname; echo " exit=$?"
# FORWARD policy and the rules for Docker (-v counters, --line-numbers numbers)
sudo iptables -L FORWARD -n -v | head -3
sudo iptables -L DOCKER-USER -n -v --line-numbersExpected (counters differ):
curl: (7) Failed to connect to 172.18.0.3 port 30080 after 0 ms: Couldn't connect to server
exit=7
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
680K 1064M DOCKER-USER 0 -- * * 0.0.0.0/0 0.0.0.0/0
Chain DOCKER-USER (1 references)
num pkts bytes target prot opt in out source destination
1 13 1141 ACCEPT 0 -- br-1eb80005bd1a up0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
2 15 6621 ACCEPT 0 -- eth0 up0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
3 17 1697 ACCEPT 0 -- up0 eth0 0.0.0.0/0 0.0.0.0/0
Two different symptoms for the same destination – that is the key.
From client a timeout: the packet
disappears along the way. From netz itself an
immediate rejection: the path is clear, but at the
destination nobody is there. DOCKER-USER is missing the
rule up0 → bridge from Day 11; Docker’s FORWARD policy DROP
therefore drops everything that wants to go from the namespace network
into the kind network. First fix:
# on netz
sudo iptables -I DOCKER-USER -i up0 -o $BR -j ACCEPT
$C curl -sS -m3 http://172.18.0.3:30080/hostname; echo " exit=$?"Expected:
curl: (7) Failed to connect to 172.18.0.3 port 30080 after 0 ms: Couldn't connect to server
exit=7
Now the client sees what netz already saw. The second
fault:
# on netz
kubectl get endpointslices -l kubernetes.io/service-name=web
kubectl get deployment web
kubectl scale deployment web --replicas=2
kubectl rollout status deployment web --timeout=120s | tail -1
$C curl -s -m3 http://172.18.0.3:30080/hostname | cut -c1-3Expected:
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
web-2lp95 IPv4 <unset> <unset> 14h
NAME READY UP-TO-DATE AVAILABLE AGE
web 0/0 0 0 14h
deployment.apps/web scaled
deployment "web" successfully rolled out
web
Zero replicas, zero endpoints. The lesson of the double round: if the symptom changes after a fix (timeout → rejection), the fix was right – you have just reached the next fault. If you now delete the rule again because “it still doesn’t work”, you start over.
Save your progress? Sign up for free
Checkpoint
The same block as in the playing field, plus the two things that remain after the competition:
# on netz
$C ping -c1 -W1 -q web.firma.lab | grep -o "1 received"
$C curl -s -m3 -o /dev/null -w "http %{http_code}\n" http://web.firma.lab/
$C curl -s -m3 -o /dev/null -w "tls %{http_code}\n" --cacert ~/ndbg/pki/ca-chain.crt --resolve shop.firma.lab:8443:10.2.0.10 https://shop.firma.lab:8443/
$W curl -s -m3 http://web/hostname | cut -c1-3
$C curl -s -m3 http://172.18.0.3:30080/hostname | cut -c1-3
# two policies from round 5, four rules in DOCKER-USER (the chain itself, as a -N line, does not count)
kubectl get networkpolicy -o name
sudo iptables -S DOCKER-USER | grep -c "^-A"Expected:
1 received
http 200
tls 200
web
web
networkpolicy.networking.k8s.io/dns-erlauben
networkpolicy.networking.k8s.io/sicherheit-basis
4
Clean up
The two policies from round 5 are not part of the training ground:
# on netz
kubectl delete networkpolicy sicherheit-basis dns-erlaubenExpected:
networkpolicy.networking.k8s.io "sicherheit-basis" deleted from default namespace
networkpolicy.networking.k8s.io "dns-erlauben" deleted from default namespace
After the double round, the rule in DOCKER-USER is in
first instead of second place; for the effect, the order of the four
ACCEPT rules does not matter. Appendix A
rebuilds the training ground after a reboot in the original order.
Practice note
The six rounds are six layers: route, DNS, TLS, service, policy, host firewall. In everyday work the report always comes as “it doesn’t work”, never with a layer. The fastest method was the same every time: test the same destination from two places (over TCP instead of UDP, with and without SNI, from the host instead of from the namespace, by IP instead of by name) and compare the two answers. The difference points to the layer where it is stuck – and only then is it worth reading configurations.