Simple and subtle: The Joy of DNS
In the first of a two-part series, Geoff Meads explores the history of the domain name system (DNS) and how it simplified the process of using the internet.
Back in the early days of the internet, when we all read books and watched regular broadcast television, it was really hard to get access to services like websites and email. This was because the IPv4 addresses we all know about (e.g. 22.214.171.124) were the only thing we could use to navigate to the services we needed. In short, it was like having to dial a telephone number to get to your chosen service and you needed a telephone directory to find the right number in the first place.
Fortunately, in the mid to late 1980s, a new internet service arrived called the Domain Name System or ‘DNS’.
DNS was initially conceptualised by a graduate named Paul Mockapetris who proposed a formal register of plain text names for each service that could be automatically translated by an external service to the equivalent IP address.
This simplifies things immensely. You type in a domain name, say ‘facebook.com’ and the DNS service tells your device ‘ah, the IP address you need is 126.96.36.199’. Your device can then contact that service without you ever needing to know the IP address. Brilliant!
To enable visitors’ access to an online service you provide (like your website or your email) you first need to obtain a domain for them to use. In the early days of DNS, domains were free of charge. With rising popularity, it became necessary to charge for domains so that an organisation could be formed to add some control. That organisation is called the Internet Corporation for Assigned Names and Numbers or ‘ICANN’ and they now control the use of domains and IP addresses globally.
A domain name consists of three components with each part representing a smaller division of the entire domain scope as you read from right to left (i.e. backwards…). Let’s take ‘www.facebook.com’ as an example:
‘.com’ – the Top-Level Domain or ‘TLD’ which contains hundreds of thousands of domains
‘facebook’ – the domain itself, a subdivision of the .com TLD
‘www’ – the website subdomain within the facebook.com domain
To put it another way, www.facebook.com is the website subdomain of the facebook domain within the .com TLD.
Because of this relationship, when you purchase ‘mydomain.com’ you buy all of the possible subdomains within ‘mydomain.com’. For example, you now own ‘www.mydomain.com’ for your website and ‘mx.mydomain.com’ for your email service automatically.
Note that when you buy ‘mydomain.com’, you have only purchased a domain within the ‘.com’ TLD. If you wish to also obtain ‘mydomain.net’ or ‘mydomain.org’ you will need to purchase them separately as they are within another TLD.
The good news is that you can set up as many subdomains as you like within your own domain. For example, if you are building a client portal for your customers you can locate that at portal.mydomain. com’ as, by owning ‘mydomain.com’, you automatically own all the subdomains beneath it.
From the above you may have already guessed that the master DNS records for your domain will contain multiple sub-records. This is useful as the IP address for your website server may well be different from your email server. For example, you might host your website on GoDaddy and your email with Gmail. Each server will have a different IP address and may even be in different parts of the world!
To get around this, each subdomain can be pointed to independent IP addresses within your DNS records.
THE DNS PROCESS
Bearing in mind your device can’t use domain names directly (as network traffic needs to use valid IP addresses at OSI layer 3 for transport) how does your device translate a domain name to an IP address? The answer is in a cascading system of DNS servers.
When your device joins the local network (LAN), it will either gain an address for DNS queries automatically or you will need to add one manually if the device is using a static IP address. Actually, the device obtains two DNS addresses, one primary and one secondary. This is in case the primary one is unavailable or busy at any point.
It is normal for the primary and secondary DNS address for a LAN device to be that of the router, for reasons we will now explain…
Let’s imagine you type ‘https://www.mydomain.com’ into your web browser. At first, the browser will look at your browsing history to see if you have visited that site before. If you have been to that site before it will have the IP address from a previous DNS lookup and will attempt to use that address to get the files for the website you asked for.
If the web browser doesn’t have the IP address it will then send a DNS lookup request to the primary DNS address it has been giving for the LAN. This is normally the IP address of the router. The router then looks to see if it has a record for the requested domain within its own cache of previous requests. If it does, then the IP address on record will be sent back to your device.
If the router doesn’t have the information needed, it will then request it from the DNS addresses it was given by the ISP when the router was first connected to the WAN. These are usually copies of the entire DNS system that are held on servers that belong to ISP.
Finally, If the ISP doesn’t have the information, then it will request it from the internet’s central DNS servers. There are hundreds of thousands of copies of the full DNS in existence on the internet to provide reliability for the system. However, this means that when you purchase a new domain, or change its records, the changes can take some time to propagate around the world and for the system to update!
There’s no doubt that, without DNS, the internet would have had a much tougher job in gaining acceptance among people like our typical customers. The mere thought of carrying a ‘telephone book’ style record around of all our favourite websites and email addresses is unthinkable. So, let’s give thanks for the miracle that is DNS and all it does for us!