SkillPilotAI

DNSSEC, DoH/DoT, mDNS and split DNS

Plain DNS travels unencrypted on UDP 53 and can be read or faked. This topic covers the fixes and variations: DNSSEC (signed answers), DoT/DoH (encrypted transport), mDNS (.local names without a server), split-horizon DNS (different answers per network) and the hosts file.

83.1 Why is it used?

  • On a cafe Wi-Fi an attacker can read your plain DNS query to 1.1.1.1 (privacy problem).
  • If the attacker's fake reply arrives before the real one, the laptop accepts a wrong IP: DNS spoofing (integrity problem).
  • DNSSEC fixes integrity, DoT/DoH fix privacy.
  • A home LAN has no DNS server, yet printer.local must resolve: mDNS.
  • Office users need the private IP of app.example.com, internet users the public one: split-horizon DNS.

83.2 DNSSEC chain of trust

  • Every zone signs its records with its private key; the signature travels as an RRSIG record.
  • The zone's public key is published as a DNSKEY record.
  • The parent zone holds a DS record = hash of the child's key (DS for example.com sits in com, DS for com sits in the root).
  • The root key is pre-installed in the resolver as the trust anchor, so the whole chain can be verified.
DNSSEC validation of example.com
  1. 1.Resolver asks example.com: A? -> gets A + RRSIG

  2. 2.Fetches example.com DNSKEY and checks the RRSIG

  3. 3.Fetches DS for example.com from com: does the hash match the DNSKEY?

  4. 4.Fetches com DNSKEY and its DS from the root

  5. 5.Checks the root DNSKEY against the built-in trust anchor

  6. 6.All links valid -> answer marked ad (authenticated data)

Any broken link -> SERVFAIL

Terminal
dig @1.1.1.1 +dnssec example.com Adelv @1.1.1.1 example.com Adelv @1.1.1.1 +rtrace example.com A
Output
$ dig @1.1.1.1 +dnssec example.com A;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1; EDNS: version: 0, flags: do; udp: 1232example.com.  179  IN  RRSIG  A 13 2 300 20261109233216 20261107213216 34505 example.com. ...ns$ delv @1.1.1.1 example.com A; fully validatedexample.com.  300  IN  A  104.20.23.154example.com.  300  IN  A  172.66.147.243example.com.  300  IN  RRSIG  A 13 2 300 20261109233428 20261107213428 34505 example.com. ...ns$ delv @1.1.1.1 +rtrace example.com A;; fetch: example.com/A;; fetch: example.com/DNSKEY;; fetch: example.com/DS;; fetch: com/DNSKEY;; fetch: com/DS;; fetch: ./DNSKEY; fully validated
  • ad flag = the resolver validated the signature; do flag = we asked for DNSSEC records.
  • delv validates by itself instead of trusting the resolver's ad flag; +rtrace lists every fetch in the chain.

83.3 When DNSSEC fails

Terminal
dig @1.1.1.1 dnssec-failed.org Adig @1.1.1.1 +cd dnssec-failed.org Adelv @1.1.1.1 dnssec-failed.org Adelv @1.1.1.1 example.com A   # old delv
Output
$ dig @1.1.1.1 dnssec-failed.org A;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 54415; EDE: 9 (DNSKEY Missing): (no SEP matching the DS found for dnssec-failed.org.)$ dig @1.1.1.1 +cd dnssec-failed.org Adnssec-failed.org.  300  IN  A  96.99.227.255ns$ delv @1.1.1.1 dnssec-failed.org A;; resolution failed: failure$ delv -vdelv 9.18.25$ delv @1.1.1.1 example.com A;; validating ./DNSKEY: no valid signature found (DS);; no valid RRSIG resolving './DNSKEY/IN': 1.1.1.1#53;; broken trust chain resolving 'example.com/A/IN': 1.1.1.1#53;; resolution failed: broken trust chain$ dig @1.1.1.1 . DNSKEY +dnssec | grep RRSIG.  3515  IN  RRSIG  DNSKEY 8 0 172800 20261121000000 20261031000000 38696 . ...
  • dnssec-failed.org is a test zone with a deliberately broken chain: SERVFAIL with EDE 9 (DNSKEY Missing).
  • +cd (checking disabled) returns the IP: the data exists, the resolver just refuses to trust it.
  • Real observation: the old delv 9.18.25 calls even example.com a broken trust chain, because the root is now signed by the new KSK 38696 that its built-in trust anchor lacks (delv 9.18.49 validates fine). Outdated trust anchors break validation.

