Day 30/40 Days of K8s: Understanding Domain Name System(DNS) !!

❓ What is DNS?

DNS stands for Domain Name System, which is used to translate the human-readable domain names (like https://google.com) into IP addresses (like 192.168.1.1) and render the response back to the browser.

❓ Why Do We Need DNS?

Why we need this translation? Why can’t we reach out directly using google.com?

We need FQDN to reach out address or server , each server will have unique IP address and When we try to reach any server via internet we should use this IP address.

Problem: It’s impossible to remember all IP addresses for all websites and moreover these IP addresses keep changing right. So for this reason we use DNS on top of server to resolve corresponding IP address.

❓ How Does DNS Work?

  • Domain Name Resolution: When you enter a domain name (ex: www.thecloudopscommunity.org) in your web browser, your device first checks its local DNS cache to see if the IP address is already known. If not, it sends a request to a DNS server.

  • DNS Server Lookup: The DNS server then searches its own database to find the corresponding IP address for the requested domain name. If the DNS server doesn't have the information, it will forward the request to higher-level DNS servers until the IP address is found.

  • Response Delivery: Once the IP address is located, the response is sent back to the device allowing it to establish a connection with the web server and retrieve the content.

✴ Issues:

  1. What if we have billions of load requests to handle one DNS server ?

    Solution: Implement caching for optimal performance and reduced latency. This can involve multi-level caching, like:

    • DNS Caching: Stores recent DNS queries to avoid repeated lookups.

    • Browser-Level Caching: Browsers retain DNS information for previously visited sites, reducing the need for repeated DNS lookups.

    • Router-Level Caching: Routers can cache DNS queries to serve multiple devices without contacting DNS servers each time.

    • ISP Caching: Internet Service Providers can cache DNS records, improving response times for their customers.

Example of DNS Caching

When accessing a new website, the browser performs a DNS lookup to resolve the server's IP address. After the initial lookup, refreshing the page does not trigger another DNS query, as the browser retrieves the IP address from its cache. This behaviour explains browser-level caching.

✴ DNS Redundancy and Reliability

To ensure high availability and reliability, the DNS system is designed with redundancy:

  1. Root Name Servers: There are 13 root name servers that serve as the starting point for all DNS queries. These servers are owned and operated by various organizations to provide a decentralized and resilient system.

  2. Top-Level Domain (TLD) Servers: TLD servers are responsible for managing the top-level domains (ex: .com, .org, .net) and directing queries to the appropriate authoritative name servers.

  3. Authoritative Name Servers: These servers hold the actual records for a specific domain and provide the final answer to DNS queries.

    Each Root name server expose at 1 IP address but can resolve to different DNS servers, meaning internally have more servers but advertised to the same IP address (these 13 Root DNS server will act as a load balancer and balanced the load to the backend DNS servers ).

✴ DNS Record Types

Common DNS Record Types

When managing DNS settings, we will encounter various types of DNS records. Here are some of the most common ones:

  1. A Record: Maps a domain name to an IPv4 address.

  2. AAAA Record: Maps a domain name to an IPv6 address.

  3. CNAME Record: Creates an alias, allowing one domain name to point to another domain name.

  4. TXT Record: Stores text-based information(Human readable), often used for domain verification or email authentication.

  5. NS Record: Specifies the authoritative name servers for a domain.

  6. MX Record: Defines the mail server responsible for accepting email messages for a domain.

Troubleshooting DNS Issues

When facing DNS-related problems, we can use the following troubleshooting steps:

Checking Local DNS Configuration

  1. Linux/macOS:Look at the /etc/hosts file, which has local DNS records. If there's an A record in this file, the browser will resolve the domain to the specified IP address by default.

  2. DNS Configuration File: On Linux/macOS systems, the /etc/resolv.conf file contains the DNS server settings, indicating which DNS server is used for name resolution.

  3. Popular DNS Servers: Some well-known public DNS servers include Cloudflare (1.1.1.1) and Google DNS (8.8.8.8).

  4. nslookup: A command-line tool that allows you to perform manual DNS lookups and troubleshoot DNS-related issues.

In some cases, you may want to resolve DNS queries locally without going over the public internet. To do this, you can configure your system to use a local DNS server instead of the default DNS provided by your network or ISP.

#Kubernetes #DNS #NameServer #DNSrecords #40DaysofKubernetes #CKASeries

0
Subscribe to my newsletter

Read articles from Gopi Vivek Manne directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gopi Vivek Manne
Gopi Vivek Manne

I'm Gopi Vivek Manne, a passionate DevOps Cloud Engineer with a strong focus on AWS cloud migrations. I have expertise in a range of technologies, including AWS, Linux, Jenkins, Bitbucket, GitHub Actions, Terraform, Docker, Kubernetes, Ansible, SonarQube, JUnit, AppScan, Prometheus, Grafana, Zabbix, and container orchestration. I'm constantly learning and exploring new ways to optimize and automate workflows, and I enjoy sharing my experiences and knowledge with others in the tech community. Follow me for insights, tips, and best practices on all things DevOps and cloud engineering!