As humans are identified by names, the hosts are identified by the hostnames (www.abc.com) and IP addresses ( The IP address are of 4 bytes each byte ranging from 0 to 255.

DNS or Domain Name Server is basically a distributed database implemented in a hierarchy of Database Servers and an application layer protocol that helps to query the distributed database. The DNS works as follows when you query for a hostname say abc.com

  1. The user name in which we have given the query also runs as the client side for the DNS.
  2. The browser extracts the host name and pass it to the client side of the DNS application.
  3. The client side of the DNS then sends in the query to the DNS server.
  4. The server converts the hostname to IP address and then sends it back to client.
  5. Once the IP address is received the client then tries to establish a TCP connection with the server.

Services by DNS

  1. Host Aliasing: DNS can be invoked by an application to provide the canonical host names.
  2. Mai Aliasing: DNS can be invoked by an application to provide the canonical host name for the supplied alias name and IP address.
  3. Load Distribution: It provides load distribution among the replicated web servers like cnn.com. Each such web servers they will have a list of IP address for their canonical hostnames that is associated with it. When a DNS query is sent then the server responds by fetching all the IP addresses and then by selecting the first IP address, which then goes in a rotation thereby, distributing the traffic. s

Centralized DNS : If we consider to have single DNS server around the world then we would have the following limitations.

  1. A single point failure: If the DNS, so does the internet.
  2. Traffic Volume: Handle traffic queries from millions of users around.
  3. Distance: Suppose the DNS Server is in US and a person in Australia wants to connect, to much of time to connect.
  4. Maintenance: Updation of new domains to account for every new host.

Distributed Hierarchial Database

  1. Root DNS Servers : There are basically 13 root level domain servers. Most of them are in US (Eg: NASA)
  2. TLD's: Refers to ones like .com, .edu, .org, .gov
  3. Authoriative DNS: Publicly accesbile host for every organisation.

DNS Caching

For example, each time the local DNS server dns.poly.edu receives a reply from some DNS server, it can cache any of the information contained in the reply. If a hostname/IP address pair is cached in a DNS server and another query arrives to the DNS server for the same hostname, the DNS server can provide the desired IP address, even if it is not authoritative for the hostname. Because hosts and mappings between hostnames and IP addresses are by no means permanent, DNS servers discard cached information after a period of time

DNS Records and Messages

The DNS servers that together implement the DNS distributed database store resource records (RRs). The Resource Record has four tuples: (Name, Value, Type, TTL). TTL refers to the Time To Live, it determines when a resource should be removed from the cache.

Based on the Type we can classify RR's into four types and get their names and values

Type Name Value Eg
A Hostname IP Adress (foo.com,
NS Hostname Authoritative Address (foo.com, dns.foo.com)
CNAME Hostname Canonical Address (foo.com, relay1.foo.com)
MX Mail server Canonical Address (gmail.com, mail.google.com)
DNS Message Format.png

DNS message Format

The DNS message Format has the first header section for 12 bytes that contains the

  1. Identification number which is a 16bit number and the second one a 1 bit flag followed by number of questions, number of answers, number of authority RRs and addititonal RRs.