How to Troubleshoot DNS On Linux

I will show you how to troubleshoot DNS issues with Linux commands.

Introduction

 

DNS stands for domain name resolution and it associates IP addresses with common names. These are special servers which do this on the internet. DNS servers have name server, mail exchange, A, and PTR records. They all act together to figure out where to send us on the internet. 

 

User Problems

 

Users are going to use the common name for a web address. They will remember google.com and not an IP address. So, when they can not access a site or resource that they have in the past, DNS is one of the first things to check. 

 

Bind Utilities

 

You will probably need to install this package of utilities. You can do so by entering the following command:

 

Dnf install bind-utils

 

This will install the primary tools we need, which are ping, nslookup, dig, and host. This is a Fedora system, so if you are another operating system, just use your native package manager.

 

Testing DNS

 

If a user can not access a web resource, try using the ping command first. You will want to use the hostname if possible so you can see the error in person.

 

Ping -c aindien.com

 

If this works, the problem is elsewhere in the system. If your query does not get you to the correct site, then use the IP address.

 

Ping -c 192.168.1.12

 

If this test works by using the IP address, then you probably have a DNS issue. If the IP address does not work either, then you have another problem, which is probably connectivity. Basically, ping tells you whether you have a DNS or connectivity issue.



Manual DNS Checks



If ping does not give you the results you are looking for, the next tool to use is Dig. It is straightforward to use. 

 

Dig aindien.com

 

This is called a forward lookup. It will give you a bunch of information if you have connectivity. Otherwise, it should give you clues about where to look next. If you are not reaching your target, then use a reverse lookup with the IP address.

 

Dig -x 192.168.1.2

 

This will give you different information. Like ping, this tells you whether you have a DNS or connectivity issue. However, it gives a lot more information, and it is different. It is another way to check for errors.

 

Conclusion

 

In this document, I have illustrated how to do basic DNS troubleshooting. This is all about narrowing down the issues. Once you have done that, you know where to go from there. We talked about the ping utility. Even though it is the simplest, it is always a good place to start. Then we used the Dig utility to delve deeper into DNS issues. You use Dig once you have established it is a DNS issue.