Troubleshooting DNS Resolution on Linux: A Step-by-Step Guide to Checking Your Upstream DNS Resolver

If you’re experiencing DNS resolution issues on a Linux system, there are several steps you can take to diagnose and check your upstream DNS resolver. Here’s a step-by-step guide:

1. Check the Resolver Configuration File

Your DNS resolver settings are typically found in the /etc/resolv.conf file. This file lists the DNS servers your system is using.

To check the file, you can use a command like cat:

cat /etc/resolv.conf

You should see output similar to this, which shows the DNS servers your system is using:

Copy code

nameserver 8.8.8.8
nameserver 8.8.4.4

2. Test DNS Resolution

To test if your DNS is working, you can use the dig or nslookup commands followed by a domain name.

For dig:

dig bigbeartechworld.com

For nslookup:

nslookup bigbeartechworld.com

If these commands return an IP address, then your DNS is working.

3. Query Specific DNS Servers

You can also test querying specific DNS servers to rule out issues with your default resolver.

For example, to query Google’s public DNS for the IP of google.com:

dig @8.8.8.8 google.com

4. Check for Firewall or Network Issues

Sometimes, DNS issues can be caused by a firewall or network configuration that blocks DNS queries. You can check if you can reach the DNS server with ping:

ping -c 3 8.8.8.8

Replace 8.8.8.8 with the DNS server you want to check.

5. Check Systemd-resolved Service

If you’re using systemd-resolved, which is common in newer distributions, you can check its status with:

systemctl status systemd-resolved

6. Use the resolvectl or systemd-resolve Commands

resolvectl (or systemd-resolve on older systems) is a utility for service and network configuration. To check the status of the DNS servers, use:

resolvectl status

This will show detailed information about the DNS servers and their reachability.

7. Check Network Manager

If you’re using Network Manager, it might be managing your DNS settings. You can check the settings with:

nmcli device show

Look for the IP4.DNS and IP6.DNS entries.

8. Look at Logs

Sometimes, the logs can provide hints as to what’s going wrong with DNS. To check the logs, you can use:

journalctl -u systemd-resolved

Replace systemd-resolved with the name of your DNS service if different.

9. Flush DNS Cache

If you think the issue might be related to caching, you can flush the DNS cache:

For systemd-resolved:

resolvectl flush-caches

10. Restart Networking Services

As a last resort, sometimes restarting the networking services can help:

sudo systemctl restart NetworkManager

Or, if you’re not using Network Manager:

sudo systemctl restart networking

If you have systemd-resolved running:

sudo systemctl restart systemd-resolved

After performing these checks and actions, you should be able to identify if there’s an issue with your upstream DNS resolver or elsewhere in your system’s DNS configuration. If problems persist, it might be necessary to look at wider network issues or consult with your ISP or network administrator.