What file do I have to edit to make static DNS server in CentOS?

Almost every distro I know will wipe /etc/resolv.conf on reboot (I think DHCP does this) and thus the place to add static DHCP entries varies per distro. How do I add static DNS servers to a CentOS server, so that I know that my entries will survive a reboot?

Asked By: xenoterracide

||

It would really just come down to how you configure your dhcp client.

From the link provided, it seems the relevant file will be

/etc/sysconfig/network-scripts/ifcfg-eth0
Answered By: Stefan

For CentOS it looks like you add PEERDNS=no to /etc/sysconfig/network-scripts/ifcfg-eth0 (see the documentation).


More generically, iIf you’re using dhclient then put the following in your dhclient.conf file:

interface "eth0" {
 supersede domain-name-servers 8.8.4.4, 8.8.8.8;
}

For dhcpcd you add the -R option to the command line to stop it changing /etc/resolv.conf.

Finally pump uses the -d option on the command line to stop it changing /etc/resolv.conf.

Answered By: Cry Havok
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.