We’re here to discuss how to troubleshoot DNS name resolution problems on Linux OS, so here’s everything you need to know.
We start with a brief discussion on DNS and then discuss why troubleshooting a domain name issue is essential. Then, various steps to troubleshoot DNS name resolution problems in Linux are discussed.
What is a domain name service?
Domain name service (DNS) converts a domain name to an Internet protocol (IP) address. The DNS server maintains a database of names and IP addresses. There are various types of records are maintained by DNS servers such as SOA, NS, ME, etc.
The name resolution process is recursive. Starting from the top level, a query is sent to the domain name server at each level until the request is resolved. Therefore, resolving domain name issues is a non-trivial task.
Why Would You Need to Troubleshoot DNS Name Resolution Problems?
As we discussed earlier, it is very difficult to remember IP addresses for websites or services over the Internet. Normally, these services are accessed using their easy-to-remember names, called domain names, and the DNS server converts the domain name to IP addresses.
The domain name issues will prevent you from accessing websites and other services over the internet using their names. Therefore, a DNS issue can compromise servers’ availability over the internet. Hence, learning how to troubleshoot DNS name resolution problems is essential.
The possible reasons for a DNS problem
There can be various reasons for a DNS problem. Some of the possible issues are:
- The DNS server is unavailable, and the DNS names are not properly configured.
By learning how to troubleshoot DNS name resolution problems through various methods discussed in this article, you will be able to identify the root cause and resolve them.
Troubleshooting domain name issues on Linux
We will now discuss the various steps you can employ to identify the domain name issues. Follow the steps below.
List down the current network interfaces
The very first step will be to list down the current network interfaces. Follow the steps below:
- Open your Terminal by clicking on the System menu and selecting the Terminal.
- Type the following command on the Terminal:
$ip addr show
- You will see the list of current interfaces.
- Note down if there are any entries with ‘eth0’ or ‘ wlan0’. If there is no such entry, the error may not be the DNS issue.
- If no network devices are enabled, you must add one before proceeding.
List down the IP address of the name server
We will not list down the IP addresses of the name server that can be inquired further to identify the cause of the problem.
- First, display the content of
/etc/resolv.conf
. Type the following command on your Terminal:
$less /etc/resolv.conf
- This will show the configuration of DNS servers on your system. Take note of the IP addresses of the nameserver.
Ping the domain name server
In the next step, we will ping the domain name server identified in the previous steps. Follow the steps below:
- With the IP addresses noted in the previous step, we will ping these servers. Type the following command on your Terminal:
$ping IP_address
- You should be able to see the response, such as 64 bytes from 128.200.1.4. If you receive the response, it means the server is available but unable to resolve the domain name.
- If you don’t see the response from the server, it means the DNS server may not be available.
- Repeat the steps for all the IP addresses you noted down previously.
Try resolving some popular/ well-known domain name
For the next step, we will try resolving some known domain names.
- Type host followed by some popular domain name such as google.com
- You should see the IP address of Google in response. This implies that the DNS server was able to resolve the domain name.
- If you don’t see the IP address in return, your domain name server must be properly configured.
Check if BIND is installed
Check that the name resolution service for Linux i.e., Berkeley Internet Name Domain (BIND), is installed via the following command:
$ named –v
You should see the output that BIND is installed. If it is not installed, you can install BIND With the help of the following command on Ubuntu and similar distributions:
$ sudo apt install bind9 bind9-utils bind9-dnsutils
Check if BIND is running
Check if the BIND is running with the help of the following command:
$ sudo systemctl status bind9
As an admin, you can use systemctl start, stop, restart, enable, and disable to manage the service.
Check zone configuration
The zone file contains the resource records that relate a hostname to the IP address. You can check the zone configuration with the following command:
$ sudo named-checkzone zonename.com db.zonename.com
You should receive an exit code with the value 0. If you receive the value 1, check the zone file contents for errors.
Check the /etc/resolv.conf
The DNS information is defined in /etc/resolv.conf
in Linux systems. It contains the DNS server IP address using nameserver tags. We can have multiple servers, each on a new line. The order defines the priority. Following is a sample DNS configuration:
server# grep "nameserver" /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
Check the /etc/host file
We also have a /etc/hosts
file that does the host-to-IP address mapping locally. Following is a sample ‘hosts’ file:
server# more /etc/hosts
127.0.0.1 localhost
127.0.1.1 REMOTE-SERVER
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
...
Using various tools to troubleshoot DNS issues
We will now discuss some tools that can be used to resolve DNS issues.
nslookup
This command line utility can be used to obtain information about domain names. You can type the following command to retrieve information about a DNS record:
$nslookup linuxtechwhiz.info
You should see the following information:
Dig
The dig command can be used to obtain fine details about DNS records such as A, MX, and SOA records. It shows the entire process of recursive query. For example, type the following command can be used to dig into the details of a domain name:
$ dig linuxtechwhiz.info
You will see the following information:
In this article, we have discussed the various ways to troubleshoot DNS name resolution problems in Linux. DNS converts the domain name to the IP address. Therefore, resolving these issues is essential. We discussed different approaches to resolve domain name issues.
If this guide helped you, please share it.