# DNS - Domain Name System
## What is DNS
DNS, the Domain Name System, is a hierarchical distributed naming system that translates human-readable domain names into the IP addresses that computers use to identify each other on the network. Without DNS, every person would need to remember the numeric IP address of every website and service they wanted to access. DNS acts as the phonebook of the internet, maintaining a massive distributed database of name-to-address mappings that is queried billions of times per day.
## DNS Hierarchy
DNS is organized in a hierarchical tree structure. At the very top is the root zone, represented by a single dot. Below the root are the top-level domains, such as com, org, net, edu, and country codes like in, uk, and de. Below each top-level domain are second-level domains, such as google in google.com or wikipedia in wikipedia.org. Organizations can further subdivide their domains into subdomains. Each level of the hierarchy is managed by different organizations.
## DNS Resolution Process
When a user types a domain name in a browser, a DNS resolution process begins. The operating system first checks its local DNS cache. If a recent answer is cached, it is returned immediately. If not, the query is sent to a recursive resolver, usually provided by the internet service provider or a public service like Google's 8.8.8.8. The recursive resolver checks its own cache. If a cached answer exists, it returns it. Otherwise, the resolver begins querying the DNS hierarchy.
The resolver first queries one of the 13 root name server clusters, which respond with a referral to the name servers responsible for the relevant top-level domain. The resolver then queries the top-level domain name servers, which respond with a referral to the authoritative name servers for the specific domain. Finally, the resolver queries the authoritative name servers, which return the IP address associated with the domain name. The resolver caches this answer for the duration specified by the time-to-live value in the response and returns the IP address to the client.
## DNS Record Types
A records map domain names to IPv4 addresses. AAAA records map domain names to IPv6 addresses. MX records specify the mail servers responsible for accepting email for a domain. CNAME records create aliases pointing one domain name to another. NS records specify the authoritative name servers for a domain. TXT records store text information and are used for purposes such as email authentication with SPF and DKIM. PTR records are used for reverse DNS lookups, mapping IP addresses back to domain names.
## DNS Caching
DNS responses include a time-to-live value that specifies how long the answer can be cached. Caching reduces the load on DNS servers and speeds up resolution for frequently accessed domains. The trade-off is that DNS changes take time to propagate because cached records must expire before the new information is seen.Back to Subject