DNS or Domain Name System Explained Quickly
When a domain is registered, you need to somehow route visitors to your website through this domain. So how do you do that? You’re often asked to add a CNAME, A, MX, or TXT record. If you’re like me and have followed these instructions, somehow magically everything works. Your domain suddenly points to your website, your emails get into your domain registered email, and you can access the Google Search Console. But how does that actually happen? What is DNS or Domain Name System? What are DNS Records? I’ll tell you here…
What is DNS or Domain Name System?
Cloudflare describes the Domain Name System as the phonebook of the internet. It basically connects your website’s IP address to something (your domain name) easily remembered by humans. What is responsible for this task? The answer is DNS Servers. All they do is route IPs to domain names.
What are DNS Servers?
Cloudflare has a great graphic that simplifies everything:
Here I summarize:
- Client asks DNS Resolver to go to example.com
- DNS Resolver then asks Root Server for the address of a Top Level Domain (like .com or .net) server which contains that domain’s information
- Root Server Sends that information back to DNS Resolver
- DNS Resolver asks TLD Server for the IP address of the domain’s Authoritative Nameserver (this holds DNS records like CNAME)
- TLD Server sends that information back to DNS Resolver
- DNS Resolver then queries the Authoritative Nameserver for the actual IP address of the website (origin server)
- Authoritative Nameserver sends back that IP address
- DNS Resolver then sends back the origin server IP back to the client which then it uses to access the origin server.
This process is repeated once in a while, but it is usually cached by the DNS resolver. The amount of time that it remains cached is set by the DNS records that live on Authoritative Nameservers. You might have seen that time specified in a time-to-live or TTL field.
Now we don’t really need to know how any of that works. All we usually deal with are DNS Records that live on Authoritative Nameserver. So…
What are DNS Records?
Simply put, DNS Records are instructions in the form of a series of text files that live on Authoritative Nameservers that hold information about a domain including its IP address and further instructions on how to handle requests to that domain. Some are required and some are optional.
Here are the most common DNS records that you might come across:
A: Stores the IP address (IPv4) of a domain
- Short for Address
- The most basic type of record
- Maps domain name (letters) to IP (numbers)
CNAME: Forwards one domain to another domain
- Short for Canonical Name
- Must always point to a domain, not an IP
- Let’s Say
test.example.com
has a CNAME that points toexample.com
. This in effect means when Resolver asks for DNS records oftest.example.com
another round of DNS lookup is made too look forexample.com
which then would resolve because of theA
record.
MX: Directs mail to an email server
- Short for Mail Exchange
- Routes emails to the correct email server
TXT: Any arbitrary text
- Short for, you guessed it, Text
- Just holds text. For example, Google uses this TXT record to verify you own the domain before accessing Google Search Console.
NS: Stores the name server
- Short for Nameserver
- Holds the address to the authoritative server which is responsible for telling the world a domain’s IP address
This is it! The basics of Domain Name System and DNS Records. I hope now you have a better idea of what you’re doing the next time your register a domain or modify an existing one!