How does DNS work?

In a general sense, it’s what tells your computer that www.a_website_address.com is attached to an IP address, so that you can get to it by typing www.a_website_address.com in your web browser instead of the IP address itself. You can live a long time without knowing anything about DNS and, in a perfect world, that’s how it should be, just as you don’t have to know the mix of fuel to oxygen that your carburettor delivers to let your car engine run. But it’s not a perfect world not quite yet and so there are times particularly as a moderate user, that you’ll need to know a bit, or a lot, about DNS.

The players in the DNS architecture

Strictly speaking, DNS (Domain Name Service) is the architecture for mapping IP addresses to hostnames. Unfortunately, sloppiness, slang, and jargon have usurped the term to mean everything from the architecture to the software that implements the architecture to the database that holds the actual hostname IP address mappings. There are several players involved in the architecture the DNS database, a DNS server, and a DNS client. The first player is the DNS database – the database where the actual mappings of hostnames and IP addresses are stored. The second player is a DNS server, the software that dishes out info from the DNS database when asked. The DNS database and the DNS server software both reside, obviously, on a DNS server machine. The DNS client is the program (in a loose sense of the word) that sits on an end user computer that does the asking of a DNS server when the end user is trying to connect to another computer.

DNS database

Each mapping is stored in a (very large) database that is distributed across a collection of special servers connected to the internet, so that only part of the database is on any one server. These servers are called DNS servers or, sometimes, DNS name servers. There are different DNS servers for different top level domains those ending in ‘.com’ are located in one database, for example, while those ending in ‘.edu’ are located in another database. When you want to access content on a_website_address.com, you’ll type that URL into your browser. Your browser looks up the IP address of a_website_address.com’s host via the appropriate DNS database. This process is called ‘resolving’ an address. If everything works (all the correct data is found), off you go, your browser is now displaying data sent from a_website_address.com’s web server software.In the early days of the internet, there were only a few DNS servers. The entire list of domain names and IP addresses was contained in a simple text file, and every computer on the internet had a copy of that text file. It was relatively easy to keep all of the copies of this text file in synchronisation. Decades later, however, things had become busier. Imagine if the tens of millions of domains on the internet were all listed in a single text file and every one of the “billions and billions” of computers on the internet had to keep an up to date copy of that enormous text file. In reality, the database is considerably more complex than this. A domain has more than just the IP address for the web server. There could be other servers involved, such as an FTP server or a mail server. There could be sub-domains (the ‘www.’ part of the URL), and additional information, such as time for updates to be checked, are also needed.

DNS server

Even after splitting up the DNS database into subsets for the various domains, it could get very crowded at each of the DNS servers if there was only one set, particularly if there was only one DNS server for .com domains! In addition, having all of the DNS information in one place would create a single point of failure that, if it did indeed fail, would bring the entire Internet to a crashing halt. As a result, the architects of the internet created the ability for multiple copies of the DNS databases to be available to users around the world. That means there are many DNS servers scattered around the internet. So when your computer tries to resolve a URL, it likely uses a copy (or ‘mirror’, or ‘slave’) of the primary DNS server for the type of domain in question, instead of going to the master copy. This system of multiple DNS servers also provides redundancy if one of them goes down, your computer can use a different DNS server instead of getting stalled. This is akin having a spare copy of the phone book at home when the master copy has disappeared somewhere in your teenager’s room.

DNS server software

DNS server software is a program running on a computer that gets queries (in the form of URLs) from folks looking for your domain and dishes out responses (in the form of IP addresses) in return, using one of those ‘worker bee’ DNS databases. Your friend ‘Bob’ hears you have a web site, www.a_website_address.com, and enters the URL into his Web browser. The Web browser looks up the DNS servers that he entered in his network card settings, and asks one of them what the IP address for your website is. If that DNS server has the mapping for www.a_website_address.com, it’ll look it up and return the IP address. In some cases, the DNS server he is using won’t have www.a_website_address.com in its own database, but it knows where to go look the server that for ‘.com’. This DNS server software program is running constantly, and is typically configured to be a ‘service’, so that it starts up when the computer is started. This is similar to a database server or web servers (both of which, interestingly enough, also lie in wait for requests from users and then dish out responses in return.) There are specific instances of DNS programs, just like there are specific instances of database servers (e.g. MySQL, PostgreSQL and Oracle) and web servers (e.g. Apache, IIS, etc.).

DNS client

The fourth player in this scheme is a DNS ‘client’. You can think of this client as a program running on your desktop (laptop) computer that fetches the IP address from a DNS server. When you enter a URL into your browser, your browser then talks to your DNS client, which then goes out onto the internet to find one of the DNS servers that were identified in the network card settings on your computer. When the DNS client gets an answer, it then returns that answer back to whoever requested it, such as the web browser. Strictly speaking, the DNS client isn’t actually a separate program on your computer, like a web browser or an email client. Instead, it’s a module or part of a larger program often the operating system that handles the work. There isn’t a separate program that can be started up and shut down. A web browser, for instance, would just ask the OS to do the lookup.

Christian Wach has written 34 articles