How DNS works

The Domain Name System (DNS) is a distributed naming system for devices connected to a network or the Internet. Its main job is to translate the domain names into IPs, to allow us to access a remote website without having to know a set of numbers.

From Wikipedia:

    The Domain Name System distributes the responsibility of assigning domain names and mapping those names to IP addresses by designating authoritative name servers for each domain. Authoritative name servers are assigned to be responsible for their supported domains, and may delegate authority over sub-domains to other name servers. This mechanism provides distributed and fault tolerant service and was designed to avoid the need for a single central database.

The funny part about the DNS is that works in the same way in your local network, so when you access a local PC with its name (example: pc02.thesolving.local) there’s a domain name server translating it in a local network IP address.

The DNS can store different types of records. Three are the most important ones:

  • A: translate a domain name in one or more IP addresses (32-bit)
  • CNAME: translate a domain name (alias) in another domain name
  • MX: translate a domain name in one or more IP addresses (only for emails)

The domain names tree composes the Domain Name Space. Every domain can have subdomains and it’s possible to segment this tree in zones of a single domain name or multiple domain names.

The domain hierarchy is quite simple, the more a label is on the right and higher its level is.

For example, in explanation.example.org we have:

  • A top-level domain: org
  • A second level domain: example
  • A third level domain: explanation

It’s possible to add other levels of segmentation, up to 127 levels. The total lenght of a domain name may not exceed the length of 253 characters while each label can’t contain more than 63 characters.

A domain name resolver, the client side of the DNS, determines the domain name server responsible for a domain name by a sequence of queries. It starts with the top-level domain and go on with lower level domains.

The domain name system heavely relies on caching to avoid bottleneck and performance issues.

Comments