DNS server stops working after restart inside VPS


I get the following error during Re-Check Config in Virtualmin after every server restart:

Virtualmin is configured to setup DNS zones, but this system is not setup to use itself as a DNS server. Either add to the list of DNS servers, or turn off the BIND feature on the module config page. your system is not ready for use by Virtualmin.

If I follow the link to add to the list of DNS servers, Re-Check Config will pass and BIND will work.

The configuration will not stick after reboot and will be returned to the default nameservers apparently setup by the host. This looks like another VPS bug: the host (Virtuozzo/OpenVZ) apparently overwrites files at will inside the VPS, which confuses other apps like Webin/Virtualmin. I have not found any other services on my Debian 5 server which could be overwriting this file.

/etc/resolv.conf shows:
nameserver 85.214.7.xyz
nameserver 81.169.163.xyz

before reboot, as modified by Virtualmin.

I’ve tried to use chattr -i /etc/resolv.conf, which prevents the file from being overwritten. But with this attribute, the server fails to restart, without giving any clues in syslog. What would be the best way to preserve the settings in /etc/resolv.conf between reboots?

I suppose, I could also write a script which will append the localhost nameserver at every restart.


Hi Christian,

The problem you’re having could occur if your server is setup to pull it’s IP address via DHCP.

DHCP, by default, will generally alter the /etc/resolv.conf with updated DNS addresses.

If it is indeed a DHCP issue, one way to resolve that is by setting your IP address statically.


I’m having the same problem. How to set IP static in Centos 5.3?

One way to set it static would be to go into Webmin -> Networking -> Network Interfaces, and to setup your static IP in there.

I believe there’s also a way to tell DHCP not to reset /etc/resolv.conf, but I don’t recall what that is :slight_smile:

Eric, thanks for the suggestion to check DHCP. I checked it, and I’m positive, that DHCP had nothing to do with it, as no dhcp related services are running on the server.

It is actually Virtuozzo/OpenVZ, which rewrites the file on every reboot. This could only be changed on the host OS, not in the guest. Since I cannot change the settings at the hosting company, I have to deal with this from within the guest.

A workaround I found was to use Debian’s package ‘resolvconf’, which can be configured to rewrite resolv.conf as needed. Alternatively, on other distros, a simple startup script could accomplish the same purpose, by prepending the nameservers from Webmin’s configuration.

I believe, that this could be fixed within Webmin/Virtualmin, if it would be more aware that it is running inside a VPS. Currently, Virtualmin makes no attempt to deal with the idiosyncrasies of running inside a virtual environment.


The other option is to tell Virtualmin to stop checking resolv.conf, and just accept whatever nameservers it contains. This can be done by going to System Settings -> Module Config -> Advanced Options, and changing ‘Check resolv.conf for this system?’ to ‘No’.

However, be sure that any domain you create on the Virtualmin system is registered with your DNS registrar, or else the system will not be able to resolve those domains even though they are hosted locally. This can confuse some services, like Virtualmin’s status monitoring…

On many VPS systems, when the guest/vm is rebooted, the host/node rewrites /etc/resolv.conf

One way to counter this is to write resolv.conf yourself from /etc/rc.local