Some infrastructure is so basic that it is noticed only when it breaks, and then everything breaks. DNS delegation hands a zone from a parent to child name servers with NS and glue records; split-horizon DNS answers the same name differently inside and outside a network. BGP is how networks tell each other which addresses they can reach; anycast announces the same address from many places so users reach the nearest. And time: NTP (or PTP) keeps clocks in step, because TLS certificates, tokens, logs, and distributed databases all assume clocks agree. This lesson follows one user's request to an anycast DNS and API service, and shows two failures: a delegation change that broke resolution for a day, and a clock that drifted until tokens were rejected.
Difficulty: Advanced · Know this first: Lesson 105, Lesson 61
By the end of this lesson you can work at four levels:
This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.
This bar adds up minutes of user-visible disruption. It is a worked example, not a measurement. The delegation and time hops are where small infrastructure mistakes become large outages.
Pick how a DNS provider migration is done, how sites announce the anycast address, and whether time sync is monitored.
Three questions. No score is saved anywhere — this is just you against the material.
Infrastructure plumbing grows in four levels: tracing a name and a route, operating DNS and time, running anycast and BGP, and designing it for resilience.
At the basic level you can follow a name to an address and a packet to a site.
dig +trace, NS, glue, TTLs; inside versus outside answers.chronyc tracking or timedatectl.Where it breaks: testing DNS from inside only, when the problem is the public view (or the reverse).
Try it: Basic
Staff cannot reach a new service; customers can. What is the likely cause?
Now do it: Resolve one name from both sides.
At the intermediate level you change DNS and run time sync safely.
Try it: Intermediate
You will change an A record tomorrow. What do you do today?
Now do it: Check the TTL of one record you will change soon.
At the advanced level you announce and protect your own routes.
Try it: Advanced
What does an RPKI ROA let other networks do?
Now do it: Check your prefixes' RPKI status.
At the master level the plumbing has no single point of failure.
Trade-off: two DNS providers double the configuration to keep in step; automation from one source removes the risk of drift.
Try it: Master
Why run authoritative DNS on two providers?
Now do it: List your authoritative name servers and their providers.
Read-only checks for delegation, split-horizon, routing, and time:
dig +trace api.example.com # root → .com → example.com, step by step dig +short NS example.com @a.gtld-servers.net # what the parent says (delegation) dig +short NS example.com @ns1.example.com # what the child says: should match dig +norecurse example.com SOA @ns1.newprovider.net # does the new provider answer authoritatively? dig +short api.example.com @10.0.0.2 # internal view (VPC resolver) dig +short api.example.com @1.1.1.1 # public view whois -h whois.radb.net 203.0.113.0/24 # registered route objects chronyc tracking # "System time" offset from the reference chronyc sources -v # which servers chrony is using, and their quality timedatectl show-timesync --all 2>/dev/null # systemd-timesyncd, where used
A safe DNS provider migration: lower the TTLs of the NS records you control and of key records; export the zone and load it on the new provider; verify every record from the new servers directly; add the new name servers alongside the old ones at the registrar and in the zone; wait at least the parent's NS TTL (two days for .com); remove the old ones from the registrar, then from the zone; keep the old provider serving for another TTL.
Kubernetes and clocks: nodes need time sync like any host; TLS between control plane components, service account tokens (with nbf and exp), and etcd leases all assume it. Many managed platforms configure it for you; custom images must enable it.
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The name servers that were not ready.
DNS changes follow a runbook (verify new servers first, add alongside, wait TTLs, remove last), the zone is managed as code and pushed to both providers, and an external check resolves key names from several public resolvers every minute.
Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.
Before you start: Linux with dig (sudo apt install dnsutils), network access, and Python 3. Every command here is read-only.
Type each one, read what it prints, and compare it with the note above it.
Follow a name from the root, the way a resolver does.
dig +trace +nodnssec example.com | grep -E "IN\s+(NS|A)\s" | head -12
Compare the delegation at the parent with the child's own NS records; they should match.
PARENT=$(dig +short NS com | head -1) echo "parent says:"; dig +short +norecurse NS example.com @"$PARENT" | sort echo "child says:"; dig +short NS example.com @"$(dig +short NS example.com | head -1)" | sort
Look at the TTLs that decide how long a mistake lasts.
dig +noall +answer +authority NS example.com @"$(dig +short NS com | head -1)" +norecurse | awk '{print $2, $4, $5}'Check this machine's clock against its time sources.
chronyc tracking 2>/dev/null | grep -E "System time|Leap" || timedatectl status | grep -Ei "synchronized|NTP"
plumbing.pyThis program simulates a DNS provider migration as resolvers see it, with delegations cached for the parent's two-day TTL, comparing a one-step switch with a staged one. Then it validates tokens issued by hosts with different clock offsets against a 30-second leeway, the way clock skew turns into intermittent rejections. Save it as plumbing.py, then run it.
# plumbing.py
TTL_H = 48 # .com delegations are cached for two days
WINDOW_H = 2 # hours the new servers were listed but could not answer
RESOLVERS = 10_000 # resolvers that look up the domain, refreshing at random times
def affected(hours_after, plan):
if plan == "staged":
return 0 # new servers answer before they are listed; old ones stay up
cached_bad = RESOLVERS * min(hours_after, WINDOW_H) / TTL_H
if hours_after <= TTL_H:
return round(cached_bad)
return round(cached_bad * max(0.0, 1 - (hours_after - TTL_H) / WINDOW_H))
print("hours after the change one-step switch: resolvers failing staged: resolvers failing")
for h in (1, 2, 12, 24, 48, 49, 50):
print(f"{h:>21} {affected(h, 'switch'):>33,} {affected(h, 'staged'):>24,}")
print(f"a resolver that cached the bad delegation keeps it for up to {TTL_H} h, whatever you fix in the meantime")
print()
LEEWAY = 30
HOSTS = {"node-a": 0.4, "node-b": -1.2, "node-new-1": 240.0, "node-new-2": 238.5} # clock offset, seconds
for issuer, offset in HOSTS.items():
issued_at = 1_000_000 + offset # the issuer stamps its own (possibly wrong) time
now_at_verifier = 1_000_000 # the verifier's clock is right
if issued_at - now_at_verifier > LEEWAY:
verdict = f"REJECTED: not yet valid ({issued_at - now_at_verifier:.0f} s in the future)"
else:
verdict = "accepted"
print(f"token from {issuer:<11} offset {offset:+7.1f} s {verdict}")
Run it, and you should see this output:
$ python3 plumbing.py
hours after the change one-step switch: resolvers failing staged: resolvers failing
1 208 0
2 417 0
12 417 0
24 417 0
48 417 0
49 208 0
50 0 0
a resolver that cached the bad delegation keeps it for up to 48 h, whatever you fix in the meantime
token from node-a offset +0.4 s accepted
token from node-b offset -1.2 s accepted
token from node-new-1 offset +240.0 s REJECTED: not yet valid (240 s in the future)
token from node-new-2 offset +238.5 s REJECTED: not yet valid (238 s in the future)
The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/dns-delegation-split-horizon-bgp-anycast-and-time && cd ~/labs/dns-delegation-split-horizon-bgp-anycast-and-time) and save this as lab.sh.
#!/usr/bin/env bash
# The Linux steps of "Internet Plumbing: DNS Delegation, Split-Horizon DNS, BGP, Anycast, and Clock Skew", as one script (save it as lab.sh).
#
# ./lab.sh run every step, in order
# ./lab.sh 2 4 run only steps 2 and 4
# ./lab.sh --list list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.
STEPS=(
'Follow a name from the root, the way a resolver does.'
'Compare the delegation at the parent with the child'\''s own NS records; they should match.'
'Look at the TTLs that decide how long a mistake lasts.'
'Check this machine'\''s clock against its time sources.'
)
step_1() {
dig +trace +nodnssec example.com | grep -E "IN\s+(NS|A)\s" | head -12
}
step_2() {
PARENT=$(dig +short NS com | head -1)
echo "parent says:"; dig +short +norecurse NS example.com @"$PARENT" | sort
echo "child says:"; dig +short NS example.com @"$(dig +short NS example.com | head -1)" | sort
}
step_3() {
dig +noall +answer +authority NS example.com @"$(dig +short NS com | head -1)" +norecurse | awk '{print $2, $4, $5}'
}
step_4() {
chronyc tracking 2>/dev/null | grep -E "System time|Leap" || timedatectl status | grep -Ei "synchronized|NTP"
}
# print a step that has to be run by hand, instead of running it
by_hand() {
echo " (run this one yourself: $1)"
sed 's/^/ /'
}
RESULTS=()
run_step() {
local n=$1 start=$SECONDS code
printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
"step_$n"
code=$?
RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}
summary() {
echo
echo "== summary"
local r
for r in "${RESULTS[@]}"; do echo " $r"; done
}
case "${1:-}" in
-h|--help) sed -n '2,6p' "$0"; exit 0 ;;
--list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac
[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
echo "there is no step '$n'; try --list" >&2
exit 2
fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done
Then make it executable and run it:
chmod +x lab.sh ./lab.sh --list # the steps ./lab.sh # every step, then a summary of exit codes and times ./lab.sh 2 3 # only steps 2 and 3
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
grep, awk, sort, head, echo, Pipes, Redirection, If...Else, Variables.Your company serves an API to customers worldwide and runs internal services in two clouds. Design its DNS, routing, and time infrastructure for resilience.
Where is authoritative DNS hosted, and how are changes made? How do internal and external views stay consistent? How do users reach the nearest healthy site? How are routes protected? How is time kept and monitored?
Say 300 DNS records, 6 serving sites, 2 clouds plus a data centre, 1,500 hosts, and a token lifetime of 5 minutes.
Authoritative DNS on two providers, zone as code pushed to both, changes through a reviewed pipeline with TTL planning; split-horizon generated from the same code (private zones and resolver rules for internal names); anycast through a provider or your own ASN with health-tied announcements and site-loss drills; RPKI ROAs for owned prefixes; chrony on every image against cloud time services and internal servers, offset alerts at 100 ms, leeway of 30 seconds on token checks; external monitoring of resolution from several public resolvers.
Two DNS providers add sync work that automation must absorb; long TTLs reduce query load and slow recovery from mistakes; anycast simplifies global routing and makes per-site capacity planning essential.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Broken delegation | Hop 2: Delegation | Breaks | During a DNS provider migration, the NS records at the registrar are switched to the new provider's servers before the zone is published there. The new servers answer REFUSED for example.com. Resolvers that refresh the delegation cache it for up to two days. |
| Clock drift | Hop 8: Time sync | Breaks | A new node image ships with chrony installed but disabled. Over three days the new nodes drift four minutes fast. |
The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.
Last updated . Next review due by November 2027. Found something out of date? Tell me.