Wednesday, December 11, 2013

DNS (Domain Name Server) Fundamentals






DNS stands for Domain Name System, or Domain Name Server. DNS resolves an IP address to a hostname or vice versa. DNS is basically a large database which resides on various computers that contains the names and IP addresses of various hosts/domains. Other than ip-address DNS also associates various information with the domain names.

Structure of a DNS

DNS uses a hierarchical tree based name structure. At top of the tree is the “root” ( represented as a dot (.) ) followed by the TLD ( Top Level Domain ), then by the domain-name and any number of lower level sob-domains separated by a dot.

The Top Level Domains are divided into 2 categories:
1. Generic TLD (gTLD)

2. Country Code TLD (ccTLD)

Below are some of the common Generic Top Level Domains:
  • .com – comercial web sites
  • .org – non profit organizations web sites
  • .edu – restricted to schools and institutions.
  • .net – originally for network infrastructures, now unrestricted
Below are some fo the Country Code Top Level Domains:
  • .us – United States
  • .in – India
  • .uk – United Kingdom
  • .ru – Russia
The following shows a sample representation of the structure of the DNS tree:


Authority, Delegation and Zone

The Authority for the root domain and gTLD lies with Internet Corporation for Assigned Numbers and Names (ICANN). ccTLD’s are delegated to individual countries for administration purpose. Each level in the hierarchy may delegate the authoritative control to the next lower level. There is a DNS server running in every level of the hierarchy and the responsibility of running the DNS server lies with the Authority at that level.

For Example, when the root domain gets a DNS query for www.example.com, the root will delegate responsibility for resolving to its lower level “.com”, which in-turn will delegate to “example”. Finally the DNS server in the “example” will respond with the IP address of the hostname “www”.
A zone is simply a portion of a domain. For example, the domain example.com may contain all the information for a.example.com, b.example.com and c.example.com. However, the zone example.com contains only information for example.com and delegates the responsibility to the authoritative name servers for the subdomains. In general, if there are no subdomains, then the zone and domain are essentially the same.

Resource Records

A DNS zone database is made up of a collection of resource records. Each resource record specifies information about a particular object. The DNS server uses these records to answer queries for hosts in its zone. For example, address mapping (A) record, map a host name to an IP address, and reverse-lookup pointer (PTR) records map an IP address to a host name. Here are some of commonly used Resource Records.
  • A Record: The ‘A’ record specifies the IP address of a host. ‘A’ record will have the details of the domainname and its associated IP address. When a Query is given to resolve domainname, DNS server will refer the ‘A’ record and answer with the IP address present in the record.
  • PTR Record: A PTR record maps the IP address to a specific host.
  • NS Record: An NS record or name server record maps a domain name to a list of DNS
  • servers authoritative for that domain. Delegations depend on NS records.
  • MX Record: An MX record or mail exchange record maps a domain name to a list of mail exchange servers for that domain. For example, when you send a mail to alpha@example.com, the mail will be routed to the Mail Server as specified in MX record.
You can use dig command to query DNS server and view the above information.

DNS Queries

A DNS query would be something like ‘what is the IP address of a.example.com’. A DNS server may receive such a query for any domain, to which it has no information about. The DNS server will respond is different ways for which it has no information about.
The following are the three types of DNS queries:
  • Recursive query
  • Iterative query
  • Inverse query
In Recursive query, the following are the steps involved when a host queries its local DNS server for ‘a.example.com’.
  • Host sends query ‘what is the IP address of a.example.com’ to locally configured DNS server.
  • DNS server looks up a.example.com in local tables – not found
  • DNS sends query to a root-server for the IP of a.example.com
  • The root-server replies with a referral to the TLD servers for .com
  • The DNS server sends query ‘what is the IP address a.example.com’ to one of the .com TLD servers.
  • The TLD server replies with a referral to the name servers for example.com
  • The DNS server sends query ‘what is the IP address a.example.com’ to name server for example.com.
  • Zone file defines a A record which shows ‘a”s IP address is x.x.x.x.
  • DNS returns the A record for ‘a’.
In Iterative query, if the DNS server doesn’t know the answer, it will refer other DNS server as response. So the client which initiates the query will once again contact the DNS server which came in as response.In Inverse query, an IP address will be provided and a hostname will be asked.

No comments:

Post a Comment