Saturday, February 12, 2011

Domain Name Server ( DNS )

What is Domain name server ?

Domain name server is a server which converts the human readable domain-names into numeric IP addresses .

There exists basically two namespaces in Domain name system :
1 . The Human readable domain names . Ex :
2 . The Numeric IP addresses which is used to locate the computer in the network. 
     Ex :

DNS Resolution :
Whenever you type the domain name in the address bar of the browser, the domain name is sent to a DNS where the mapping of the two namespaces takes place , wherein the domain names are mapped onto the numeric IP addresses for looking up the computer with that particular IP address in the network.

resolv.conf :
It is the name of the computer file found in many of the operating systems which is used to configure domain name system resolver libraries.The resolv.conf file typically contains directives with the IP addresses of nameservers available to a host .
Usually this file is located in /etc directory in most Unix systems.

DNS Lookup utilities :
These are the utilities basically used to interrogate DNS name servers.
Three most Flexible utilities for DNS lookup are :

1 : nslookup.
2 : dig ( Domain Information Groper ).
3 : host

nslookup :

Used to query the Internet name servers .

Syntax : nslookup [-option] [name | -  ] [server]

nslookup basically works in two modes :

1 : Interactive Mode : This mode is activated when you type nslookup without arguments . A   > prompt appears for interactively querying the name server .

Ex : nslookup 
     > server

2 : Non Interactive Mode : This mode comes into picture when you enter nslookup with arguments .

 Ex : nslookup

       Non-authoritative answer: canonical name =

The Java Code which achieves the same task as nslookup is given below :

public class IP {
    public static void main(String[] args) throws Exception {

The Java code above queries the name server to resolve human readable to numerical IP address .

There are many options which can be used for effectively quering the DNS . Check out the manual page for nslookup for further details.

dig ( Domain information groper )

Syntax : dig @server  name  type
server is the IP address or the name of the name server .
name is the name of resource record to be looked up.
type is the type of query required Ex :ANY , MX etc
Is also used to query the DNS . It performs DNS lookups and returns the output given by the name servers . It is the most flexible tool used by most of the network administrators for troubleshooting the problems in DNS resolution . It is also most used DNS lookup utility because of its clarity of output. It has indeed got a huge set of options for memory debugging ,selection of specific family of protocols and much more . Consult the man page for more details .
Ex : dig MX

;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4548 ;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ; IN MX ;; ANSWER SECTION: 3600 IN MX 10 3600 IN MX 50 ;; ADDITIONAL SECTION: 3600 IN A 3600 IN A ;; Query time: 479 msec ;; SERVER: ;; WHEN: Sun Feb 13 12:23:26 2011 ;; MSG SIZE rcvd: 109

As we can see the Output is more clear .

host :

Syntax : host [-options] [server ]

Host is the most simple utility for DNS lookups .It is used to convert names into IP addresses and vice versa .

Ex : host is an alias for has address is an alias for

These are the tools which are used for DNS lookups which are usually used by Network Administrators to troubleshoot the problems in DNS .

For any queries , suggestions , comments do fell free to leave a comment or mail me at

No comments: