DNS: The Domain Name System


DNS is what allows us to type www.example.com instead of using an IP address. Think how difficult browsing the web would be if you had to remember IP addresses for all of the websites that you want to visit.

Basic DNS Process

  1. You enter a URL (including domain) into a web browser.
  2. The browser checks if you have a local entry for that domain (e.g. in /etc/hosts on Linux).
  3. If you don't have a local entry, the host queries a local or remote DNS server to find out the IP address for the server of the domain.
  4. The browser uses that IP address to exchange IP packets with the server.
  5. The IP packets sent from the server contain 'HTML' and other assets which are 'rendered' by the browser.

Hosts will usually have a file which specifies hostname - IP address pairings. This is usually checked first and then a query is made to a DNS server.

DNS servers are hierarchical so if the first server that you ask doesn’t have information for that exact domain, it will ask a more senior DNS server.

Recursive Queries

A host, acting as a DNS resolver, makes a recursive query. A recursive query is when you ask for a full answer to your query or an error but not a partial answer.

For example, if you want ‘blog.example.com’ you either want the IP address for ‘blog.example.com’ or an error message saying that it can’t be found. You don’t want the IP address for just ‘example.com’.

Iterative Queries

When you ask your DNS server to resolve an address, it will make iterative queries. Iterative DNS queries involve resolving parts of a domain name to get to the full answer.

How Recursive and Iterative DNS Queries Work

For blog.example.com

  1. Host asks their local DNS server (DNS1) for blog.example.com.
  2. DNS1 asks their ISP DNS server (DNS2) for the IP address.
  3. DNS2 asks a root DNS server where to find the '.com' TLD (Top Level Domain) DNS server (DNS3).
  4. DNS2 asks the .com TLD (Top Level Domain) name server (DNS3) where the authoritative DNS server for example.com is and gets an answer of DNS4.
  5. DNS2 asks DNS4 what the IP address for blog.example.com is.
  6. DNS2 returns the IP address to DNS1.
  7. DNS1 returns the IP address to the host.

DNS entries will be cached at different stages of this process to make lookups quicker in the future.

IANA (Internet Assigned Numbers Authority) maintains a list of the root servers. Today many people will use public DNS servers instead of relying on their ISP. For example Google's service or Cloudflare's service.

DNS Records

Common types of DNS record are given below.

A Record

Also known as a Host record, A Records map hostnames to 32 bit IPv4 addresses.

AAAA Record

AAAA records map hostnames to 128 bit IPv6 addresses.

CNAME Record

A Canonical Name (CNAME) record gives an alias for another name. A DNS lookup can then be performed against that. For example, ‘www.example.com’ might be an alias for ‘example.com’. Then if you ask for ‘www.example.com’ the DNS server will just tell you to get the IP address for ‘example.com’.


Mail eXchange (MX) records give the IP address(es) of mail servers for a given domain.

NS Record

Name Server (NS) records give the IP address(es) for the authoritative name servers that service a domain.

PTR Records

Pointer (PTR) DNS records return a name, instead of trying to find an IP address. They are most commonly used for reverse DNS lookups (trying to find a hostname from an IP address).


Learn more about this topic by checking out these references.

Other Lessons

Learn more by checking out these related lessons

How does IPv4 work?



Ping and ICMP




This lesson is part of the following courses.

Computer Networking Foundations