Sys-Admin for Web Devs (Intro to DNS)
Tags: dns, sysadmin, dev, ip
Published: 2019-10-23 18:56:50

---
title: Sys-Admin for Web Devs (Intro to DNS)
published: true
description: A brief guide to DNS and it’s many hit records
tags: DNS, sysadmin, dev, IP
series: Sysadmin for Web Devs
cover_image: https://assets.pcmag.com/media/images/644954-how-and-why-to-change-your-dns-server.jpg?thumb=y&width=810&height=456
canonical_url: https://angusallman.com/blog/intro-to-dns/
---

I’ve bought a domain and built a site… now what?

At some point in the process of building and deploying a site, you’ll need to dig into the dark confusing world that is DNS. DNS stands for Domain Name System (you'll usually find it in the settings of a domain which you own, possibly under Advanced DNS) and handles the translation of a URL that you type into the browser to an IP address that the computer can visit in order to load a website.

There are several different types of DNS records that you’ll more than likely encounter throughout your site deployment journey. DNS can handle translation, redirection, email and a whole host of other things but for now, I’ll just cover the most commonly used ones.

## Anatomy of a DNS Record
DNS Records are made up of 3 main parts: **type**, **host**, and **value**. _Type_ will be the name of the record and there may be a dropdown to choose it from, both _host_ and _type_ should be strings made up of letters, numbers, and punctuation. You may sometimes see an '@' symbol in the host field. This means that the _host_ is set to the domain on which you’re editing the DNS. For example, if you see an A Record which looks like the following... (Screenshots come from [Namecheap](https://www.namecheap.com))

![An A Record](https://thepracticaldev.s3.amazonaws.com/i/uwkyzik8z3b0iiw1tgtw.png)

...then it’s pointing the domain you’re editing to the IP address in the _value_ section of the record. You’ll also see that there’s a **TTL** field. This stands for Time to Live and acts as a sort of expiration date for the record and “dictates how long the **record** will be cached by resolving nameservers, browsers, etc.” ( [dnsmadeeasy.com](https://help.dnsmadeeasy.com/what-is/ttl/) )

## A Records
These are the simplest record which I’ve already kind of explained but I'll run over it again with a bit more detail.
Firstly, the 'A' stands for 'address' and according to [DNSimple](https://support.dnsimple.com/articles/a-record/)

> An A record is used to find the IP address of a computer connected to the internet from a name.  

When someone goes to a web address, the A record acts as a signpost and points the request to the IP address which is in the value of the record. To create a new A record you need to choose 'A' as the type from the dropdown and define either '@' or the subdomain name you wish you point to an IP in the _host_ and then the IP in question in the _value_ field. For example, if you have a site called myblog.com and you want a subdomain which you use for development called dev.myblog.com then you can use an A record to define it by putting "dev" into the _host_ field and adding the IP of the server where your code is into the _value_ field.

## CNAME
**CNAME** (Canonical Name) records can be used to alias one name to another. A CNAME record has to point to another domain and should never point to an IP address. If you take domain.com and www.domain.com as examples then, domain.com would have an A record that points it to an IP whereas www.domain.com would have a CNAME record with the _value_ domain.com or '@' (remember this symbol points to the domain that you are currently working with).

## TXT Records
**TXT** Records are more or less just a way to store extra data in the DNS or a domain. They allow a kind of key/value store at the domain level and are useful when using your domain with 3rd party services. Online services like [Mailgun](https://www.mailgun.com/) (a great tool for email management) or [Firebase](https://firebase.google.com/)(great for serverless app development and data storage) may ask you to add these records to your DNS to make sure that you own the domain. This way they can query the DNS and look for the TXT record that they're after.  

## MX Records
**MX** (mail exchange) records are used to tell email delivery agents where to deliver emails to. In other words, these are what you need to configure in order to be able to use a domain in an email address.
Systems like [Mailgun](https://www.mailgun.com/), [Google](https://google.com/) and other email providers talk you through the process of configuring these when you set up a new email domain.
You can supply multiple different MX records, as you can with all DNS records, but the difference here is that you can specify a priority level. The priority level means that if the MX record with the highest priority fails to send the email, then it will try the record with the next highest priority and so on. If all of them fail then the email doesn’t send.

## Conclusion
That just about does it for a quick intro to DNS and the most commonly used records. There's plenty more that can be said about DNS (most of which I don't even know yet) but at the very least I hope you've come away from this knowing more than you did when you started reading. If there are any questions or you just want to say 'hi' then leave a comment below! If you're interested in more of this content then let me know and give me a follow on twitter [@allmanajD](https://twitter.com/allmanajD).