Computers communicate over the Internet using an addressing scheme called IP. An IP address, is a unique string of numbers, separated by full stops. However, humans tend to be terrible at remembering long strings of numbers. So, in order to make access to computers easier, a phone book of sorts was needed. A phone book that would map computer names to IP addresses; so that humans and software could easily connect to some other computer resource. In this article, we’ll explain in detail how DNS works.
Before DNS, the Internet was called ARPANET and had few connected computers to it; thus, only a HOSTS.TXT file was necessary to maintain their IP address to name mappings.
Addresses were administered manually, and changes to the mappings would need a phone call to SRI’s Network Information Center (formerly called Stanford Research Institute).
At some point, in the 80’s, to manually manage all these mappings became cumbersome and so a solution was needed. The Domain Name System came to be that solution.
What DNS is and what problems it solves.
The Domain Name System was developed to solve the pressing need of having to maintain a large list of computer names. It is implemented by a hierarchical network of servers, called “nameservers” and a communications protocol. It is also distributed by nature, which makes it resilient in cases of failure. A nameserver stores information about domain name records, and responds to queries from other servers or clients. We’ll delve into what domain name records are, later in this article. But first, let’s visit some key concepts to better understand how DNS works:
Root nameservers and their hierarchy
We’ve mentioned earlier that DNS is a hierarchical system. This hierarchy is comprised of three different levels of nameservers. The root nameservers, the Top Level Domain (TLD) ones, and the authoritative, DNS servers for everything else. There are 13 root servers for the entire Internet. These are not physical ones, as they can span into multiple machines, due to their distributed nature. They do, however, provide an authoritative answer as to which name servers are responsible for the top level domains (.com, .net, etc). These root servers contain the most updated and accurate pointers when compared to nameservers that are responsible for everything under these TLDs.
Try our Award-Winning WordPress Hosting today!
Top Level Domain nameservers
These are the nameservers that are responsible for the last part of a domain. The entity which manages most top-level domains is called the Internet Corporation for Assigned Names and Numbers (ICANN). There are various types of TLDs with the most common ones being the country codes (.uk, .nl, .us, etc). There are also some very familiar ones, like .com, .net, .gov, .edu which are called generic.
Authoritative Domain nameservers
These are nameservers that are responsible for specific domains (i.e pressidium.com). They contain their domain records and are called authoritative, not only because they hold the newest and most accurate information about a domain, but also because the domain owner has specified them as such. The authoritative nameservers are a key part to understand how DNS works.
A domain is simply a label that identifies a set of Internet resources (computers, networks, etc). It is used by people and organizations to establish their identity on the Internet.
A domain name registrar is a commercial entity that manages domains. They are authorized to perform this function by a top-level domain registry. Domains of various top-level types can be purchased by them. The domain will be linked with your personal data, thus proving ownership. Almost all site owners have used registrar services to register a domain even if they don’t know how DNS works.
Name server records
A domain, as we referred to earlier, is a label that defines a set of Internet Resources. A name server contains information about these, responding to queries from other servers or clients. These resources are organized and represented as structured text, in what is called a domain name record.
There are several types of records, but the most commonly used are the following:
- A (Address)
- CNAME (Canonical Name)
- MX (Mail exchange)
The A record, which is probably the most fundamental and widely used, is the record that maps names to IP addresses. For example, the following record:
website.com. IN A 126.96.36.199
maps the domain website.com to IP address 188.8.131.52.
Another common practice is to have multiple A records with IP mappings to the same name. This provides a basic but effective form of load balancing, since every time the nameserver is queried about that domain, it returns a different IP address.
The CNAME record is used to alias one name to another A record. This is typically used when you need to have multiple sub-domains (www, ftp, mail) to point to the same domain (the same server can be a web/ftp/email server). For example:
ftp IN CNAME website.com.
will create an ftp alias to website.com, so that when someone ftp’s to ftp.website.com, they will be redirected to website.com.
Τhere is a special relationship between DNS and email. Although, services such as ftp and the web can, in practice, function without DNS (if you can remember the IP addresses that is), email, on the other hand, cannot. Email absolutely needs DNS in order to function properly. The MX record is used to define the A record that will handle all incoming email for that domain. For example, if you want mail.website.com to handle all mail addressed to website.com you put the following:
website.com. MX 10 mail.website.com
website.com. MX 20 mail-backup.website.com
There are some additional things also going on here:
The number next to the MX string corresponds to priority. The first record defines mail.website.com with priority 10, while the second with 20. This ensures that if for some reason, mail.website.com becomes unavailable, then the 2nd entry with priority of 20 will take over.
Now let’s see how DNS works with a real-life example. When you use a computer name to connect to somewhere, anywhere, the following things happen (let’s use www.pressidium.com as an example):
- Your browser, or client software uses a software module called DNS resolver, which looks up your configured DNS server (this is usually what your ISP has set for you)
- Your ISP’s nameserver then checks whether it knows the answer, and if not, makes a call to the Root nameservers asking who is responsible for .com (since the domain is pressidium.com)
- The Root nameserver then responds with a list of the TLD nameservers for .com.
- Your ISP nameserver contacts the TLD nameservers and asks whether they know which nameserver is the authoritative one for pressidium.com.
- Finally, your ISP NS contacts the authoritative nameserver of that domain, and asks the A record for ‘www.pressidium.com’
These series of calls are called recursive, and usually there is some server-side caching involved so that your ISP nameserver probably won’t go through all that trouble.
Earlier we described the special relationship that DNS and email has. Concluding the final installment of our Internet core technologies series, we will take a look at email. Electronic mail has a rich history; it has gone through a lot of changes and has survived several competitive technologies. Even now, in our pervasive “always-on” social Internet culture, email is essential for business and communication.