Let’s face it: DNS can be confusing. It can be confusing to tech professionals, and it can be downright mystifying to ordinary website owners. But it is important to at least understand the basics, especially if you plan on migrating your site from one provider to another or updating any DNS records for any reason. In this first of a series of articles on DNS, I will help you understand what it is and how it works.
IP Addresses and DNS
Computers on a network – and the internet is a giant computer network – need to communicate with one another. They do this by knowing each other’s addresses. This is not unlike how the telephone system works, or even the postal system. If I need to send information to you or request that you send information to me, I first need to know where you are. Your telephone number is your location on the telephone network, and your mailing address is your location in the postal system. Likewise, you’ll need to know my address (either telephone or postal) to send or request information from me.
With computers, it’s an IP address (IP stands for “Internet Protocol”). Most of us have seen these before – a series of numbers such as 220.127.116.11 or 18.104.22.168. Before cell phones, most people remembered perhaps a couple dozen telephone numbers for friends, family, and work, but anything beyond that required a lookup in the phone book. Computer networks can be enormous, too – the number of devices connected to the internet is estimated in the billions — and rather than having to look up addresses in the IP-equivalent of a phone book, a naming system called DNS was devised.
DNS stands for Domain Name System, and it is what allows us to attach meaningful, human-readable labels to IP addresses. These labels are called domain names. The reason you can type the domain name godaddy.com into your browser rather than 22.214.171.124 (though you can do that too), or google.com rather than 126.96.36.199 (though again you can do that too), is because of DNS.
Of course, computer networks can expand and new domain names will be added, or you might want to change the IP that a domain name refers to. In the early 1980s, a massive text file called HOSTS.TXT was maintained by the Stanford Research Institute that kept up-to-date records of names and IP addresses. Early users would need to download this file in order for names to resolve to the correct IPs.
That quickly became unfeasible. If we had to use such a file today, with its billions of entries, its size would be enormous and searching for a given record would be very long and process-intensive. We would also constantly have to be retrieving a new copy. DNS avoids this by decentralizing the “phone book.”
How DNS Works
Here is a basic explanation of how it works. Let’s suppose that your ISP (Internet Service Provider) is Comcast, and you type “webhostingsun.com” into your web browser. The problem is that your computer may not know the IP that webhostingsun.com resolves to, and there is no massive HOSTS.TXT file in which to look it up. What your computer does, in this case, is it asks Comcast’s DNS servers to give you the IP. If Comcast’s DNS servers have cached (or saved) the IP from before, they will send your computer the answer and you are on your merry way. If they haven’t, then they will perform a series of steps:
- Send a query to the root name servers. The root name servers don’t know the IP that you want, but they know the name servers for top-level domains (or TLDs), which in this case is .com. There are 13 root name servers in the world, and they act as traffic directors of sorts: if you are looking for the IP of a .com domain name, go this way; if you are looking for the IP of a .net domain, go that way. In our example, the root name servers answer with the name servers that are responsible for .com.
Send a query to the TLD name servers. The TLD name servers also don’t know the IP that you want, but they do know the name servers for individual .com domain names. In our case, the TLD name servers answer with the authoritative name servers for webhostingsun.com, which are ns1.inetsun.net and ns2.inetsun.net.
- Send a query to the authoritative name servers. Authoritative name servers store the DNS records for a given domain. In our case, they answer with the A record for webhostingsun.com: 188.8.131.52.
- Store the A record in the cache for a certain period of time, so that the next time someone requests the IP of webhostingsun.com, the answer can be given without having to go through steps 1 – 3.
- Sends a reply to your computer that the IP for webhostingsun.com is 184.108.40.206.
Now that Comcast’s DNS servers have sent your computer the answer, your computer will then store that IP in its own cache (depending on your settings), and then supply your web browser with the answer so that you can surf to webhostingsun.com!
That is the basics of DNS. In the next article, Understanding DNS Records, I discuss several common DNS records, their usage, and their importance to you.