A brief introduction to DNS

Some technologies are technologies we take for granted. I remember my family were a little late to the game in getting connected to the internet, and it was only in 2003, when I was 14, that we actually got the internet at home.

Before that time, I essentially thought of the internet as being one technology, useful only for acquiring cheat codes for Tony Hawks Pro Skater 2 on PS1 and our dearly departed MSN Messenger.

As for how websites were loaded, it was just a given — you type in the address of a website and it loads. A website has an address, and that’s the end of it.

Of course, that’s not the end of it.

The internet of course is a collection of different technologies that work together to provide a worldwide electronic network, which can be used to send data for a whole host of other technologies, the most prevalent being the World Wide Web (serving websites over the HTTP protocol), e-mail and FTP.

There’s one technology that could easily be taken for granted, at least if you’ve not set up your own website before — DNS.

It’s the service that lets you load a website by typing a domain name into the address bar of your web browser.

It’s also the service that ensures that e-mails sent to your e-mail address are sent to the servers your mail provider has created your mailboxes on.

Students of the Complete Web Developer course and non-students alike, listen up. Here are the essential facts you need to know about DNS.

What is DNS?

DNS stands for Domain Name Service (or Domain Name System, depending on who you speak to).

It is, primarily, a system that allows a request for a domain name, or a subdomain of that domain name to be forwarded to the server that request is intended for.

Web servers themselves are not accessible purely through a domain name. The internet is a network based on a protocol (standardised set of rules) called IP (Internet Protocol).

Any device that connects to the internet, or a smaller private network, such as your home network, will use IP to connect. Each device can only connect if it has an IP address.

IP addresses consist of four sets of numbers, which can range from 1 to 255, separated by dots.

For example:

216.58.210.78

This is actually the IP address of the server that Google.com is served from. Not quite as catchy as “google.com” though is it?

DNS means that rather than having to remember the IP address of each server when trying to request a website, an easy to remember domain name can be used instead.

How DNS works

Any software that you enter a domain name into to connect to something (for example, your web browser), will first need to use DNS to resolve the domain name you’ve requested to an IP address.

It does this through consulting nameservers. Nameservers are the servers that serve DNS records.

All (functioning) domain names are assigned nameservers, and it is on those nameservers that DNS records reside.

When you request a domain name, the DNS resolution process will first of all consult the root nameservers. The root nameservers are at the very core of the Internet’s architecture.

There are only 13 root nameserver addresses for the entire internet, which is quite amazing when you consider the number of devices that rely on DNS each day.

When a request for a domain, e.g. google.com, arrives at one of the root nameservers, it will look up the records for “com”, which is the top level domain of google.com.

They will find records that then delegate DNS duties for all .com domain names. These .com nameservers are then consulted to find DNS records for “google.com”.

The nameservers that are returned for “google.com” will contain more information beyond a simple delegation record. They will contain the DNS records that specify what server a request for “google.com” should be sent to.

At this point, the DNS resolution process has completed, and the address that is resolved is the one that your browser will then send the request for the Google website to. That server will then respond to the request by sending the website.

Types of DNS record

Most people typically only encounter four, or possibly five types of DNS record when configuring DNS. These are those records:

The A Record

A records are named as such because they are the key records that resolve directly to an IP address.

This record will always need to be at the end of any chain of DNS resolution where an IP address needs to be found, as otherwise, no IP address will be found.

The CNAME Record

A CNAME record can be thought of as an alias for another hostname.

CNAME records resolve to other hostnames, and can be used for masking a URL.

For example, if you have a website published at “my-site.rubbish-free-website-builder.com”, and the domain name “my-site.com”, you could create a CNAME record for my-site.com to resolve to “my-site.rubbish-free-website-builder.com”, so that my-site.com loads that site.

Remember though that CNAME records are a little less efficient than A records, because a second DNS lookup will then need to be carried out on the address that the CNAME record resolves to.

The MX Record

MX (Mail eXchange) records define the servers that e-mails for a domain should be sent to.

They work in the same way as CNAME records, in that the hostname of a mail server must be specified. The A record for that hostname is then used to find the IP address of the mail server to be connected to.

The TXT Record

TXT records are plain text records, and unlike the prevous three types of record, don’t have the primary purpose of resolving an IP address.

The most common uses of TXT records are to add verification codes for services like Google Webmaster Tools to confirm that you are the owner of a domain, or for adding an SPF record, which specifies what mail servers are allowed to send mail on behalf of that domain.

The SRV Record

SRV records do serve the purpose of resolving to a specific server, though are rather picky in doing so. They specify what servers should be connected to for specific services that request that domain.

Services that use one technology (VOIP, for example) can be forwarded to one server, whilst services that use another (e.g. Minecraft) can be forwarded to a different one.

TL;DNR? (An easy to read summary)

In short, DNS records link domain names to the servers hosting their services.

Nameservers and DNS records are not the same thing. Nameservers serve DNS records.

The nameservers you assign a domain determine what DNS records are served based on the DNS records those nameservers contain.

 

Andy Dunn is a web developing, photo taking, blog writing Wulfrunian based in Cambridge. He can generally be found on two wheels.

Leave a Reply