Tip of the Day
- May 28, 2021
/etc/resolv.conf - Why do my DNS lookups not work, or sometimes seem to work, and other times don't.
Today's tip of the day is something I just figured out, after having it bug me for many years, and only just now confirming the resolution!
Unfortunately, Network Manager often creates a new /etc/resolv.conf file with the "search" statement preceding the "nameserver" statement(s)! This causes intermittent DNS lookup failures, especially on the local network! This has caused me years of frustration, so my hopes are this will help others avoid my past frustration! :-)
Here is an example of what Network Manager can create, causing my local DNS queries on my own internal BIND9 DNS VM servers to fail:
# Generated by NetworkManager search dawgland.com nameserver 192.168.200.103 nameserver 192.168.200.104 nameserver 188.8.131.52
Through trial and error using multiple machines(VM's actually) with multiple distros of Linux, both Red Hat and Debian based, I discovered that the order of the statements within the /etc/resolv.conf file make a HUGE differnce!
The nameserver statements MUST come before the "search" statement!!! Such as this example:
# /etc/resolv.conf - Created manually on 05-28-2021 nameserver 192.168.200.103 nameserver 192.168.200.104 nameserver 184.108.40.206 search dawgland.com
The changes take effect immediatelly, without the need to reboot or restart any services. I hope you found this tip of the day useful!