DNS (Domain Name System) is a distributed implemented in a hierarchy of many name servers.
It is also an application layer protocol used to query those servers.

DNS services handle hostname-to-IP-address translation, mail server aliasing, load distribution and more.

A DNS query

Say a client wants to query the address for www.amazon.com

  • client queries root server to find .com
  • client queries .com server to get amazon.com server
  • client queries amazon.com server to get the IP address for www.amazon.com

TLD servers are responsible for top-level-domains (.com, .tech, etc)

Authoritative DNS servers are an organization’s own DNS server, providing authoritative hostname to IP mappings for organization’s named hosts

Iterated Query

A DNS server may return the address of another server to try querying if the server itself does not contain the address, can be done via a local DNS server which makes the subsequent requests itself instead of relying on the contacted name server.

Recursive Query

Puts the burdern of name resolution on the contacted name server, leads to heavy load at upper levels of the hierarchy

DNS caching

Most if not all name server implementations cache requested queries to improve response time, DNS caches expire for each entry after a TTL (time to live).

Cached entries may be out-of-date until all TTLs expire.

DNS Record Types

A

  • name is hostname
  • value is IP address

NS

  • name is domain
  • value is hostname of authoritative name server for it

CNAME

  • name is alias for a canonical name
  • value is the canonical name

MX

  • value is the name of the SMTP mail server associated with name

DNS Protocol Messages

Query and reply messages have the same format