Skip to content
# Networking

DNS troubleshooting

Diagnose DNS resolution problems with dig, nslookup and /etc/resolv.conf.

Look up a domain: dig

dig is the standard, detailed DNS query tool. A bare dig call is verbose; +short gives just the answer.

bash
dig example.com
dig +short example.com
dig +short example.com MX      # mail records
dig +short example.com NS      # nameservers

dig against a specific resolver

Useful to rule out "is it my DNS server or the record itself" β€” query a known-good public resolver directly.

bash
dig @1.1.1.1 example.com
dig @8.8.8.8 example.com

nslookup as a fallback

Older and less detailed than dig, but present on almost every system and fine for a quick check.

bash
nslookup example.com

Check what resolver your server is actually using

/etc/resolv.conf lists the nameservers the system queries. On systemd-resolved-based distros (Ubuntu, Fedora) it may just point at 127.0.0.53, a local stub resolver β€” check resolvectl for the real upstream in that case.

bash
cat /etc/resolv.conf
resolvectl status   # on systemd-resolved systems (Ubuntu, Fedora)

dig doesn't come preinstalled everywhere

On minimal images (notably Alpine) you may need to install the DNS utilities package first.

bash
sudo apt install dnsutils     # Ubuntu/Debian
sudo dnf install bind-utils   # RHEL/Fedora
sudo apk add bind-tools       # Alpine