Domain Name System

Understand how the Domain Name System works.

We'll cover the following

Every device connected to the internet has its unique IP addressIP address is short for Internet Protocol address. It is a unique numerical label assigned to each device connected to a computer network. IP addresses can be either IPv4 (32-bit) or IPv6 (128-bit)., enabling communication with it. When we browse the internet, we access web applications hosted on servers, each identified by a distinct IP address. For instance, consider the case of educative.io. If we assume that the content of educative.io is stored on a server with the IP address 104.18.2.119., then educative.io is a domain name that directs users to this server. We can access the same content using the educative.io domain name or the server’s IP address.

Press + to interact
Users accessing educative.io
Users accessing educative.io

The Domain Name System (DNS) is a hierarchical decentralized naming system that translates human-readable domain names, such as educative.io, into IP addresses. The DNS organizes domain names into a hierarchical tree-like structure:

  • At the top are root domain servers, the highest authority in DNS.

  • Below are top-level domainsTop-level domains (TLDs) are the last part of website addresses, like ".com" or ".org." They categorize websites into groups based on their purpose or location. There are three main types: generic (for everyone), country-specific, and special-purpose TLDs. Knowing TLDs helps us identify different types of websites on the internet. (TLDs) like .com and country-code TLDs. Each TLD is managed by its registryA registry is a company that sells domain registrations for one or more top-level domains, such as `.com`..

  • Second-level domains (SLDs) sit beneath TLDs and often represent organizations. Subdomains can extend from SLDs.

DNS resolves domain names to IP addresses by traversing this hierarchy from root servers to authoritative name serversServers that help translate domain names into the IP addresses, which computers use to communicate with one another. Name servers are either recursive name servers (also known as  DNS resolver ) or  authoritative name server.. This setup ensures efficient domain name resolution on the internet.

Press + to interact
DNS hierarchy
DNS hierarchy

Domain name system is distributed globally over numerous servers, this approach provides high availability and scalability.

DNS zone

A DNS zone is a portion of the DNS namespace that a specific organization or administrator manages. It typically corresponds to a specific domain name or a subdomain that allows more granular control of DNS components, such as authoritative name servers.

Let us try to understand zones using educative.io, which is a learning platform. Within the DNS hierarchy, we can identify three distinct zones that encapsulate different aspects of the platform: learning, community, and careers. Each zone represents a logical grouping of related resources and services within the educative.io domain. For instance,

  • The learning zone encompasses educational content and resources, including two subdomains: courses and cloud labs.

  • The community zone focuses on interactive elements organized under the respective subdomains, such as blogs and discussion forums.

  • Finally, the careers zone may feature job listings, career-related articles, and other professional development resources tailored to the platform’s audience.

Press + to interact
DNS zones
DNS zones

By setting up these zones, educative.io efficiently arranges its website, making it easier for users to find the content they need. Each zone acts like a separate section with its own set of web pages. This organization ensures that when users visit educative.io, they can quickly access the right information without getting lost. Behind the scenes, authoritative servers manage each zone, directing users to the correct pages when they type in a web address.

The authoritative servers host the zone file, which is a text file. The zone file also contains the DNS recordsA DNS record is a data entry stored in a DNS server's database that maps domain names to specific information or resources associated with those domain names. DNS records are essential components of the Domain Name System (DNS) and play a crucial role in DNS resolution. to map domain names to corresponding IP addresses. The following table displays various types of DNS records along with their respective functions.

DNS Records

Record Type

Value

SOA records

Provides authoritative information about a DNS zone, including details such as the primary name server for the zone, the email address of the zone administrator, and other zone management parameters.

NS records

Specifies the authoritative name servers for a domain. These servers are responsible for providing DNS information about the domain.

A records

Maps a domain name to an IPv4 address. For example, we might have an A record that maps "example.com" to "192.0.2.1".

AAAA records

Maps a domain name to an IPv6 address. For example, we might have an A record that maps "example.com" to "2001:db8:3333:4444:5555:6666:7777:8888".

CNAME records

Maps one domain name to another. For instance, we might use a CNAME record to point "www.example.com" to "example.com".

MX records

Specifies mail servers responsible for receiving email on behalf of a domain. MX records often point to mail servers like "mail.example.com".

TXT records

Stores arbitrary text information associated with a domain name. This can be used for various purposes, such as verifying domain ownership or providing SPF (Sender Policy Framework) records for email authentication.

Each DNS record has a value set to specify how long DNS resolvers and other DNS servers should cache the record before it expires and needs to be refreshed. This value is called Time-to-Live (TTL).

Press + to interact
TTL
TTL
1 of 3

In the illustration above, the authoritative server manages the DNS record for www.xyz.com and stores the corresponding endpoint’s IP address. The Time-to-Live (TTL) for this DNS record is set to 30 minutes, indicating that the stored IP address is valid for this duration. Initially, the record’s value is set to “192.9.101.2,” which remains valid for 30 minutes.

When a DNS query is made five minutes after the record is initialized, the DNS resolver responds with the initial IP address 192.9.101.2. The resolver then stores this value in its cache. At the 15-minute mark, another DNS query is resolved, and the resolver continues to respond with the same IP address.

However, the TTL for the record has expired when the last query is initiated after 35 minutes. Consequently, the DNS resolver requests the authoritative server for the updated value. The authoritative server responds with the new IP address, 172.19.10.21. The resolver updates its cache with this updated value and responds to the request with the new IP address.

DNS resolution

Let’s explore how DNS resolves the domain request for educative.io. Here, we will assume that the TLD server responds with the address of the authoritative server responsible for educative.io.

Press + to interact
Resolver and Root DNS
Resolver and Root DNS
1 of 4

Here is a brief explanation of the slides above:

  • Resolver and Root DNS: The client domain requests are forwarded to the DNS resolver. The DNS resolver then forwards the requests to the root server, and the root server responds with the TLD server address.

  • Resolver and TLD name server: The DNS resolver forwards the client request to that TLD server. The TLD server interprets the request and responds with the address of the responsible authoritative server.

  • Resolver and authoritative server: The DNS resolver receives the response from the TLD server and forwards the request to the responsible authoritative server. The authoritative server contains the Resource records and zone files for each domain. The authoritative server resolves the query and responds to the DNS resolver with the educative.io server’s IP address.

  • Response to the user: The DNS resolver provides the client with the response and stores this response in its cache memory for any possible requests that it might receive in the future. The user connects to the server to access educative.io.



Get hands-on with 1300+ tech skills courses.