DNS Servers keep resetting back

Hi

I tried changing DNS servers in “Hostname and DNS Client” to add in an extra 2 (Googles) for backup (because Linode DNS went down earlier), BUT when I Apply the changes, and go back in its reset them back to the original ones. This only happens on some of my virtualmin servers.

Does anyone know why the DNS servers keep resetting back??

Thanks

Howdy,

Are you by chance using DHCP on those servers where the DNS settings get overwritten?

If so, take a peek at the following link, in the section named “Received Virtualmin error that 127.0.0.1 isn’t listed in /etc/resolv.conf”:

https://www.virtualmin.com/documentation/dns/faq

Looks like the servers are DHCP, they’re Linode https://library.linode.com/networking/configuring-static-ip-interfaces#sph_dns-resolver-settings

But I am a little confused as to what I should change to stop resolv.conf overwriting. The link you sent is mainly instructions about adding 127.0.0.1 to a /etc/dhclient.conf file. I guess thats not my issue?

Some of my servers overwrite resolv.conf and some dont which is weird. I can see eth0 differences as follows, should I change eth0 as per the Linode static network guide??

eth0 on server that resolve.conf overwrites:

####

eth0 default configuration

DEVICE=“eth0”
BOOTPROTO=“dhcp”
IPV6INIT=“yes”
IPV6_AUTOCONF=“yes”
ONBOOT=“yes”
TYPE=“Ethernet”

eth0 on server that resolve.conf is not overwritten:

# Configuration for eth0
DEVICE=eth0
BOOTPROTO=none

This line ensures that the interface will be brought up during boot.

ONBOOT=yes

eth0 - This is the main IP address that will be used for most outbound connections.

The address, netmask and gateway are all necessary.

IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.0
GATEWAY=xxx.xxx.xxx.xxx

Howdy,

One way to correct it would be just to change it to use static IP’s. We recommend static IP’s when possible.

If you wish to use DHCP, the instructions mentioned in that link are what you’re after… except, instead of “127.0.0.1” as your DNS server, you’d replace that with your desired nameserver’s IP address.

-Eric

Thanks, but to use static IPs I just change the eth0 file to like the second one above? I think thats my issue, I dont actually know what to change. I guess making the eth0 like the second one above would work, as I am sure thats all I did on the servers that do have static.

Howdy,

You could either make the change from within Webmin/Virtualmin (by going into Webmin -> Networking -> Network Configuration -> Network Interfaces), or you could use a text editor to change the interface file that you’re looking at… the CentOS documentation for that is available here:

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-networkscripts-interfaces.html

In your case, the configuration that is not overwriting the resolv.conf file is indeed using a static IP.

-Eric

Thanks for that, but when I changed it in Network Configuration -> Network Interfaces the server went down :(. Had to login to the Linode console and set it manually like the above eth0 config like another static server and worked OK. So a bit reluctant to do it in Webmin. Will do the others by command. Revisiting Networking Interfaces it looks the same as what I entered. I dont have the eth0 file anymore to show you what it looked like.

To confirm, creating the following eth0 config file works fine and fixes this issue for me:

# Configuration for eth0
DEVICE=eth0
BOOTPROTO=none

This line ensures that the interface will be brought up during boot.

ONBOOT=yes

eth0 - This is the main IP address that will be used for most outbound connections.

The address, netmask and gateway are all necessary.

IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.0
GATEWAY=xxx.xxx.xxx.xxx

any one wondering about this on openvz, you can edit your resolv.conf and then use chattr +i on it to make it read only even to root, i had to do the same thing to my /etc/hostname

I have to do this with google cloud instances otherwise i have problems with hostname if i have changed it from that assigned by google cloud.