Contact for queries :
 

Troubleshooting DNS using nslookup and host commands in Linux

The most basic test after the DNS server has been set up properly is to ping the hostname of the nameserver
and the domain itself. If both return a reply, your nameserver is querying properly.
Step 1. Ping the hostname of the nameserver for your network—in this case, RHEL01:

# ping rhel01
PING rhel01.example.com (172.168.1.1) 56(84) bytes of data.
64 bytes from rhel01.example.com (172.168.1.1): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from rhel01.example.com (172.168.1.1): icmp_seq=2 ttl=64 time=0.020 ms
— rhel01.example.com ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.020/0.028/0.036/0.008 ms

Step 2. Next, you can ping the domain name to ensure that the primary nameserver is again functioning properly:

# ping example.com
PING example.com (172.168.1.1) 56(84) bytes of data.
64 bytes from rhel01.example.com (172.168.1.1): icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from rhel01.example.com (172.168.1.1): icmp_seq=2 ttl=64time=0.020 ms
— example.com ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.020/0.028/0.036/0.008 ms

Another useful tool that can help test whether your DNS server is functioning properly is the host  command.

Syntax: host [option] HOSTNAME
Options:
-l Allows you to perform zone transfers
-r Disables recursive processing
-t Specifies the query type
-v Provides verbose output

You can use this command for two simple purposes to ensure functionality.
Step 3. First, perform a forward lookup to test the main zone file:

# host rhel01
rhel01.example.com has address 172.168.1.1

Step 4. Second, perform a reverse lookup to test the reverse lookup zone file:

# host 172.168.1.1
1.1.168.172.in-addr.arpa domain name pointer rhel01.example.com.

If the results that you are expecting don’t match what is displayed, or if the hostname or IP address can’t be found, it is a good indication there is a problem with that particular zone file.
This is a good way to test a few of the entries in each zone file to verify functionality of the DNS server. Aside from the host command, you can also use the nslookup command that offers slightly different information about lookups.
Step 5. Query the domain name again:

# nslookup example.com
Server: 172.168.1.1
Address: 172.168.1.1#53
Name: example.com
Address: 172.168.1.1

This time you see the nameserver for the example.com domain respond. This is a good way to find out which DNS server is responsible for a particular domain.
Step 6. You can also use nslookup like the host command to perform forward lookups:

# nslookup rhel01
Server: 172.168.1.1
Address: 172.168.1.1#53
Name: rhel01.example.com
Address: 172.168.1.1

Step 7. Plus, you can use it to perform reverse lookups:

# nslookup 172.168.1.1
Server: 172.168.1.1
Address: 172.168.1.1#53
1.1.168.172.in-addr.arpa name = rhel01.example.com.

November 16, 2015

1 responses on "Troubleshooting DNS using nslookup and host commands in Linux"

Leave a Message

Your email address will not be published. Required fields are marked *

About iGURKUL

IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal www.unixadminschool.com. And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base www.unixadminschool.com/blog for the best practices and Knowledge learning.

Popular Tags

Who’s Online

Profile picture of Stephan N
Profile picture of Raja Raghava
Profile picture of Mark Joe
Profile picture of Arun S Vijayan
top
Template Design © igurkul I.T. solutions. All rights reserved.
X