What is DNS and How Does It Work?Last Updated:
What phone numbers do you have memorized? If you wanted to call up your old childhood friend for a quick catch-up, could you just pick up the phone and punch in their number without blinking? Alternatively, if someone handed you a slip of paper with a phone number on it, would you know whom you’d be calling?
Chances are, the answer would be “No.” Unless you’ve got phenomenal memory and universal access to phone directories for every single network on the planet, there will always be a phone number you can’t readily identify, and a person whose contact details you can’t instantly recall.
You might never notice it, but you’re in a similar situation whenever you use the Internet. If not for a clever bit of technology, you’d have to flick through a vast directory just to visit your usual websites. That technology is called the Domain Name System or DNS, and it plays a crucial role in making the Internet as easy to use as it is today.
If you’ve ever wondered how DNS works, or why it seems to be such a big deal, then you’ve come to the right place.
First Things First: IP Addresses
In order to understand DNS, you’ll have to know what IP addresses are. Every device on the Internet, including the servers housing your website, has an identifying number: an IP (Internet Protocol) address. This is usually a set of figures, like 172.16.254.1 or 2001:db8:0:1234:0:567:8:1. These numbers tell your computer where to go as it navigates the vast network of the Internet. If you wanted to visit Google, for example, your browser would head to 188.8.131.52, which is Google’s IP address.
So Why Aren’t We Typing Numbers?
That’s the magic of DNS. When it comes to navigating the web, computers read and think in numbers — IP addresses. But human brains aren’t built to traffic exclusively in endless strings of numbers. Instead, we use domain names like google.com, which are easier for us to remember. DNS is what translates these human-friendly domain names into the IP addresses that computers can understand, and vice versa.
Think of the Contacts app on your phone. When calling up your neighbor, you might look for John Smith on your contacts list. But your phone can’t just beep “John Smith” out into the air; instead, it uses the records in your app to find John Smith’s phone number and establish a link with his phone.
DNS, as many people like to say, is the directory of the Internet.
Digging Into Details: Domains, DNS Records, and More
The beauty of DNS is that no one entity manages the entries in that huge directory. Instead, it works like a vast crowd-driven project. The whole system comprises numerous databases where pairs of domain names and corresponding IP addresses are compiled.
Where do those databases come from? Well, when you create a website, you have to register your chosen domain name — either with your hosting provider or with a separate domain registrar like Namecheap. This information is what forms the core of DNS databases.
Why do you even need to register? Two big reasons:
- Registration creates an entry, called your DNS records, which tells computers that the domain name you chose corresponds to your site’s IP address.
- Registration ensures that domain names are unique, so that the whole Domain Name System isn’t tied into knots by overlapping or duplicate names claimed by different websites.
But wait. You can have a myawesomesite.com and a myawesomesite.net that are completely different sites, right? Yes, and those domains can coexist without blowing up the system. The key is in those last three letters.
A Day in the Life of a Request
Those domain name endings, like .com and .net, are called Top Level Domains (TLDs). They denote large categories of domains, which make it easier for a computer to sift through the vast collection of DNS records in order to find the right entry that points to the IP address it needs. To understand the term “top level” a bit better, and to peek into the mechanism of the Domain Name System, let’s look into the typical steps in a browser request.
Here’s a quick summary diagram, courtesy of NetRegistry.com:
Step 1: Enter Coordinates
When you type a domain name into your browser, your computer actually goes to look up the corresponding IP address. This process is called DNS name resolution, and it’s done by consulting a DNS server, also known as a name server. This is just a powerful computer outfitted with special software that puts it in charge of a huge database of DNS records. Essentially, a DNS server is what maps out the correspondences between domain names and IP addresses.
Once you try to visit a website, your computer will ask your Internet Server Provider (ISP) for a DNS record. If it’s a fairly popular website or one you visit often, your computer or ISP will have the needed domain-IP address pair in the cache, which we’ll discuss more later. Otherwise, your ISP consults DNS servers.
To start with, the DNS server reads your given domain name from right to left. A .com ending, for example, tells the server to skip the records pertaining to domains under other categories like .net or .org. Think of it as a way to narrow down the field: you zero in on one category, and then you keep sifting through the entries in that category until you find the right one.
There are only a few top-level domains, though you can have millions of unique domain names or addresses grouped under each one. Consider these the supercategories of domain names: .com, .net, .org, and others are the umbrellas under which specific websites reside. That’s why myawesomesite.com AND myawesomesite.net can both be active on the Internet — they’re under different umbrellas, so computers don’t confuse them for each other when sifting through records.
Step 2: Ask A Friend
Now, the thing about the Domain Name System is that no one server has a copy of the whole thing. Instead, as mentioned earlier, you’ve got data distributed across numerous DNS servers. If the first DNS server that your computer contacts doesn’t have the records you need, it moves to step two.
That first DNS server essentially asks another DNS server if it knows what your given domain name’s corresponding IP address is. These DNS servers keep cycling through this “ask a friend” step until the right IP address is found; if, after a reasonable number of attempts, no record can be found, that’s when you’ll get an error.
Step 3: Destination Reached
Finally, once your computer gets the IP address that maps to the domain name you typed into your browser, it connects to the server/s housing your destination website and returns that website’s data to you. That’s when the website pops up on your screen.
Some websites, especially the larger ones, have multiple servers and multiple IP addresses associated with the same domain name. Some sites also change IP addresses over time. That’s another advantage of the Domain Name System: you don’t have to keep track of all these changing or associated IP addresses. You can just keep the site name in mind — say, google.com, and the system takes care of matching it with the most up-to-date IP information available.
Speeding Up: Caches
DNS name resolutions take place in fractions of a second — definitely much faster than waiting for your friend to flip through a phone book. Your computer speeds up the process even more by using caches. These are basically time-limited easy-reference entries created by multiple servers in the DNS name resolution chain.
When someone looks up a website, a cache entry can be created to make it easier to resolve similar requests in the near future. Caches, in a way, are the technological equivalent of folding down the corner of a phone book page that you consult often. This is especially useful for frequently visited or popular sites, such as google.com: Instead of going through the whole process of checking DNS records again, your computer can just check cache entries and send your browser on its way.
The Domain Name System or DNS is one of the biggest reasons why the Internet can stay so huge without losing much of its convenience. With DNS’ distributed architecture and name-to-IP mapping protocol, navigating the internet can be as easy as remembering a few simple domain names without worrying about your computer’s ability to find the corresponding websites. Of course, there’s a lot more technical detail involved when it comes to DNS, and this article only scratches the surface. We’ve given you a solid start, but watch out for our future articles if you want to dig deeper into DNS!