What is DNS?

If we were driving in New York City and we wanted to get to the Empire State Building, we wouldn’t say “Let’s go to latitude 40.74844, longitude -73.98566.” We would instead say “Let’s go to 350 Fifth Ave, New York NY.” If we were using our phone to navigate, it would use a combination of GPS and turn by turn routing to get us there.

Now imagine I wanted you to visit my website. I wouldn’t say “Go to IP address 69.89.19.202” because, like GPS coordinates, it’s a number that’s really hard for us to remember and use. Instead, I would say “Go to scottbarstow.com” and, again, using a different kind of routing technology, you would arrive at my website.

Just like we use street addresses to talk about physical destinations instead of GPS, we use DNS, or the Domain Name System, to talk about destinations on the internet.

There are a few basic technologies that make up the internet that you must understand, if only at a basic level. DNS is at or near the top of the list. Why? As we talked about above, the entire internet uses DNS to figure out how to get you (and your users) to the proper destination. Having a working knowledge of DNS will lead to better understanding about how your product actually works.

As with all technology topics, you can go as deep and wide as you would like on DNS. For purposes of this article, we are going to stay very basic.

To get us started, let’s imagine we’ve decided to start a company called High Ground. The very next thing we’d probably do is go looking for a domain.

Anatomy of a Domain

A domain is made up of two parts: the domain (like scottbarstow) and the Top-Level Domain, or TLD (.com, .net, etc.). It used to be that there were only a few TLDs, but now there are more than you can keep track of, like .io, .biz, .info,  and so on. Generally speaking most people go looking for the .com TLD for their domain if they’re going to run a business. My general rule of thumb is to buy as many TLDs of your domain as you can afford and find.

New Mockup 2

Domains are managed by entities called registrars. Some of the more popular registrars are Register.com, Go Daddy, and my personal favorite Namecheap. The registrar’s job, much like a real estate registrar, is to record for all of the world to see who owns a particular domain.

Let’s say we registered the domain HighGround.io. Our registrar would then share with this with the rest of the internet. The registrar would also publish our contact information so that, in the event something happens with our domain, or someone wants to buy it, there’s a known way to reach the owner.

So far so good.

What happens when a user wants to visit HighGround.io?

Anatomy of a Request

Without getting neck deep in different protocols, generally when you browse to a particular domain, your browser makes a request and the server on the other end responds with the appropriate page, data, etc. What actually happens under the hood?

When you set up the server for HighGround.io, the service provider (be they Amazon, Digital Ocean, WordPress.com, or anyone else) most likely will give you an IP address for your server. There are instances where this isn’t the case, but for our purposes, we’ll assume you’ve gotten an IP address of 192.168.101.2 (Note: You would never be given this actual IP address, so don’t try to use it).

The IP Address is like the GPS coordinates of the internet. We wouldn’t be able to find our way around without them, but we also never want to have to remember them. Instead, we use the names and DNS. Some say DNS is like a phonebook, which is probably also an accurate analogy, but I like the map analogy better. Anyway, back to the story…

Your computer asks DNS “Where do I go to find Highground.io?” The DNS server for the domain says “Oh Oh! I know where that is! It’s at 192.168.101.2!” Using a technology called routing (just like our map), your request navigates through the internet and winds up at the IP address for the domain and says “Hey, give me the web page at this address!” Your web server says “Ok, here you go” and sends back the page for your browser to show.

Pretty neat, huh?

Now, obviously there’s a lot more to it, but that gives you the gist of how DNS makes your life easier every single day.

What About WWW?

We’ve talked about domains, and we’ve talked about how IP addresses and domains work together in DNS, but what about when you type “www.highground.io” or “mail.highground.io” into your browser? What is that “www” and “mail” at the front of the name? Those are called hosts (or sometimes subdomains). If you own the domain “highground.io”, you get to have as many hosts or subdomains as you want.

They’re all configured in your domain’s DNS settings.

Just Remember

  • DNS is one of the core building blocks of the internet. While it serves many purposes that we’ve not talked about here, one of it’s main jobs is to translate IP addresses to more friendly memorable names and keep us all sane
  • You have been using DNS all day, every day on your phone, computer and every other device, perhaps without even knowing it
  • A working knowledge of DNS will not make you more attractive to the opposite sex (except in rare circumstances), but it will help you in conversations with your development team

Your Assignment

If you’ve already registered a domain for your company, log in to your registrar and go to the DNS settings for your domain. Review all of the settings for your domain, including how your domain is pointed to various IP addresses to make each host address work correctly.

If you’re feeling saucy, add a new host record (sometimes called an A record) to your domain, something like test.yourdomain.com and point it to the same IP address as one of your main records (like www). Once you’ve saved your settings, it may take up to a day for the new entry to make it’s way around the internet. Usually it will be available within a few minutes. You can test your new host setup by going to your browser and typing “test.yourdomain.com.”

Here’s a screenshot from my setup of HighGround.io to help you out:

DNS Example

It’s worth noting that in a production setup, you might handle DNS very differently using a service like Amazon’s Route 53. However, for getting a basic understanding of how all of this works, using your registrar’s DNS should work just fine.

If you’ve got any doubts about what you’re doing, ask someone to look over your shoulder. If you make the wrong edits to your domain’s DNS,  you can temporarily take your site offline.

If you’re naturally curious and want to read more on DNS, I recommend starting with this wikipedia article.