Monday 4 April 2011

DNS command for troubleshooting

Zone file database records divide DNS information into three primary types: NS (Name Server) records, MX (Mail Exchange) records, and A (Address) records. NS records indicate the name servers. MX records indicate the hosts that handle email delivery; the priority (pri) number indicates the order in which mail servers are used, with the lowest number receiving the highest priority. The A (Address) records map hostnames to IP addresses, the real names of machines.

nslookup
========


The nslookup program allows the user to query Internet domain name servers interactively or non-interactively

# nslookup www.redhat.com
Server: 128.121.247.232
Address: 128.121.247.232#53

Non-authoritative answer:
Name: www.redhat.com
Address: 209.132.177.50

dig
===


Use the dig command to determine whether the name server for your domain is configured correctly.

You can quickly determine the Name servers of your host or any other host:

# dig ns your-host.com

Check your (or another) website against the host's name servers:

# dig www.your-domain-name.com @ns.your-host.com

Dig can provide output that is in the same format as the zone file itself. Here is how to get the whole zone file:

# dig any your-domain-name.com

Here are the most useful dig query types: dig any (gathers all DNS information), dig ns (gathers name server information), dig mx (gathers mail exchanger information) and dig a (gathers network address information).

Reverse DNS from command line. Quick and easy way to look up a domain name given an IP address.

# dig -x 192.168.52.2

host
====


This is the simplest of the DNS commands. It is a quick way to determine the IP address of a hostname.

The host command accepts arguments that are either the fully qualified domain name or the IP address of the server when providing results.

# host

# host www.domainname.com

To perfrom reverse lookup

# host 192.1168.52.2

To find all of the information about a host maintained by the DNS, use the command:

# host -a
# host -a redhat.com
# host www.your-domain-name.com

The -a option will return all of the DNS information in verbose format:

# host -a www.your-domain-name.com

Now that you know the IP address for www.your-domain-name.com, try a reverse lookup:

# host

To list a complete domain, use the command:

# host -l
# host -l redhat.com

dnsquery
========


The dnsquery program queries domain name servers via the resolver library calls /etc/resolv.conf.

# dnsquery
# dnsquery www.redhat.com