83.4 DNS over TLS and DNS over HTTPS

PointPlain DNSDoTDoH
PortUDP/TCP 53TCP 853TCP 443
EncryptedNoYes (TLS)Yes (HTTPS)
Looks likeDNSClearly DNS (own port, easy to block)Normal web traffic
dig option(default)+tls+https
Terminal
dig @1.1.1.1 +short example.com Adig +tls @1.1.1.1 +short example.com Adig +https @1.1.1.1 +short example.com Atcpdump -nn -q -i eth0 host 1.1.1.1# Windows (read-only):netsh dns show encryption server=1.1.1.1
Output
$ dig +https @1.1.1.1 +short example.com A172.66.147.243104.20.23.154;; SERVER: 1.1.1.1#443(1.1.1.1) (HTTPS)$ tcpdump -nn -q -i eth0 host 1.1.1.1IP 192.168.103.10.39104 > 1.1.1.1.53: UDP, length 52IP 1.1.1.1.53 > 192.168.103.10.39104: UDP, length 72IP 192.168.103.10.42289 > 1.1.1.1.853: tcp 309IP 1.1.1.1.853 > 192.168.103.10.42289: tcp 1180IP 192.168.103.10.42289 > 1.1.1.1.853: tcp 80IP 192.168.103.10.44981 > 1.1.1.1.443: tcp 312IP 1.1.1.1.443 > 192.168.103.10.44981: tcp 1180IP 192.168.103.10.44981 > 1.1.1.1.443: tcp 182PS> netsh dns show encryption server=1.1.1.1Encryption settings for 1.1.1.1DNS-over-HTTPS template     : https://cloudflare-dns.com/dns-queryAuto-upgrade                : noUDP-fallback                : no
  • Same answer for all three; tcpdump shows the difference: one small UDP packet on 53 vs only encrypted TCP data on 853 and 443.
  • A fake reply from the attacker now fails the TLS check.

83.5 mDNS and .local

mDNS: resolving printer.local without a DNS server
  1. 1.Laptop sends "printer.local?" to multicast 224.0.0.251, UDP 5353

  2. 2.The switch floods the multicast to every device on the LAN

  3. 3.Only the device named printer.local answers: A 192.168.103.30

  4. 4.On startup the printer probes 3 times (is the name free?) then announces its IP

.local is reserved for mDNS; Bonjour on macOS, avahi on Linux

Terminal
avahi-daemon --no-drop-root --no-chroottcpdump -nn -i eth0 udp port 5353avahi-resolve -4 -n printer.localavahi-browse -rt _ipp._tcp
Output
printer$ avahi-daemon --no-drop-root --no-chrootJoining mDNS multicast group on interface eth0.IPv4 with address 192.168.103.30.Server startup complete. Host name is printer.local.Service "Office Printer" (/etc/avahi/services/ipp.service) successfully established.pc$ tcpdump -nn -i eth0 udp port 5353192.168.103.30.5353 > 224.0.0.251.5353: 0 [2q] [2n] ANY (QM)? ... printer.local. (94)192.168.103.30.5353 > 224.0.0.251.5353: 0 [2q] [2n] ANY (QM)? ... printer.local. (94)192.168.103.30.5353 > 224.0.0.251.5353: 0 [2q] [2n] ANY (QM)? ... printer.local. (94)192.168.103.30.5353 > 224.0.0.251.5353: 0*- [0q] 2/0/0 (Cache flush) PTR printer.local., (Cache flush) A 192.168.103.30 (82)laptop$ avahi-resolve -4 -n printer.localprinter.local	192.168.103.30laptop$ avahi-browse -rt _ipp._tcp=   eth0 IPv4 Office Printer      Internet Printer     local   hostname = [printer.local]   address = [192.168.103.30]   port = [631]   txt = ["ty=Lab Printer"]

On macOS (or Windows with Bonjour) the same job is done by dns-sd. It was not installed on the lab PC, so this is syntax from its man page:

Output
dns-sd -B _ipp._tcp          services browsedns-sd -L NAME _ipp._tcp     host + portdns-sd -G v4 printer.local   IPv4 lookupdns-sd -Q printer.local A    record querydns-sd -R NAME _http._tcp . 80   registerdns-sd -Z _ipp._tcp          zone file formatdns-sd -E / -F               domains list

