A simple explanation of the Domain Name System

The Domain Name System (DNS) is a core component of the Internet as we know and use it today. It maps domain names to IP addresses. For example, the domain name google.co.za, which is easy for people to remember, translates, at the time of writing, to the IP address 64.233.179.104. IP stands for 'Internet Protocol' and it is used by the computers on the Internet to talk to one another. Importantly, it uses numbers such as 64.233.179.104 and not domain names to address the many stationary and mobile machines on the Internet.

What is their IP?

If you type the command host google.co.za into a command window, it should tell you that google.co.za has the IP address 64.233.179.104. So, pointing your browser at http://64.233.179.104 or http://google.co.za should have the same effect and, as I write this, it has.

I wrote 'should' for three reasons:

  • By the time you read this, the domain google.co.za may point at another IP address. Why? For example because the server at 64.233.179.104 is being upgraded and the domain administrator has decided that another machine with another IP address should take over its role in the meantime. This is an important and very useful function of DNS.
  • A domain name can have more than one IP address associated with it. So, although both you and I typed http://google.co.za into our browser's address field, we end up on different machines. Both machines will typically serve the same content, however for the operator of a popular website this means that the load of visitors can be distributed across multiple machines. This form of 'Load Balancing' is another useful function of DNS
  • Finally, yourdomain.co.za and mydomain.co.za could both map to the same IP address, yet two entirely different pages are shown. This is called 'Virtual Hosting' and supported by many webservers to allow one machine to serve multiple domains. This is useful if a webserver would otherwise be underutilized. If you try, in this case, to visit the IP address with your browser instead of the domain you may find that another or even no page is returned, because the webserver cannot tell without the domain name which domain's content it should serve. This is not a function of DNS but one of the server software that is installed on the machine with that IP address.

DNS is distributed

DNS works very much like a phonebook. Your computer looks up a name to find the number of the machine it wants to talk to. However, given the huge number of domain names (see http://www.domaintools.com/internet-statistics for example) and the frequency at which they are updated, it is not feasible for every computer to hold a copy of this phonebook. This was not always the case. In the early days of the Internet every computer had a copy. The 'phonebook' still exists on your machine (/etc/hosts on Linux and C:\Windows\System32\drivers\etc\hosts on Microsoft Windows) however it's mostly been made redundant by DNS. With DNS the phonebook is distributed across a large number of systems and the next section on DNS' hierarchical nature explains how.

DNS is hierarchical

The hierarchical and distributed character of DNS is best explained with an example. What happens when you try to visit www.example.co.za?

  • Your computer checks your local phonebook in the file hosts and doesn't find www.example.co.za so it decides to use DNS.
  • You computer asks the name-server of your Internet Service Provider (ISP) whether it knows the IP address of the domain www.example.co.za. The ISP's name server now reacts in one of three ways. It can say 'no', it can look up www.example.co.za for you or, in the case that it previously looked up the IP address for you or another user, it can return a cached copy. Let's assume that it does not have a cached copy but that it is prepared to look up www.example.co.za on your behalf (this is called a recursive name-server, whereas a non-recursive one would just say 'no').
  • Your ISP's name-server now asks one of the relatively few and globally known DNS root servers 'Hey, do you know the IP address of www.example.co.za?' and it is told 'No, but go and ask the server at .za, which incidentally (this is called a 'glue' record) has the IP address x.x.x.x - oh, and don't bother asking me again about domains under .za in the next x seconds (that's the expiry time), because my answer will be the same.'
  • Your ISP now asks .za and is told 'No, go and ask .co.za at x.x.x.x and don't bother asking me again about .co.za domains for the next x seconds...'
  • Now it asks .co.za 'Do you know www.example.co.za' and learns 'No, ask ns1.domain-name-registration.co.za or alternatively ns2.domain-name-registration.co.za and don't bother ...'
  • 'Hey ns1.domain-name-registration.co.za ...' - (unlikely to happen in reality but ns1 is down. :-)
  • 'Hey ns2.domain-name-registration.co.za ...' - 'Yes, my user told me in the DNS Manager that the host www of the domain example.co.za, which I am authorative for, has the following IP address ... and don't bother ...'
  • Finally, your ISP tells your computer the IP address of the machine at www.example.co.za and caches it for subsequent queries by yourself or others.

This is DNS in action and as you can see, caching is an important mechanism to lessen the burden on the overall system and on the machines close to the DNS root-servers in particular. Caching also means however, that changes to your DNS records are not immediately globally visible. This is because of the expiry time, which although expressed in seconds can be anything up to days in length. Changes are propagated through the system gradually.

DNS record types

I haven't actually looked at a phonebook in a while but the ones I remember didn't just map names to phone-numbers. They also mapped name to address and sometimes name to FAX number. Clearly a postal address is a different type of record from that of a phone number. Similarly DNS doesn't just map names to IP addresses but also names to different types on DNS records. A CNAME record (Canonical Name) for example creates an alias by mapping one name to another, such as www.example.co.za to example.co.za, with the consequence that your users can either include or omit the www to get to your site. In this context 'wildcards' are of interest. The record *.example.co.za uses a wildcard (*) and as a result tom.example.co.za, dick.example.co.za and harry.example.co.za all map to the same name.

There are also MX (Mail Exchanger, used for email), TXT (Text) and many other record types. My article on How to use the DNS Manager has more to say on this topic. For a complete list of record types visit Wikipedia at http://en.wikipedia.org/wiki/List_of_DNS_record_types.

Comments & Questions

For any comments, questions or corrections, please visit the forum. It's entirely open and does not require you to register.

Share

Tell your friends about this article and follow, if you like, cozaDomain on Twitter, for .co.za news and discounts. Thanks for reading.