DNS
DNS introduction
DNS, or Domain Name System, is a system used to translate human-readable domain names (e.g., www.designgurus.com) into IP addresses (e.g., 198.47.25.1) that computers can understand. This translation process is crucial because computers and networking devices rely on IP addresses to identify and communicate with each other on the internet. In simple terms, DNS acts like a phonebook for the internet, allowing users to access websites using easy-to-remember domain names instead of having to memorize numeric IP addresses.
The primary purpose of DNS is to make it easier for people to access websites and other online resources. By providing a human-readable naming system for computers and other devices connected to the internet, DNS enables users to navigate the internet using familiar and intuitive domain names.
DNS is essential for the smooth functioning of the internet. Some of its key benefits include:
- User-friendliness
- Domain names are easier to remember and type than IP addresses, which are long strings of numbers.
- Scalability
- DNS is a distributed and hierarchical system, allowing it to handle the ever-growing number of domain names and IP addresses on the internet.
- Flexibility
- DNS allows websites to change their IP addresses without affecting users. When a website's IP address changes, the DNS records are updated, and users can continue accessing the site using the same domain name.
- Load balancing
- DNS can distribute user requests across multiple servers, improving the performance and reliability of websites.
DNS terminology
-
Domain names
- A domain name is a human-readable address used to access a website or other resources on the internet. It consists of a series of character strings separated by dots, such as www.example.com. Domain names are easier to remember and use than IP addresses.
-
TLDs (Top-Level Domains)
- A top-level domain (TLD) is the rightmost part of a domain name, such as ".com" in www.example.com. TLDs are managed by various organizations and can be divided into two categories: generic TLDs (gTLDs), like .com, .org, or .net, and country-code TLDs (ccTLDs), which represent specific countries or territories, like .us for the United States or .uk for the United Kingdom.
-
Subdomains
- A subdomain is a subdivision of a domain name, allowing the creation of separate sections or areas within a website. Subdomains appear to the left of the main domain name, such as blog.example.com, where "blog" is the subdomain of example.com.
-
Root servers
- Root servers are the highest level of DNS servers and are responsible for directing queries to the appropriate TLD servers. There are 13 root server clusters worldwide, managed by various organizations, each having multiple servers for redundancy and reliability.
-
TLD servers
- TLD servers store information about domain names within their specific TLD. When they receive a query, they direct it to the appropriate authoritative name server responsible for that domain.
-
Authoritative name servers
- These servers hold the actual DNS records for a domain, including its IP address and other information. They provide the final answer to DNS queries, allowing users to access the desired website or resource.
-
DNS resolvers
- Also known as recursive resolvers, DNS resolvers are usually provided by internet service providers (ISPs) or other organizations. They act as intermediaries between users and DNS servers, receiving DNS queries from users and sending them to the appropriate DNS servers to be resolved. Once the resolver receives the answer, it caches the information and returns it to the user.
-
Caching resolver
- A caching resolver stores previously resolved queries in its cache, speeding up the resolution process for future requests. If the requested information is available in the cache, the caching resolver returns the answer directly without contacting other DNS servers.
-
Forwarding resolver
- A forwarding resolver forwards DNS queries to another resolver, which is typically a caching resolver, instead of contacting DNS servers directly. This setup allows for better control, security, and performance.
DNS process
DNS translates human-readable domain names into machine-readable IP addresses. This translation process, known as DNS resolution, enables users to access websites and online services using easy-to-remember domain names instead of having to memorize complex numerical IP addresses. The DNS resolution process involves a series of recursive and iterative queries, utilizing a distributed and hierarchical infrastructure of DNS servers, resolvers, and caching mechanisms.
Recursive vs iterative DNS queries
DNS resolution is the process of converting a domain name into its corresponding IP address. There are two types of DNS queries involved in this process: recursive and iterative queries.
-
Recursive query
- In a recursive query, the DNS resolver asks for the complete answer to a query from the DNS server. If the server has the answer, it responds with the required information. If not, the server takes responsibility for contacting other DNS servers to find the answer and then returns it to the resolver. Recursive queries put more responsibility on the DNS server to find the requested information.
-
Iterative query
- In an iterative query, the DNS resolver asks the DNS server for the best answer it has at the moment. If the server doesn't have the complete answer, it responds with a referral to another server that might have more information. The resolver then contacts that server with a new iterative query, repeating the process until it finds the complete answer. In iterative queries, the resolver takes on more responsibility for finding the requested information.
DNS caching and TTL
To speed up the DNS resolution process, resolvers and servers cache the results of previous queries. When a resolver receives a query, it first checks its cache to see if the answer is already available. If it finds the cached information, it returns the answer without contacting other servers, saving time and reducing network traffic.
Each DNS record has an associated Time To Live (TTL) value, which specifies how long the record should be stored in the cache. TTL is measured in seconds, and once the TTL expires, the cached information is removed to ensure that outdated information is not used.
Negative caching
Negative caching is the process of caching the non-existence of a DNS record. When a resolver receives a query for a non-existent domain or record, it caches this information as a negative response, preventing repeated queries for the same non-existent resource. This reduces the load on DNS servers and improves overall performance.
In short, the DNS resolution process involves converting a domain name into its corresponding IP address using recursive and iterative queries. Resolvers and servers cache the results of previous queries to speed up the resolution process, with TTL values determining how long the records are stored. Negative caching helps improve performance by caching the non-existence of DNS records.
DNS load balancing
The Domain Name System (DNS) plays a critical role in the smooth functioning of the internet, translating human-readable domain names into IP addresses that computers can understand. As the number of users and services on the internet continues to grow, ensuring the performance, reliability, and availability of DNS becomes increasingly important. DNS load balancing and high availability techniques, such as round-robin DNS, geographically distributed servers, anycast routing, and Content Delivery Networks (CDNs), help distribute the load among multiple servers, reduce latency for end-users, and maintain uninterrupted service, even in the face of server failures or network outages.
Round robin DNS
Round-robin DNS is a simple load balancing technique in which multiple IP addresses are associated with a single domain name. When a resolver queries the domain name, the DNS server responds with one of the available IP addresses, rotating through them in a round-robin fashion. This distributes the load among multiple servers or resources, improving the performance and availability of the website or service.
However, round-robin DNS does not take into account the actual load on each server or the geographic location of the client, which can lead to uneven load distribution or increased latency in some cases.
Geographically distributed DNS servers
To improve the performance and availability of DNS services, operators can deploy DNS servers in multiple geographic locations. By distributing DNS servers across different regions, they can provide faster and more reliable DNS resolution for users located closer to a server.
Geographically distributed servers also offer increased redundancy, reducing the impact of server failures or network outages. If one server becomes unreachable, users can still access the service through other available servers in different locations.
Anycast routing
Anycast routing is a networking technique that allows multiple servers to share the same IP address. When a resolver sends a query to an anycast IP address, the network routes the query to the nearest server, based on factors like network latency and server availability.
Anycast provides several benefits for DNS:
- Load balancing
- Anycast distributes DNS queries among multiple servers, preventing any single server from becoming a bottleneck.
- Reduced latency
- By directing users to the nearest server, anycast can significantly reduce the time it takes for DNS resolution.
- High availability
- If a server fails or becomes unreachable, anycast automatically redirects queries to the next closest server, ensuring uninterrupted service.
CDN and DNS
A Content Delivery Network (CDN) is a network of distributed servers that cache and deliver web content to users based on their geographic location. CDNs help improve the performance, reliability, and security of websites and web services by distributing the load among multiple servers and serving content from the server closest to the user.
DNS plays a crucial role in the functioning of CDNs. When a user requests content from a website using a CDN, the CDN's DNS server determines the best server to deliver the content based on the user's location and other factors. The DNS server then responds with the IP address of the chosen server, allowing the user to access the content quickly and efficiently.