As humans are identified by names, the hosts are identified by the hostnames (www.abc.com) and IP addresses (184.108.40.206). 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
- The user name in which we have given the query also runs as the client side for the DNS.
- The browser extracts the host name and pass it to the client side of the DNS application.
- The client side of the DNS then sends in the query to the DNS server.
- The server converts the hostname to IP address and then sends it back to client.
- Once the IP address is received the client then tries to establish a TCP connection with the server.
Services by DNS
- Host Aliasing: DNS can be invoked by an application to provide the canonical host names.
- Mai Aliasing: DNS can be invoked by an application to provide the canonical host name for the supplied alias name and IP address.
- 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.
- A single point failure: If the DNS, so does the internet.
- Traffic Volume: Handle traffic queries from millions of users around.
- Distance: Suppose the DNS Server is in US and a person in Australia wants to connect, to much of time to connect.
- Maintenance: Updation of new domains to account for every new host.
Distributed Hierarchial Database
- Root DNS Servers : There are basically 13 root level domain servers. Most of them are in US (Eg: NASA)
- TLD's: Refers to ones like .com, .edu, .org, .gov
- Authoriative DNS: Publicly accesbile host for every organisation.
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
|A||Hostname||IP Adress||(foo.com, 220.127.116.11)|
|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
The DNS message Format has the first header section for 12 bytes that contains the
- 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.