As a fellow command line enthusiast and network troubleshooter, I know how frustrating that "Fatal error: Neither dig nor nslookup present" message can be when all you want to do is a simple DNS lookup. But don‘t worry – this is a fairly common issue and easy to resolve once you understand what‘s going on under the hood.
Let me walk you through exactly what causes this error, how to fix it, and some bonus tips on using dig, nslookup and friends to take your DNS troubleshooting to the next level. I‘ve been down this road many times myself, so I‘ll do my best to pass along the wisdom!
The Crucial Role of DNS Lookups
Before jumping into the details, it helps to understand why DNS resolution is so important. As I‘m sure you know, the DNS system serves as the "phonebook of the internet" – matching easy-to-remember domain names like example.com to the actual machine-friendly IP addresses that computers use to communicate, like 192.0.2.123.
Without DNS, we‘d all have to memorize strings of numbers just to send an email or browse the web!
The utilities like dig and nslookup are used to directly query the DNS system and map names to IPs. This happens behind the scenes normally, but you need power user tools to really look under the hood and troubleshoot issues.
That‘s why error messages about dig or nslookup missing can halt tools that rely on them to do lookups. Time to fix that!
Diagnosing the Issue
The "neither dig nor nslookup present" error means your system is missing the utilities it needs to resolve domain names via DNS.
Specifically, it can‘t find:
- dig – The de facto standard flexible DNS lookup tool
- nslookup – Interactive way to query name servers
- host – Simple way to do basic DNS lookups
There are a few other DNS tools like drill that may also be missing. The key is your system needs one of these installed to perform the necessary name resolution.
Installing Bind Utilities – The Quick Fix
On Linux, the easiest way to install the missing dig, host, nslookup commands is by installing the bind-utils package.
For yum-based distros like RHEL/CentOS:
yum install bind-utils
On apt systems like Ubuntu/Debian:
apt install dnsutils
Either of those will pull in all the standard DNS utilities. With that, you should be able to run commands like dig and nslookup!
Verifying the DNS Tools Work
Of course, you‘ll want to confirm the utilities are actually available now.
You can check dig:
dig -v
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> -v
And nslookup:
nslookup -version
Nslookup program version: 9.11.4-P2-RedHat-9.11.4-9.P2.el7
Run a few test queries against popular public DNS servers like Google (8.8.8.8) or Cloudflare (1.1.1.1) to verify external DNS resolution works as expected.
If you run into any issues here, it may be related to firewall rules, DNS server configuration or networking. But at least the tools themselves are installed!
Troubleshooting Persistent DNS Issues
Sometimes installing bind-utils alone doesn‘t fully resolve DNS lookup problems. A few things to check if you still see errors:
-
DNS Server Settings: Check your /etc/resolv.conf and any other network config areas to see if a specific DNS server is set that is unreachable. Try setting 8.8.8.8 temporarily for testing.
-
Firewall Rules: Your local network or cloud host firewall may be blocking access to DNS ports (UDP 53). Add exceptions for DNS traffic.
-
Networking: Very rarely hardware issues like bad routers or NICs can cause DNS problems. But start with software!
-
SELinux/AppArmor: These security modules could be blocking access to dns utilities. Consider tweaking as a last resort.
Taking Your DNS Troubleshooting to the Next Level
While the basics of installing bind-utils and nslookup should get you past the simple errors, I want to provide some tips on using them more effectively. Here are some of my favorites:
dig
One of the most flexible DNS tools, dig can query nameservers for virtually any record type. Here are some useful examples:
- Query all records for a domain:
dig example.com ANY
- Specify record type to lookup:
dig example.com MX
- Debug underscore domains for mail servers:
dig -t txt _dmarc.example.com
- Trace recursive lookups:
dig +trace example.com
nslookup
Nslookup is a more interactive way to query DNS and troubleshoot records.
- Enter interactive mode:
nslookup
- Lookup a specific record:
nslookup -type=MX example.com
- Query a different DNS server:
server 1.1.1.1
host
Don‘t overlook host – it‘s simpler than dig/nslookup but great for quick lookups:
host -t AAAA example.com
Final Thoughts
I hope this guide has helped explain what‘s causing the "neither dig nor nslookup" errors and given you some solid tips on installing the needed tools and using them to troubleshoot DNS issues like a pro.
DNS may seem dry on the surface, but it‘s a critical foundation of how the internet works. Mastering the ins and outs of those dig queries and nslookup commands really does pay off in the long run!
Let me know if any part needs more detail. I‘m always happy to chat more DNS and networking tools. Stay curious my friend!