Computers find each other by number. Every device on the internet has an IP address, such as 65.8.70.23, and a connection can't start without one. Nobody wants to type numbers, so the Domain Name System (DNS) translates names into numbers. It's the internet's phone book: you look up rrjamal.ca and get back the address to connect to.
DNS sits behind every link you click. It's also what you edit when you point a domain at a website, an email provider or a home server, so it's worth knowing how it works.
What happens when you type a web address
Your browser doesn't look the name up itself. It asks a resolver, a server whose job is to find answers, and the resolver does the legwork. Answers are kept for a while, so most lookups are answered from memory on your device or router, and nothing goes out at all.
The full chain only runs on a miss, when nobody nearby has the answer yet:
sequenceDiagram
participant B as Browser
participant C as Cache
participant R as Resolver<br/>(router, ISP,<br/>1.1.1.1)
participant Ro as Root
participant T as .ca
participant N as Nameservers
B->>C: rrjamal.ca?
C-->>B: not cached
B->>R: rrjamal.ca?
R->>Ro: rrjamal.ca?
Ro-->>R: ask the .ca servers
R->>T: rrjamal.ca?
T-->>R: ask these nameservers
R->>N: rrjamal.ca?
N-->>R: four addresses
R-->>B: four addresses, now cached
The resolver is usually your router, which passes questions to your ISP, or a public one such as 1.1.1.1. Each step only points onward. The root servers know who runs .ca, the .ca servers know which nameservers answer for rrjamal.ca, and those nameservers hold the actual records.
See it yourself
On macOS and Linux, dig shows the answer and the chain. On Windows, nslookup rrjamal.ca does the simple lookup.
dig rrjamal.ca
Trimmed to the answer:
;; ANSWER SECTION:
rrjamal.ca. 60 IN A 65.8.70.23
rrjamal.ca. 60 IN A 65.8.70.113
rrjamal.ca. 60 IN A 65.8.70.68
rrjamal.ca. 60 IN A 65.8.70.83
Four addresses, because this site is served by CloudFront, AWS's network of servers around the world. These are the ones near me; ask from another city and you'll get different ones. The 60 is the TTL, explained below.
dig +trace skips the resolver and walks the chain itself, starting at the root and following each referral. Trimmed to the four hops:
dig +trace rrjamal.ca
. 434183 IN NS b.root-servers.net.
...
ca. 172800 IN NS c.ca-servers.ca.
...
rrjamal.ca. 86400 IN NS ns-1787.awsdns-31.co.uk.
...
rrjamal.ca. 60 IN A 65.8.70.113
The first line is the root, the second is .ca, the third is the domain's own nameservers, and the last is the answer.
Caching and TTL
TTL stands for time to live. It's how many seconds a resolver may keep an answer before it has to ask again. This site's A records say 60 seconds, while its nameserver records say 86,400 (a day).
That's why a change takes time to spread. When you edit a record, resolvers that already hold the old answer keep giving it out until their copy expires. Nothing tells them to refresh early, so the new address appears as the old copies run out.
If you're planning a change, lower the TTL a day ahead. The old answers then expire quickly, and you can raise it again once the change is done.
The records you'll meet
| Record | What it says | Real example here |
|---|---|---|
| A | A name's IPv4 address | rrjamal.ca has four, starting 65.8.70.23 |
| AAAA | A name's IPv6 address | None: dig AAAA rrjamal.ca returns nothing |
| CNAME | A name that points to another name | None. www has its own four A records (aliases, explained below) |
| MX | Which server takes email for the domain, with a priority | 10 inbound-smtp.us-east-1.amazonaws.com. (at the time of writing) |
| TXT | Free text, used for ownership proofs and email rules | "v=spf1 include:amazonses.com ~all" (SPF, which lists who may send mail) |
| NS | Which servers answer for the domain | ns-286.awsdns-35.com. and three others |
Two notes on that table:
- A CNAME can't sit on the bare domain (
rrjamal.ca), because that name also has to hold records like NS that can't share a name with an alias. That's why DNS hosts such as Route 53 (below) have "alias" records, which work at the bare domain. - MX and TXT matter when you move email, because the MX says where mail goes and the TXT proves to the new provider that you own the domain.
Registrar against DNS host
Two companies can be involved in one domain. The registrar is where you bought the name. The DNS host runs the nameservers that answer questions about it, and it's where you edit the records. They're often the same company, but they don't have to be.
For this site, the DNS host is Route 53. The NS records end in awsdns, which is how AWS names its nameservers. You can check it yourself with dig +short NS rrjamal.ca.
What Route 53 is
Route 53 is AWS's DNS service. The name is usually explained as a nod to port 53, the port DNS answers on. You create a hosted zone for your domain, which is just the list of its records, and AWS gives the zone four nameservers spread across different top-level domains (.com, .net, .org, .co.uk), so a problem with any one of those can't take them all down. Those four are the NS records above. The registrar points the domain at them, and from then on they answer every question about rrjamal.ca.
Its most useful extra is the alias record. A normal A record holds fixed addresses. An alias points at an AWS resource instead, here this site's CloudFront distribution, and Route 53 answers with that resource's current addresses. Both rrjamal.ca and www.rrjamal.ca are aliases. That's why dig shows A records rather than a CNAME, why the addresses change depending on where you ask from, and why nothing needs editing when CloudFront moves its servers around.
It isn't free, but it's cheap: a hosted zone costs $0.50 a month, plus $0.40 per million lookups, and alias lookups to CloudFront are free. Route 53 can be your registrar too, but it doesn't have to be. Any registrar can point a domain at Route 53's nameservers.
A home connection: dynamic DNS
A home connection's public IP can change when the router reconnects. A dynamic DNS service, such as DuckDNS, gives you a fixed name like yourname.duckdns.org, and a small updater tells it whenever the address changes.
The step-by-step guide sets this up for a home server, with a free certificate. The Jellyfin story is the one where a CNAME, the router maker's nameservers and an A record got in each other's way.
When DNS goes wrong
- A typo in a value. A wrong digit still looks like an address, and the name goes nowhere. Check what's published with
dig +short A rrjamal.caand compare it with what you meant. - A change that isn't showing yet. An old answer stays in caches until its TTL runs out. Run
dig +noall +answer rrjamal.catwice: the TTL falls on the cached copy, and the new value appears when it reaches zero. - The wrong nameservers at the registrar. Your records can be right and still not be used, if the registrar points at other nameservers. Compare
dig +short NS rrjamal.cawith what your DNS host lists. - A missing record type. Without an MX record, mail to the domain has nowhere to go.
dig +short MX example.comprints nothing when a domain has no mail server. The same goes for AAAA, which is what makes a name reachable over IPv6.
What's next
Once a name points at a server, the next question is whether it's the right server. That's what certificates answer. What is an SSL certificate? explains the padlock, and How HTTPS certificates work, and who does what follows one through a home server's setup.
