DNS (Domain Name System): Magic and Internals

DNS (Domain Name System): Magic and Internals

What is DNS?

DNS (Domain Name System) is a hierarchical and decentralized naming system for Internet-connected resources. DNS maintains a list of domain names along with the resources, such as IP addresses, that are associated with them. The DNS (Domain Name System) is the phonebook of the Internet. Humans access information online through domain names, such as facebook.com or google.com. Web browsers interact through IP (Internet Protocol) addresses. DNS translates domain names to IP addresses so the browser can load Internet resources.

How does DNS work?

The process of DNS resolution involves converting a hostname (such as google.com) into a computer-friendly IP address (such as 192.168.1.1). An IP address is given to each device on the Internet, and that address is necessary to find the appropriate Internet device - like a street address is used to find a particular home. When a user wants to load a webpage, a translation must occur between what a user types into their web browser (google.com) and the machine-friendly address necessary to locate the google.com webpage.

In order to understand the process behind the DNS resolution, it’s important to learn about the different hardware components a DNS query must pass between. For the web browser, the DNS lookup occurs "behind the scenes" and requires no interaction from the user’s computer apart from the initial request.

Why DNS is important?

The Domain Name System (DNS) is important because it allows users to access websites and other resources on the internet without having to remember IP addresses. DNS translates domain names into IP addresses, making the internet more accessible and user-friendly.

  • Simplifies access to the Internet: DNS translates human-readable domain names (e.g., facebook.com) into machine-readable IP addresses (e.g., 174.168.100.01) making it easy for users to access websites without the need to remember such complex numerical addresses.

  • Enables scalability: As the internet grows, the DNS allows for the seamless addition of new domain names and services without disturbing existing systems. This scalability supports the rapid expansion of websites, apps, and other services.

  • Ensures Network Efficiency: By distributing the workload across multiple servers (e.g., root, TLD, and authoritative name servers), DNS reduces latency and improves the speed of resolving domain names, ensuring a smooth user experience.

  • Supports Load Balancing: DNS can direct users to different servers based on location, load, or availability, ensuring websites remain accessible even during high traffic or server outages.

  • Enables Customization and Flexibility: Businesses can use DNS to create custom subdomains (e.g., mail.google.com), redirect traffic, or implement content delivery networks (CDNs) for faster content delivery.

DNS Records: The Documentation of Internet:

DNS Record an instruction or configuration in Domain Name System(DNS) that provides information about domain, how they should behave, respond to the queries and help in finding the services associated with the domain.

Anatomy of DNS Record:

  Name: example.com
  Type: A
  Value: 93.184.216.34
  TTL: 3600

- Name: Name of the domain or sub-domain to which a particular record applies to.

- Type: Type of record it is like A, AAAA, MX, CNAME, etc.

- Value: Actual data like IP address, hostname, etc.

- TTL(Time To Live): How long a record should be cached.

Type of DNS Records you should know:

  1. A Record (Address Record):

    • These records form the foundation for routing traffic to servers and are responsible for mapping a domain to an IPv4 address.

    • E.g.: example.com → 145.1.1.12

  2. AAAA Record:

    • These records support modern web addressing and are responsible for mapping a domain to an IPv6 address.

    • E.g: example.com → 2001:0db8:85a3:0000:0000:8a2e:0370:7334

  3. CNAME Record(Canonical Name Record):

    • These records maps one domain to another domain simplifying management of domains by allowing multiple domains to a single target.

    • E.g.: www.example.com → example.com

  4. MX Record(Mail Exchange Record):

    • These records specify mail servers for receiving mails for a particular domain.

    • E.g.: example.com → mail.example.com

  5. TXT Record:

    • These records hold textual information associated with a domain, generally used for authentication and verification process.

    • E.g: SPF (Sender Policy Framework)

  6. NS Record:

  7. PT Record:

    • These records are used for mapping an IP address back to a domain (reverse DNS).

    • E.g.: 145.1.1.1 → example.com

  8. SOA Record(Start of Authority Record):

    • These records provide administrative information about a domain and are essential for DNS zone management.

    • Administrative Information Includes: Primary Name Server, Contact Email, Retry, Refresh, Expiry, TTL values, etc.

  9. SRV Record:

    • These records specify services available for a particular domain.

    • E.g. : _sip._tcp.example.com → 10 5 5060 sipserver.example.com

  10. CAA Record(Certificate Authority Authorization):

    • These records give information about Certificate Authorities that are allowed to issue certificates to the domain and are responsible for preventing unauthorized SSL certificates.

DNS Hierarchy Explained: Root to Authoritative Servers:

The DNS hierarchy is structured in a top-down fashion, starting from the root and ending at the authoritative name servers. Each level plays a distinct role in resolving domain names:

  1. Root Name Servers:

    • The root is the highest level in the DNS hierarchy. Root name servers contain information about TLD name servers. There are 13 root server clusters globally, each identified by letters (e.g., A, B, C).

Role: They direct queries to the appropriate TLD name servers.

  1. Top-Level Domain (TLD) Name Servers:

    • These servers manage domains under specific TLDs, such as .com, .org, .net, or country-code TLDs like .uk and .jp.

Role: They direct queries to the authoritative name servers for the requested domain.

  1. Authoritative Name Servers:

    • These servers store DNS records for specific domains, such as A (Address), CNAME (Canonical Name), MX (Mail Exchange), and TXT records.

Role: They provide the final answer to DNS queries by returning the IP address or other requested information.

Conclusion:

The Domain Name System is an extraordinary technology that makes the Internet accessible, efficient, and reliable. Its inner workings, often unseen, form the backbone of our digital interactions. By understanding DNS magic and internals, we gain deeper insights into the Internet’s functionality and appreciate the brilliance of this essential system.