domain-name-system.gif

​The Domain Name System (DNS) associates a computer-readable IP address to a human-friendly domain name.

Overview

Communication using the Internet Protocol (IP) requires each endpoint to be identified by a numeric IP address. IP addresses are needed to actually deliver a message to a receiver, just like a numeric phone number is required to place a call.

In the early days of the Internet, entries were added to a “hosts file” that resided on a computer that associated a human-readable name to an IP. A user could access a site using the name in the hosts file instead of the IP address.

The domain name system is a distributed way to share these name-to-IP associations instead of requiring each computer to synchronize a hosts file. A name server publishes the IP address for a domain and provides a single location to update when an IP changes.

How DNS Works

Domain names are issued by registrars and name servers provide the details about which IP is associated with the domain. Domain registrations are valid for 1 to 10 years and registrars typically provide name servers to their customers as well. (Some developers may choose to run their own name servers for greater control.)

Here’s a step-by-step description of how DNS works:

  1. A user enters a URL like www.example.com in their browser.
  2. The computer performs a DNS request to resolve example.com to an actual IP address.
  3. The DNS request starts with a set of authoritative name servers and determines if any have the name server for example.com. Name servers have separate “zones of authority” and the request may be routed to a different zone.
  4. The computer follows the hierarchy until it eventually reaches the name server for example.com. For a web request, the computer requests the record for “www” and receives the associated IP address (10.20.30.40).
  5. Using this IP address the computer can communicate with the server and load the content of http://www.example.com.

DNS Record Types

A Records

Instead of performing a full DNS lookup on every request, a computer may cache the results for a time period defined by the name server. A typical DNS entry looks like this:

www.example.com A 3600 10.20.30.40

This entry indicates that the result should be cached for 3600 seconds (1 hour). Administrators will often change the timeout value to a low number (minutes) before they change an IP address.

CNAME Records

There are several other record types in addition to the A record. CNAME records let you point one domain name to another. Eventually the chain of CNAME records is resolved by an A record that points to an actual IP address.

MX and TXT Records

MX records are used to set the IP address of the email server (usually different from the web server) and TXT records are used for informational purposes such as verifying ownership of a domain.

Example of DNS

DNS is a backbone technology for the Internet and is especially relevant when setting up or configuring a server infrastructure. When purchasing a new domain, the registrar will often ask for the IP address of your server to be added to their name servers, or allow you to use your own name servers.

Most CDNs ask you to create a new DNS entry on your domain that points to the CDN. This makes it easy to load assets from the CDN using your own domain. Similarly, Platform-as-a-Service providers like Heroku let you point your domains to their servers so you can keep your domain brand while using their hosted infrastructure.

Benefits of DNS

  1. Users get a friendly domain name instead of the IP address required by the computer
  2. Developers can change servers without a disruption to users since IP addresses are looked up dynamically
  3. Developers can improve performance by configuring their domains to use CDNs or cloud-hosted environments instead of their own servers

Conclusion

A domain name is the entry point to an online service and knowing how they work is crucial to integrating with external services. Content delivery networks like StackPath have DNS setup instructions to provide users with a fast, branded online experience.

Start 15-day Trial

Every Secure Content Delivery Plan includes WAF and DDoS mitigation.

Choose plan