How DNS Works

Updated on

We’ll start with the basics of what happens when someone types a URL into a browser, reviewing what we already covered and expanding on it.

The Internet is a big network of computers. Each computer has an address (IP address) that identifies its location in the network.

Websites live on computers. When your computer wants to read a page from a website, your browser has to find the IP address of the computer where the website lives.

It’s too difficult to remember IP addresses, so we use short, memorable domain names instead.

For example, google.com is much easier to remember than 142.250.188.238.

Another benefit of using domain names instead of IP addresses to refer to websites is that domain names aren’t locked into one specific machine. If there is a problem with the computer located at one IP address, a domain name can be pointed at a different IP address to avoid downtime.

A illustration representing a network of people online

When you visit a URL in your Web browser, the browser uses DNS (the Domain Name System) to look up the domain name and find the IP address where the website currently lives. The browser can then send its request to the computer at that IP address.

A DNS lookup for google.com

In earlier sections we looked at how to manually look up a website’s IP address. The browser is querying the same system to find the IP address.

How to Configure a Website’s Nameservers

When creating a website, there are two important steps:

  1. Register a domain name from a registrar. Some hosting services also let you borrow a subdomain to point at your server.
  2. Get some Web hosting from a hosting company.

In this section we’ll go over how they fit together.

Nameservers

When you register a domain name with a registrar (like Gandi.net), you designate nameservers for the domain.

The registrar will typically have the domain pointing to their own nameservers. You can manage the DNS settings there or choose to point the domain to external nameservers. For example, I use Cloudflare to manage my DNS records, so I pointed this codingforseo.com domain at two of Cloudflare’s nameservers:

Name Server: ALEX.NS.CLOUDFLARE.COM
Name Server: MAY.NS.CLOUDFLARE.COM

Cloudflare then manages the details of the domain’s settings even though the domain is registered with Gandi.

DNS Records

Then, in the Cloudflare dashboard, I’ve set up my DNS records to point various parts of the domain to different servers.

This website is hosted on Fly.io, so when I set up Fly they gave me a couple of IP addresses along with instructions on how to enter them into the nameserver dashboard.

There are various kinds of DNS records:

Here’s a screenshot of what a typical DNS dashboard looks like. The “Type” column refers to the type of record. So, as mentioned above, the A records contain IPv4 addresses in their “Content” column, the AAAA records point to IPv6 addresses, and the CNAME records point to external subdomains. At the bottom is a TXT record that Google uses to verify ownership of the site for Google Search Console.

Entering DNS settings into the nameservers on Cloudflare.com

The IP Addresses

The IP addresses for A and AAAA records come from the hosting company. A hosting company will typically allocate some server space for you and give you an IP address(es) to add to your DNS records. You create A record for the IPv4 address and/or an AAAA record for the IPv6 address.

For now, we’re just going through a general overview. In a later tutorial we’ll walk through the complete process, step-by-step.

Takeaways

Things you should remember from this section:

Return to the main tutorial page.

Feedback and Comments

What did you think about this page? Do you have any questions, or is there anything that could be improved? You can leave a comment after clicking on an icon below.