Sub topic 1
How DNS resolution works
Prerequisites
You should be comfortable in a Linux shell and a text editor. You should know basic TCP/IP: IP addresses, ports, and the difference between UDP and TCP. You should also have installed packages and managed services with systemd.
How DNS resolution works
The Domain Name System (DNS) maps names such as www.example.com to addresses and other data. A recursive resolver answers client queries by walking the hierarchy. It asks a root server which server handles .com, asks that top-level domain (TLD) server for the name servers of example.com, and then asks those authoritative servers for the final answer. It caches each answer for the time given by its TTL.
Resource records and TTLs
A resource record (RR) is one entry in a zone file. Common types include:
| Type | Purpose | Example |
|---|---|---|
| A | IPv4 address | `www IN A 192.0.2.20` |
| NS | Authoritative name server | `IN NS ns1.example.com.` |
| MX | Mail exchanger | `IN MX 10 mail.example.com.` |
| PTR | Name for a reverse lookup | `20 IN PTR www.example.com.` |
| SOA | Zone metadata and serial | `IN SOA ns1.example.com. ...` |
The TTL (time to live) is measured in seconds. A TTL of 3600 lets caches reuse an answer for one hour. Lower the TTL before a planned change so that caches expire sooner.
Authoritative servers, recursive resolvers and forwarders
An authoritative server holds the data for a zone and answers only for that zone. A recursive resolver performs the lookup chain for clients and caches the results. A forwarder sends queries to another resolver instead of walking the hierarchy itself.
Keep these roles separate. An authoritative server that also accepts recursive queries from the internet can be abused for traffic floods.
BIND or Unbound: which one for which job
BIND (the named daemon) is a full authoritative server and can also resolve recursively. Unbound is a validating caching resolver. Use Unbound for a LAN resolver, and use BIND when you need to publish your own zones.
Installing the software and freeing port 53
DNS servers listen on port 53. On many Ubuntu systems, systemd-resolved already holds 127.0.0.53:53. Check which process is listening:
sudo ss -lntup | grep ':53 'Install the packages:
# Debian/Ubuntu
sudo apt install bind9 bind9-utils dnsutils
sudo apt install unbound
# RHEL family
sudo dnf install bind bind-utils
sudo dnf install unboundExercise
Which record type maps a name to an IPv4 address?
Show answer
The A record.