DNS Crash Course
by Steven Malins
There is no cloud, there is only someone else’s computer.
DNS stands for Domain Name System and it translates domain names, for example github.io into an IP or Internet Protocol address. The IP address of github.io at time of this writing is: 185.199.110.153 The IP address points to a specific “location” on the internet. It is this address that your browser, for example Firefox, uses to look up the computer on which the website you wish to view is stored.
A Domain Name Registrar is an organization that maintains a list of who owns/controls what domain names. All registrars operate under a license granted by ICANN or the Internet Corporation for Assigned Names and Numbers. ICANN is a non-profit organization that is comprised of multiple stakeholders and is based in the US. In addition to specifying a responsible party for a domain name, the Registrar also provides a list of at least two nameservers. The nameserver is the server, computer, that stores and provides the DNS Records for a given domain name.
Almost all domain name registrars maintain their own nameservers. However, it is not uncommon for registrants, those who register/own domain names, to use name servers associated with their hosting company, a company like Cloudflare that provides caching and anti DOS services, or even operate their own nameservers in the case of larger companies. Each hostname like github.io has a DNS server that is the authoritative nameserver for the hostname. Other servers can store the DNS information for a domain name for a limited amount of time, called caching. Most modern computers do not contact the authoritative nameserver for a hostname each time it is typed into the browser. Most internet providers, like Comcast or Century Link, operate intermediate DNS servers to speed up the time it takes to translate a hostname into an IP address. Because of this, sometimes changing DNS records takes some time to take effect on all machines on the internet. This is called DNS propagation.
DNS Records
The nameserver stores a list of records for each hostname. This includes records for any subdomains, eg srmalins is the subdomain of srmalins.github.io and through the magic of github points to the same servers, that is IP addresses, as the primary domain github.io and that is how you get the page you are viewing right now. While I won’t provide a complete breakdown of the various types of DNS records, two that are commonly used are CNAME records and MX records.
CNAME
A CNAME record points a hostname to another hostname. For example if you wanted a site to be available at both www.site.tld and site.tld you could have an A record (the main type of DNS record) pointing from site.tld to the IP address of your hosting server and then a CNAME record that points from www.site.tld to site.tld
MX
MX stands for Mail eXchange and it defines what server should handle the email for a hostname. When you send email to user@example.com your email program (or likely your SMTP server) looks up the MX record for example.com to find out what server handles the mail for that email address.
A domain can have multiple MX records, and each is given a priority. Each MX server is attempted in ascending order of priority (ie a server with priority 10 is tried before a server with priority 20) until one of them responds that it can handle email for that address. This allows redundancy to ensure that email can be delivered even if one or more of the servers crash or must be taken offline for some reason.
Final Words
I’ve intentionally left out many of the complex details, including edge cases, in these explanations. The intent was to provide a high level overview, and I apologize if it lacks the depth necessary for improved precision. Most of the time DNS is something that Just Works (tm) but when things go wrong DNS can often cause insidious and hard to pin down problems.