What is DNS, and how does a name become an address?

The Domain Name System turns names people can remember into the IP addresses machines use. Every visit to a site you host on a server starts with a DNS lookup, so knowing how it works saves hours during launches and moves.

What happens when someone types a domain name?

Their device asks a recursive resolver, usually run by their internet provider, company or a public resolver service. If the answer is not cached, the resolver asks a root server where to find the top-level domain, asks the top-level domain's servers which name servers are authoritative for the domain, and finally asks those servers for the record. It returns the answer to the device and caches it for the record's time to live.

dig +trace www.example.org A
dig @1.1.1.1 www.example.org AAAA +short

The first command follows the chain from the root down, showing each referral; the second asks one public resolver directly.

What are the main record types?

TypePurposeExample value
AIPv4 address of a name203.0.113.90
AAAAIPv6 address of a name2001:db8:5a::90
CNAMEAlias to another nameshop.example.net.
MXMail servers for the domain10 mx1.example.org.
TXTFree text: SPF, DKIM, verification"v=spf1 ip4:203.0.113.90 -all"
NSAuthoritative name serversns1.example-dns.net.
CAAWhich CAs may issue certificates0 issue "letsencrypt.org; validationmethods=dns-01"
PTRReverse lookup, address to namemail.example.org.

What does TTL control?

How long resolvers may cache an answer. A TTL of 3,600 seconds means a change can take up to an hour to reach everyone who looked the name up recently. Before planned changes, such as moving a site to a new server, lower the TTL to 300 seconds a day or two in advance, make the change, then raise it again once stable. Lowering it at the moment of the change does not help, because resolvers still hold the old, long-lived answer.

Who hosts my DNS records?

Whoever runs the authoritative name servers listed for your domain at the registrar. That might be the registrar itself, a specialised DNS host or name servers you run yourself on a server. Running your own authoritative DNS needs at least two servers in different locations; most people use a DNS hosting service and point records at their servers. We do not host DNS zones; you publish records for your machine's addresses wherever your zone lives.

What is reverse DNS?

The lookup from an address back to a name, stored as PTR records in special zones controlled by whoever holds the address block. For our servers, you set the reverse name of the IPv4 in our console. Mail servers in particular need matching forward and reverse records, or receiving servers treat their mail with suspicion. IPv6 and reverse DNS on your server explains the details.

dig -x 203.0.113.90 +short
dig mail.example.org A +short

How do I check a new record has spread?

Query the authoritative servers first, which show the truth immediately, then a few public resolvers, which show what visitors see. If authoritative servers are correct but a resolver is not, the old answer is still within its TTL. Clearing your own device's cache may help locally, but other people's resolvers will update only when their cached copy expires.

dig example.org NS +noall +answer
dig @ns1.example-dns.net www.example.org A +norecurse

What are common DNS mistakes on launch day?

Forgetting the AAAA record, so IPv6 visitors reach an old server or nothing; leaving a CNAME at the zone apex, which the standard does not allow alongside other records; publishing MX records without matching A records for the mail host; and setting a long TTL before a planned move. Check the zone from outside with dig after every change, and keep the previous values written down so you can revert quickly if something goes wrong.

How is DNS protected?

DNSSEC signs records so resolvers can verify they came from the zone owner; DNS over TLS and DNS over HTTPS encrypt the path between a device and its resolver. Protect the registrar and DNS host accounts with strong passwords and a second factor, since whoever controls them controls where your visitors go. DNS poisoning covers attacks, and Dynamic DNS covers names for changing addresses.

Related pages

IPv6 and reverse DNS on your server

Configuring the IPv6 block that comes with every machine and setting the reverse DNS name of its IPv4 address from the console.

Read more

DNS poisoning

How forged DNS answers send users to the wrong server, cache poisoning against hijacking, DNSSEC validation, resolver hardening and protecting your domains.

Read more

Dynamic DNS

How dynamic DNS keeps a name pointing at an address that changes, the update protocols involved, where it helps and why a dedicated server rarely needs it.

Read more

Mail server deliverability

Keep mail from your own server out of spam folders: DNS records, reverse DNS, sending limits and a clean outbound path.

Read more

Questions and answers

What does DNS do?

It translates domain names into IP addresses and other data, such as mail servers, so that clients can find services.

How do A and AAAA records differ?

An A record holds an IPv4 address; an AAAA record holds an IPv6 address for the same kind of lookup.

Why do DNS changes take time to appear?

Resolvers cache answers for the record's TTL. Lower the TTL a day or two before planned changes.

Do you host DNS zones for my domain?

No. Keep your zone at your registrar or a DNS host and point records at your server. Reverse DNS for the IPv4 is set in our console.

How do I check what the authoritative server says?

Query it directly with dig @server name type +norecurse, which bypasses caches.