≡ Menu

What is DNS and How DNS Works? (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.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • thusitha December 6, 2013, 12:32 am

    Nice one. And thanks a lot

  • rahul December 6, 2013, 9:11 am

    i want to understand linux board bring up process?what is actually the process?where is bootlader copiedin internal memory of arm processor?where uboot ,kernel resides?

  • Jalal Hajigholamali December 8, 2013, 8:29 am


    Thanks a lot for very nice article..

  • Bhagyaraj December 8, 2013, 11:07 pm

    Givens me little more depth in DNS.

  • emie pelonio December 10, 2013, 9:35 pm

    Hi iam going to ask, every time im going to download a games to my samsung GT E2652W ceelphone, and they give me a link to click, after it show DNS Failed.. what am i going to do,..


  • knud jorgensen December 31, 2013, 6:12 am

    Dear, I enjoy following all TGS fine mail. Your way of explaining is very good ! I am looking forward to the coming year and wish you a Happy new Year from Knud in Denmark Europa

  • Krishnaprasad January 1, 2014, 8:04 am

    dear sir,
    Am really thank for u for giving Ur useful info bout linux. i have 1query bout linux. am using rack server but
    please send me bout how to make a mirror backup for putting backup of mysql database to my backup server while working on my main server. .

  • Vut January 6, 2014, 8:56 am

    Inverse query = reverse lookup.

    We usually call it “reverse lookup” instead of “inverse query” for PTR record lookup.

  • Ketki August 19, 2015, 6:57 am

    Good elaboration