🎓 DNS Master Class

What we will cover?
  • What is DNS?
  • DNS history
  • How does DNS work?
  • How to configure DNS?
  • Types of DNS resolvers
  • Types of DNS records
  • DNS record lookup
  • TLDs
  • DNS caching
  • DNS security
  • DNS troubleshooting
  • DNS optimization
  • My DNS Setup

* in no particular order

🤔 What is DNS?

DNS: Domain Name System

DNS is a system that translates human-readable domain names into IP addresses.

📖 It's like a phonebook for the internet.

Although it's started as a system to convert names to IP addresses, it's now a distributed system of servers that store and serve DNS records.

What are DNS records?

DNS records are the data that DNS servers store and serve.

There are different types of DNS records, each with a different purpose.

The most common types of DNS records are A, AAAA, CNAME, MX, and TXT.

TypeDescription
AIPv4 address
AAAAIPv6 address
CNAMECanonical name
MXMail exchange
TXTText record

* there are a lot more types of DNS records, but these are the most common.

🤔How does DNS work?

It's a distributed sytem of servers that store and serve DNS records.

📱 -> ISP Resolver -> Root Server -> TLD Server -> Authoritative Server
        
Let's break down the parts of a domain name

www.example.com

translates to

www.example.com.

www.example.com.

The domain name is broken down into parts:

PartDescription
.The root domain
comThe top-level domain (TLD)
exampleThe domain (apex domain)
wwwThe subdomain

generally the domain name resolution is not done by the end user device, but by the recursive resolver.

the recursive resolver is responsible for resolving the domain name part by part.

The recursive resolver caches the results for a certain period of time.

The recursive resolver then returns the result to the end user device.

The end user device then uses the result to access the website.

Practical Examples

Stub Resolvers

Stub Resolvers just aggrigate and forward the requests to the recursive resolvers.

also serves local dns records like /etc/hosts, C:/Windows/System32/drivers/etc/hosts etc.

example stub resolvers

Stub ResolverOSDescription
systemd-resolvedLinuxThe default resolver on most Linux distributions.
dnsmasqLinux, MacOSHighly configurable DNS, DHCP, and TFTP server.
corednsLinux, MacOS, WindowsHighly configurable DNS server. Common in Kubernetes clusters.
mDNSResponderMacOSApple's native DNS server. Used for Bonjour and AirPlay.

Recursive Resolvers

Recursive Resolvers are the servers that resolve the domain names.

these actually query the DNS servers part by part and cache the result and return the result to the stub resolver.

DNSSEC validation happens at Recursive Resolver level.

Free recursive resolver services:

  • 8.8.8.8 by google (aka Google Public DNS)
  • 1.1.1.1 by cloudflare
  • 9.9.9.9 by quad9
  • 149.112.112.112 by OpenDNS (now part of Cisco)
  • dns.adguard.com by AdGuard

Paid recursive resolver services:

  • Cisco Umbrella
  • ControlD
  • Next DNS
  • Infoblox
  • DNS Filter

Recursive Resolver softwares:

  • bind9
  • unbound
  • powerdns recursor
  • Technitium DNS

Notable DNS forwarders:

  • AdGuard Home
  • Pi-hole
  • CoreDNS

My Previous DNS Setup at home

all devices were connected to tailscale overlay network.

all devices were using tailscale's DNS configuration.

Tailscale is configured to use AdGuard Home server hosted on my home server.

Demo

AdGuard Home is a DNS server that can be used to block ads, trackers, and other unwanted content.

Root Servers & Root Zone

Root Servers are the top-level servers that store and serve the root zone.

https://www.iana.org/domains/root/servers

root hints

root hints are the DNS records that point to the root servers.

these are hardcoded in recursive resolvers.

these are updated periodically by IANA, and most of the recursive resolvers are configured to use the latest root hints.

https://www.internic.net/domain/named.root

TLDs and TLD servers

TLDs are the top-level domains like .com, .org, .net, .in, .co.in, etc.

TLD servers are the servers that store and serve the TLD zone which contains list of all registered domains of that TLD.

Types of TLDs

  • gTLDs (Generic Top-Level Domains), example: .com, .org, .net, .dev, .app, .google, .tech, etc.
  • ccTLDs (Country Code Top-Level Domains), example: .in, .co.in, .uk, .de, .fr, etc.
  • inTLDs (Internationalized Top-Level Domains), example: .भारत, .中国, .日本, .한국, etc.
  • infrastructure TLDs, example: .arpa

DNS Governance

DNS is governed by IANA, which is a division of ICANN.

TLD server infrastructure

Story about .local TLD in my home network

Interesting Tools

https://dns.coffee/

Authoritative Servers

Authoritative Servers are the servers that store and serve the zone files for the domains.

Deligating subdomains to other servers is possible and is a common practice.

commercial authoritative hosting services

  • Google Cloud DNS
  • Amazon Route 53
  • Cloudflare DNS
  • DNSimple
  • NS1
  • etc...

self hosing software

  • bind9
  • NSD by NLnet Labs
  • powerdns
  • Technitium DNS
  • CoreDNS

My DNS setup for rka.xyz

I'm using CoreDNS as my authoritative server.

I have redundant servers in different regions and clouds for high availability.

Anycast vs Unicast DNS Servers

https://rka.xyz/blog/anycast-dns/

DNS Caching

DNS Caching is the process of storing the results of DNS queries in a cache.

DNS caching is done by the recursive resolvers and the stub resolvers.

How TTL works?

TTL is the time to live for the DNS record.

TTL is the time for which the DNS record is cached.

TTL is the maximum time for which the DNS record is cached including all levels of caching.