DNS Deep Dive
DNS Deep Dive
1
Note Well
This is a reminder of IETF policies in effect on various topics such as patents or code of conduct. It is only meant to point you
in the right direction. Exceptions may apply. The IETF's patent policy and the definition of an IETF "contribution" and
"participation" are set forth in BCP 79; please read it carefully.
As a reminder:
● By participating in the IETF, you agree to follow IETF processes and policies.
● If you are aware that any IETF contribution is covered by patents or patent applications that are owned or controlled by you or your
sponsor, you must disclose that fact, or not participate in the discussion.
● As a participant in or attendee to any IETF activity you acknowledge that written, audio, video, and photographic records of meetings may
be made public.
● Personal information that you provide to IETF will be handled in accordance with the IETF Privacy Statement.
● As a participant or attendee, you agree to work respectfully with other participants; please contact the ombudsteam
(https://www.ietf.org/contact/ombudsteam/) if you have questions or concerns about this.
Definitive information is in the documents listed below and other IETF BCPs. For advice, please talk to WG chairs or ADs:
3
DNS as the novice Internet user sees it
website
www.example.com
4
DNS as the Techy Internet user sees it
HTTP to 93.184.216.34
HTTP
Server
93.184.216.34!
www.example.com?
DNS
hostname Server
5
DNS is Much Much More Complex
HTTP to 93.184.216.34
DNS Root (x13 v4, 13 v6)
93.184.216.34!
www.example.com?
com (x13 v4, 13 v6)
ISP DNS1
ISP DNS2
www.example.com?
Query Truncated
Authoratative/DNSSEC Response
7
ietf.org web page
(without caching)
8
webmd.com You are here
(without caching)
10
The Underlying Distributed Model of the DNS
11
DNS was created as a replacement for /etc/hosts
Distributed system to replace static information
Back in my day:
93.184.216.34 www.example.com
is all we needed.
12
The DNS ‘tree’ RFC103{4,5}
Second Level
Domains iana-servers example ietf icann
(SLDs)
a b c www ns
zone
IMPORTANT: name server records in .net (13), .com (13), and .org (6) are not shown in these slides 13
Resolvers
www.example.com?
root
root
.net zone
iana-servers www ns
a b c
16
.iana-servers.net zone
Some DNS Terminology
root b.a.example.com.
.net zone
net com
.example.com. zone
example empty
non-terminal
a
iana-servers www
.iana-servers.net b
zone apex a b c
other domain names in the zone
“terminal” (aka “leaves”) 17
.iana-servers.net. zone
Duplicate records needed in parent/child zones
iana-servers.net. NS a.iana-servers.net.
iana-servers.net. NS b.iana-servers.net. root
.net zone
iana-servers.net. NS c.iana-servers.net.
a b c
18
.iana-servers.net zone
Does this work? -- Yes but actually not well
If a.iana-servers.net can’t answer,
iana-servers.net. NS a.iana-servers.net. this is a “lame delegation”
iana-servers.net. NS b.iana-servers.net. root (it’s not authoritative but .net thinks it is)
.net zone
root
a b c www ns
zone
a b c www ns
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID | / NAME /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QDCOUNT | | CLASS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ANCOUNT | | TTL |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | |
| NSCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RDLENGTH |
| ARCOUNT | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / RDATA /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
24
DNS - A very very simple protocol
● DNS packets ship resource records around
● All Resource Records are composed of a triplet
○ A Query Name “www.example.com” (aka a “domain name”)
○ A Query Type AAAA = IPv6 address
○ A Query Class IN = Internet (aka, almost the only value used)
● Resource Record Sets
○ ALL matching combinations are an atomic unit
○ You can’t ask for “just 2”
○ They are not ordered
● Response Records also contain
○ A “Time To Live”
○ Response Data
25
RFC1035:
DNS Packet Components [This] section contains
QDCOUNT (usually 1)
entries
● Header
○ Transaction ID
○ Flags
○ Number of records in each section
● DNS Resource Record Sections
○ Question
○ Answer
○ Authoritative
○ Additional
27
What happens when DNS things go wrong?
The DNS packet headers contain an “response code” (RCODE) field, yay!
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR| Opcode |AA|TC|RD|RA| Z | RCODE |
Drat, it’s only 4 bits… There are way more than 16 problems
28
Let’s get creative about the RCODE problem
What if….
What if….
● Greater than the client said it could handle in the OPT/UDP Payload Size
A few things:
What if….
34
Resource Record Types
Type Content
A IPv4 Address
35
IPv4/IPv6 Deployment: Happy Eyeballs (RFC8305)
root
www.example.com/AAAA?
● Reponses:
host1.example.com/MX MATCHES
host2.example.com/MX MATCHES
host1.example.com/A DOESN’T MATCH (returns 192.0.2.1)
host2.example.com/A DOESN’T MATCH (returns NXDOMAIN) 39
Underbar labels: “_foo” (RFC855{2,3})
● For a long time people kept putting TXT records at the APEX
○ SPF
○ DKIM
○ DOMAINKEY
○ DNS ownership verification (google, facebook, docusign, …)
○ …
● The “right” solution was to use a new RRTYPE rather than TXT
○ But this was slower to deploy
● The new solution: use TXT and RRTYPE records at “_” prefixes
○ _spf.example.com. IN TXT - The right “new” for SPF
○ _domainkey.example.com. IN TXT - DKIM key publishing
○ _25._tcp.mail.example.com. IN TLSA - DANE for secured SMTP (RFC7672)
○ _imaps._tcp.example.com. IN SRV - Service host discovery
40
Summary: DNS is a global distributed identifier DB
Yes, but how does this all scale so well?
I have no idea
41
Extended Errors RFC -- in the RFC editor’s queue
● SERVFAIL error is the standard “I couldn’t” response
○ Operators are clueless as to why
○ e.g. most types of DNSSEC validation failures triggers this
● Extended error adds context for SERVFAIL (and others)
● With optional text providing greater debugging detail
42
DNS Deep Dive, IETF 108
Resilience
Resilience and Replication
One and Only One?
What would a ‘unitary’ DNS look like?
Recursive Resolver
Authoritative Servers
Stub Resolver
One and Only One? Recursive Resolver
Authoritative Servers
Stub Resolver
Authoritative Servers
Stub Resolver
Recursive Resolvers
Authoritative Servers
Stub Resolver
More than One
Resolv.conf
• Stub resolvers are typically configured with up to three recursive resolvers
• You can add more but…
• In a dual stack world each of these resolvers has both IPv4 and IPv6 addresses
and queries are made in parallel via both protocols (1)
• The order is usually important (2), and subsequent resolvers are only queried if
there is a UDP timeout from prior queries (3)
Authoritative Servers
• DNS domains are typically configured with more than one authoritative server
• The root zone uses 13 different server names each with IPv4 and IPv6 addresses
• Between 2 and 4 authoritative servers seems to be common practice these days
• For most applications 5 or more services is probably excessive, and 1 is regarded
as too few (1)
• The server list MAY round robin depending on the authoritative server code
1. A single unicast server is probably not enough, and a single anycast address with a set of servers using the same address may still not be enough to be
resilient! Diversity is the key here, not mindless replication
Resilience in Transport – not!
UDP
• All bets are off!
• You have no idea if the query or the response was lost
• The UDP sender uses a timeout to determine a “no answer” condition
• The timeout value depends on context:
• Stub resolvers are observed to use timeout values between 1 and 5 secs (1)
• Recursive resolvers are seen to use use values between ~300ms and 1 sec
• Should you ask the same server again? Or maybe change the address/protocol? Or maybe ask
a different server?
• When to just give up? The number of timeouts is typically limited (2)
1. resolv.conf sets the timeout to 5 seconds by default, with a minimum of 1 and a maximum of 30 configurable in
resolv.conf
2. resolv.conf sets the number of attempts to 2 by default with a maximum of 5 configurable in resolv.conf
Resilience in Transport
TCP
• If you can reach the server then you can reasonably expect a response
• Or an error code or some sort
• Asking the same server again is kinda pointless, particularly if you expected a
different answer
• But sometimes different recursives hide behind the same name or even the same protocol
and protocol address
• Asking a different server might be helpful if you didn’t like some first answers
(SERVFAIL or possibly REFUSED) but generally it’s not all that useful
Resilience in Transport++
• DNS over TLS over TCP (DoT)
• DNS over HTTPS over TLS over TCP (DoH)
• DNS over QUIC over encrypted TCP-like transport (DoQ)
Yes (1)
(1) Session time is finite, this topic is not! Best left to another session with more time!
If more is better…
better
Corner Cases:
Responses with EDNS(0) Client Subnet (1) are cached with the Client Subnet value attached
NS records from Child vs NS records from Parent
resource records that fail local DNSSEC validation
cache them but only serve from cache if the query has the CD bit set
not clear what to do if the query has no EDNS(0) extensions
DNSSEC NSEC records, which can be used to respond to a range of qnames. This exploits the property that the total name space
is far larger than the occupied name space. So the “gaps” between the list of alphabetically sorted (2) names encompass a vastly
greater pool of names than the occupied names, so NSEC caching stores these “gaps” to increase the leverage of caches
(2) NSEC3 works too, but now we sort the hashes of names, not the names (3)
(3) NSSEC3 should never have happened
Cache TTLs
TTL determines the cache lifetime
• Well not really – TTLs SUGGEST a cache lifetime (in seconds) (1)
• The resolver may shorten or lengthen the cache time
• Popular caching resolvers have a “Max TTL” setting to cap TTL values
• There does not appear to be a universal minimum TTL above 0
• And “0” is equivalent to “do not cache”
• And caches are finite-sized, so entries may be removed prior to TTL expiry
under high load
(1) The resolver may (should) treat the value as a timer, but its just a suggestion, so it may play whatever sgames it wants with the TTL value!
Resilience Engineering
Replication is a coarse response to resilience - can we do this better?
Anycast
• Use the routing system to determine “closest” instance
• Service instances can be added or removed seamlessly
• Relieves the client of the overheads of serial enumeration
• Anycast Recusive Resolvers
• Multiple recursive resolver service points that all respond to the same address
• Anycast Authoritative Servers
• Multiple auth servers all on the same address
Resilience Engineering
Replication is a coarse response to resilience - can we do this better?
Parallel Resolution!
• Increase resolver capacity though the use of resolver “farms”
• Common front end / query distributor
• Collection of resolver engines to form the back end
query
distribution
resolver
farm
Resilience Engineering query
distribution
Resolver “farms”:
• How to distribute queries across the back end systems?
• IP 5-tuple hash (possibly router-based)
• IP source hash
• DNS Qname hash
• Hot caching (unbalanced engine load)
• Cache coherency in ”farms”
• Qname hashing is effective for positive caches, but not NSEC caches
• IP source hashing is less efficient than 5-tuple hashing, but is coherent for caching
• Shared caches across the resolver farm can create cache coherency irrespective of
the query distribution mechanism, but are challenging to implement efficiently
On to part 3…
DNS Deep Dive, IETF 108
• Stub resolver - what ships with every OS, different for every OS
• Forwarder - most commonly found in home routers
• Recursive resolver software - the hardest part of DNS software
• Authoritative servers - the source of the data
• All-in-one
Stub resolvers (API)
DNS Root
www.example.com?
TLD servers
www.example.com?
ISP DNS1
ISP DNS2
www.example.com?
• As things evolve we may see other APIs or API-like forms for DNS
transactions
• e.g. DNS Over HTTP, is currently a way of transporting DNS over HTTPS
but if you look at it with web app developer eyes, it is pretty much on the
way to an API
Forwarders
DNS Root
www.example.com?
TLD servers
www.example.com?
ISP DNS1
ISP DNS2
www.example.com?
• Forwarders fall in between stubs and recursive resolvers, both from a network
topology and a functionality point of view.
• They have some features typical of recursive resolvers such as a local cache
but do not perform the recursive lookups against authoritative servers, they
“forward” the queries they get to a full-service recursive resolver that
performs the heavy duty work.
Forwarder implementations
• dnsmasq
• by far the most common version of DNS forwarder, with various versions, of
very diverse vintage, in use in the wild
DNS Root
www.example.com?
TLD servers
www.example.com?
ISP DNS1
ISP DNS2
www.example.com?
• Even though today installing and running a local (to your device) recursive server is not a
difficult task (at least for non-mobile devices), most people just use what is provided by
the network configuration (DHCP, etc) and don’t bother with actual software deployment.
• ISPs and enterprises tend to use a mix of Open Source and proprietary software in their
services.
• An increasing trend is the use of “Public Open Resolvers” where users or network
administrators change their network configuration so that applications send queries to
well-known servers on the Internet
• A lot of these feeds are proprietary, at least one option has been put to the
IETF (DNS RPZ)
Recursive resolver implementations
Open source
DNS Root
www.example.com?
TLD servers
www.example.com?
ISP DNS1
ISP DNS2
www.example.com?
• In principle these are straightforward: Load zone file and answer requests
• Life is never so simple, especially in such a long-lived protocol
• Years of evolution have led to heaps of configuration options and tunable
behaviour
• Just like for resolvers most DNS software has been Open Source software
• BIND 9
• NSD
• Knot DNS
• PowerDNS Authoritative server
Authoritative servers
Closed source
• Akamai (ex-nominum)
• Secure64
• Microsoft DNS: mostly relevant in networks where Active Directory is used as
it supports the required (extended) GSS-TSIG mechanism, based on RFC
2078
• Infoblox
Additional bits and pieces
DNS “load balancers”