Despite domain names and DNS being something that everyone online uses every day, a large quantity of people don’t understand what the terms really mean. To most, DNS is just part of the background magic that keeps the Internet working. So, for this blog article I thought I’d have a go at de-mystifying this arcane technology.
Most people’s experience of domain names pretty much starts and stops with what has commonly become termed ‘web addresses’, i.e. the domain name used to get to a website. A fine example of this is vps.net. However, to get the VPS website associated with its own address, some work needs to be performed in the background. Computers on the Internet communicate using IP – Internet protocol – addresses. At the moment, that address will consist of four numbers between 0 and 255, each separated by a dot e.g. 83.170.69.14. These numbers are pretty meaningless by themselves and difficult for a human to remember. Domain names were the solution to making the Internet easier to navigate. The concept being that a domain name just maps a human-friendly name back to that IP address. So vps.net points the computer to 109.123.127.203.
Domain names are organised in a hierarchy. The highest levels are called top-level domains, and these are the last part of a domain such as .com, .net, .uk, .fr, and increasingly now things like .ninja and .photography. Second level domains are the part before the top level domain, so for example the google in google.com.
Beneath your domain name you can also use what are referred to as sub-domains. These can be whatever you like as long as they start with a letter and only contain letters and numbers, you can also have multiple levels of sub-domains. So in www.example.com, www is a subdomain of the domain example.com. By convention, people use the www sub-domain to point to their web server. Mail, smtp, imap, pop3 subdomains are used to point to mail servers. If your domain is only used on one server and that handles your website and email, then there’s no need to create multiple sub-domains for various things, and you can use a wildcard sub-domain to point traffic sent to non-existent subdomains to the same place.
Now we’ve got an idea about what domains are, let’s look at how the Domain Name System (DNS) works.
There are distributed root servers for DNS around the world. These servers store the details of domains and the nameservers that handle the DNS records for each domain. When you purchase a domain, your registrar will normally assign a pair (or more) of their nameservers to handle DNS for your domain and then update the root servers with what those nameservers are. To increase efficiency and reduce traffic, DNS servers are designed to store DNS records for the set period of time given in the record. This is called the Time To Live (TTL). The default for this is normally the recommended 24 hours, though this can be changed to pretty much anything.
When a domain lookup is performed, your computer will contact the servers it has listed as it’s DNS lookup servers, usually provided by your ISP. These will then check through the DNS records they have stored, and if they have a match and the TTL hasn’t expired, then that result will be returned. If there isn’t a match or the TTL has expired, it will then contact a root server to find the nameserver that handle your domain’s records. Once that is returned by the root server, your ISPs DNS server will then contact your domain’s nameserver to get the required record. Once that is received, it is passed back to your computer and the DNS server will store that record for the time given in the TTL.
This now leads to another area where people get confused. In the age of always-on high-speed everything many people assume that any changes they make to their DNS will be reflected instantly. Unfortunately, thanks to the nature of the system storing records for efficiency, the changes will be visible for different people at different times as the update propagates through the DNS system. A solution to this is that when you are planning to update your DNS records to make sure that you lower the TTL to a much smaller value, such as 5 minutes, a day or so before making the change so that when it is made it can propagate across the system faster. When the change is made, you can increase the TTL back to a higher value to reduce the load on your nameservers.