83.6 Split-horizon DNS with BIND views

  • Same name app.example.com: office client gets the private IP 192.168.103.80, outside client gets the public 203.0.113.80.
  • The server decides by the client's source IP; internal server details never leak outside.
  • VPN split DNS works on the same idea.
Terminal
cat /etc/bind/n083.confip -4 -br addr show eth0dig @192.168.103.53 +short app.example.com
Output
ns$ cat /etc/bind/n083.confacl office { 192.168.103.0/25; };view "office" { match-clients { office; };  zone "example.com" { type primary; file "/etc/bind/office.zone"; }; };view "public" { match-clients { any; };  zone "example.com" { type primary; file "/etc/bind/public.zone"; }; };pc$ ip -4 -br addr show eth0eth0@if1510      UP             192.168.103.10/24pc$ dig @192.168.103.53 +short app.example.com192.168.103.80home$ ip -4 -br addr show eth0eth0@if1511      UP             192.168.103.200/24home$ dig @192.168.103.53 +short app.example.com203.0.113.80

83.7 hosts file: checked before DNS

Terminal
getent hosts app.example.comecho '192.168.103.99 app.example.com' \  >> /etc/hostsgetent hosts app.example.comdig +short app.example.comgrep hosts /etc/nsswitch.conf
Output
$ getent hosts app.example.com192.168.103.80    app.example.com  app.example.com$ echo '192.168.103.99 app.example.com' >> /etc/hosts$ getent hosts app.example.com192.168.103.99    app.example.com  app.example.com$ dig +short app.example.com192.168.103.80resolved$ grep hosts /etc/nsswitch.confhosts:          files dns
  • nsswitch order "files dns": /etc/hosts wins over DNS for getent and normal apps.
  • dig ignores the hosts file and asks the DNS server directly, so the two can differ while debugging.
  • Windows: C:\Windows\System32\drivers\etc\hosts.

83.8 systemd-resolved: DNSSEC + DoT + mDNS together

Terminal
cat /etc/systemd/resolved.confresolvectl statusresolvectl query example.comresolvectl query dnssec-failed.orgresolvectl mdns eth0 yesresolvectl query printer.local
Output
$ cat /etc/systemd/resolved.conf[Resolve]DNS=1.1.1.1#cloudflare-dns.comDNSOverTLS=yesDNSSEC=yesMulticastDNS=yesLLMNR=noDomains=~.$ resolvectl statusGlobal       Protocols: -LLMNR +mDNS +DNSOverTLS DNSSEC=yes/supportedresolv.conf mode: foreign      DNS Servers 1.1.1.1#cloudflare-dns.com       DNS Domain ~.$ resolvectl query example.comexample.com: 104.20.23.154                  -- link: eth0             172.66.147.243                 -- link: eth0-- Information acquired via protocol DNS in 342.9ms.-- Data is authenticated: yes; Data was acquired via local or encrypted transport: yes$ resolvectl query dnssec-failed.orgdnssec-failed.org: resolve call failed: DNSSEC validation failed: missing-key$ resolvectl mdns eth0 yes$ resolvectl query printer.localprinter.local: 192.168.103.30               -- link: eth0-- Information acquired via protocol mDNS/IPv4 in 26.3ms.-- Data is authenticated: no; Data was acquired via local or encrypted transport: no

83.9 Common mistakes

  • Thinking DNSSEC encrypts DNS: it only signs. Anyone can still read the query and answer; they just cannot change them.
  • Thinking DoH makes DNSSEC unnecessary: DoH only protects the laptop-to-resolver path. If the resolver itself returns a wrong answer, only DNSSEC can catch it.
  • Debugging with dig while the app uses the hosts file (or the other way round).
  • Running old validators with stale trust anchors: they report broken trust chains for valid zones.

83.10 Interview tips

  • DNSSEC = integrity (RRSIG, DNSKEY, DS, root trust anchor); DoT 853 / DoH 443 = privacy. Best setup uses both.
  • Split-horizon: different answers for the same name based on the client's source IP; BIND views + match-clients.
  • mDNS: .local names over multicast 224.0.0.251 UDP 5353, no server needed.
  • Name lookup order on Linux comes from nsswitch.conf: hosts file first, then DNS.