CentOS will wipe out any manual changes made to /etc/resolv.conf
periodically. The defaults in Linux are poor in terms of failing over in a reasonable time (query name servers in same order every time, 5 second timeout, 2 retries).
Hence, the first DNS in your resolv.conf
is essentially critical path. If it fails you can be looking at 10 seconds before you fail over.
These defaults are tweakable (see resolv.conf man page), but how can any changes be made permanent in CentOS and persist through reboots etc.?
Best Answer
The answer can be found in the
/sbin/dhclient-script
:But, it's not terribly obvious where you can set
RES_OPTIONS
to make the script pick it up - some things like the search domain can be set in theifcfg-ethX
file, but resolver options are set elsewhere. The file you want is in fact/etc/sysconfig/network
. To set the relevant options, add something like this line to that file:That will set the timeout to 1 second, use a single retry and tell the client to rotate its resolvers per request instead of sequentially going through the list each time.
If you would like to have the changes take effect immediately, then issue a
service network restart
command and check out your new/etc/resolv.conf
in all its glory. Here's what mine looked like when testing this out: