DNS 101 For Web Developers
Tags: dns, webdev, tutorial, deployment
Published: 2019-09-25 20:07:43

As web developers, DNS is one of the least understood aspects of the internet. It's also one of the most important, as it's the glue that links your domain name (yourwebsite.com) to your website that's hosted on a web server.

### DNS stands for Domain Name Service

What we are talking about here is the ability for people who are browsing the internet at your web address to be directed the IP Address of the server that is hosting your website.  It connects the Domain Name, to the IP Address.  An IP Address is a series of 4 numbers between 0 and 255 that each web host should be able to give you.

There are a few different ways that we can achieve this.

### The "A" Record

This is the most basic type of record. It says point this address (yoursite.com) to this IP Address (1.1.1.1).

For each top-level domain you should have 1 A Record. That should be used to connect your top-level website address to your web hosting IP Address.

yoursite.com	1.1.1.1

Resist the temptation to create A records for all your subdomains (www.yoursite.com, blog.yoursite.com, files.yoursite.com).  That way lies madness! Why?  If you ever move web hosts, you don't want to have to change all these A records!

We can use a different method for those.

### The "CName" Record

A CName points one web address (www.yoursite.com) to another one (yoursite.com).  The most common usage of this is to send traffic from your subdomains (eg: www.yoursite.com) to your top-level domain (yoursite.com).

www mysite.com.

Many tools use the @ symbol to represent your top-level domain.

www @

In other situations, you need to point a subdomain (eg: files.yoursite.com) to another address given to you be an address given to you by online service, such as Netlify, Cloudflare, or Azure CDN.

www xyz.netlify.com.

Notice that some DNS providers _require_ you to add the dot (.) after the address you are pointing other, otherwise they will create a link between subdomains (www.yoursite.com -> xyz.netlify.com.yoursite.com) which is not what you want.

### The "TXT" Record

Normally, a TXT record is used to verify that you own a domain.  You will be asked to put a unique identifier your TXT record that is provided by the service.

### Other DNS Record Types

There a many other DNS record types (MX, SPF, etc.)  As a web developer you probably won't need to work with those very often.  If you do, let me know in the comment.

## Name Servers

DNS Records can be hosted separately from your actual DNS name.  They are hosted by your Name Servers.  There are usually 2, sometimes 3 of these to provide redundancy.  When you setup using some hosting services, they will ask you to point to their name servers.  That way they can help you with common settings for their service.

This can become confusing if you've setup all your DNS records in one spot, but have indicated on your actual DNS host to point to name servers - so be sure to document that somewhere.

## Diagnostics

This is getting beyond the scope of this article, however there are a view tools you can use to check what the DNS settings are for a particular domain name.

Use ping to check A record (IP Address) or CName
```shell
ping www.yoursite.com
```

Online tools such as [dnschecker.org](https://dnschecker.org) can also tell you where your DNS settings have been propagated to worldwide.

---
I hope you find this helpful!