I am managing a particular host machine, and I would like to locally add a new name server for it to query (i.e. not changing its name server settings via the dhcp server). It seems that there are multiple ways to add a new name server.
- Adding a 'nameserver ' directive directly to the resolv.conf file
- Adding a 'DNS{1,2}=address' directive to a ifcfg-ethX file
- Adding a 'append domain-name-servers' directive to a dhclient.conf file. (Let's assume the host is using dhcp).
Perhaps there are even more ways…
Which way is preferred? If I want the name server address to be persisted following restarts, and also be available for use immediately in the next lookup by the host, which option is best?
Thanks
Best Answer
I would
The client will start using it immediately and the next time it refreshes it's DHCP lease/options it will get it from the server too.
You could also add the new server to the DHCP server's domain name server list and restart networking on the client so that it immediately updates from the server
If you don't want to change the DHCP server configuration then you can use the /etc/dhcp/dhclient.conf file to append or prepend an address to the domain-name-servers list
would add the name server at 8.8.4.4 to the end of the list of nameservers in /etc/resolv.conf. Using prepend would put it at the beginning.
Be aware that the maximum number of entries in the nameserver list in /etc/resolv.conf is 3.