Domain Names and DNS
Nobody wants to type 203.0.113.10 to buy a book. People remember bookshop.example, but packets only understand IP addresses. The Domain Name System (DNS) is the internet's phone book, and when a deploy "works for me but not for them", DNS is often the reason.
The rule
Names are for people; DNS turns them into addresses.
A domain name is read from right to left, from the most general part to the most specific:
exampleinapi.bookshop.exampleis the top-level domain (TLD), like.com,.orgor.in. (.exampleitself is reserved for examples like ours.)bookshop.exampleis the domain you rent every year from a registrar.api.bookshop.exampleis a subdomain. Once you own the domain, you can create as many as you like.
A domain's authoritative name server holds its records. The common ones:
| Record | Points a name at |
|---|---|
| A | an IPv4 address |
| AAAA | an IPv6 address |
| CNAME | another name (an alias) |
| MX | the mail servers for the domain |
| TXT | free text, often used to prove you own the domain |
Every record has a TTL (time to live) in seconds: how long others may cache the answer before asking again.
dig api.bookshop.example AA typical answer line reads api.bookshop.example. 300 IN A 203.0.113.10: the name, a TTL of 300 seconds, and the address.