DEV Community

Cover image for Sys-Admin for Web Devs (Intro to DNS)
Angus Allman
Angus Allman

Posted on • Edited on • Originally published at angusallman.com

Sys-Admin for Web Devs (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)

An A Record

...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 )

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

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 (a great tool for email management) or Firebase(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, Google 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.

Top comments (1)

Collapse
 
skyandsand profile image
Chris C

Hey Angus. What do you think of services like powerDNS? was just reading a bit of their blog today