Networking and the web
What is DNS?
Definition
DNS is the internet's naming system: it translates a hostname such as example.com into the IP address a computer needs in order to open a connection.
Also known as: Domain Name System
DNS in more detail
Nothing on the network routes by name. Before a browser can fetch a page it asks a resolver for the address behind the hostname, and the resolver walks a hierarchy: root servers point to the .com servers, which point to the nameservers for example.com, which finally answer with the address. Your resolver caches each answer, so the full walk happens rarely.
A zone holds several record types, and knowing which is which saves hours. A maps a name to an IPv4 address and AAAA to IPv6. CNAME aliases one name to another and may not coexist with other records at the same name, which is why a root domain usually cannot be a CNAME and hosts offer ALIAS or ANAME instead. MX routes mail, NS delegates a zone, TXT carries verification strings along with SPF, DKIM and DMARC policies.
Every record has a TTL that tells resolvers how long to cache it. There is no such thing as DNS 'propagation' in the sense of a change spreading outward — an update is live at the authoritative server immediately, and the delay you experience is old answers ageing out of caches around the world. Lowering the TTL a day before a planned change is the standard way to shorten that tail.
DNS example
$ dig +short example.com A
203.0.113.10
$ dig example.com MX +short
10 mail.example.com.
Common records
A example.com -> 203.0.113.10
AAAA example.com -> 2001:db8::10
CNAME www -> example.com.
MX example.com -> 10 mail.example.com.
TXT example.com -> "v=spf1 include:_spf.google.com ~all"
NS example.com -> ns1.registrar.net.
TTL 300 means resolvers may reuse this answer for 5 minutes.DNS — common questions
- Why do DNS changes take time to appear?
- Because resolvers cache the previous answer for its TTL. The authoritative record changed instantly; what you are waiting for is caches worldwide to expire the old value. Reducing the TTL in advance shortens the wait.
- What is the difference between an A record and a CNAME?
- An A record points a name directly at an IPv4 address. A CNAME points a name at another name, which then has to be resolved in turn. A CNAME cannot sit alongside other records at the same name, which usually rules it out at the domain root.
- Is DNS encrypted?
- Classic DNS is plaintext UDP, so anyone on the path can see and tamper with lookups. DNS over HTTPS and DNS over TLS encrypt the query to your resolver, and DNSSEC signs answers so forged ones can be detected, though it does not encrypt them.
Keep reading
Every definition in the set is indexed A-Z in the developer glossary, and the cheat sheets cover the syntax once you know what you are looking for.
Browse the A-Z glossary