How to handle DHCP and BIND ?


The hoster of my server supplies IP by DHCP to server (both public IPs and local RPN ones). But when I check configuration of my server it states me that:

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. It appears that DHCP is being used to dynamically configure your network interfaces, which can cause the DNS servers to be set based on settings provided by the DHCP server. Using a static IP address is strongly recommended with Virtualmin.

If I add in resolv.conf it’s automatically deleted by system and I have to keep network port in DHCP or it’s going to get a problem with the hoster of servers (Online in France, ex Dédibox).



Not sure what OS but this quick and little trick should work on any OS:

  1. Open /etc/rc.local or /etc/rc.d/rc.local
  2. Add at the bottom /bin/cp /root/.resolv/resolv.conf /etc/resolv.conf
  3. Be sure you left one empty line at the end of rc.local file
  4. Save and close
  5. Check if rc.local is executable (755)
  6. Now create the file in /root/.resolv/resolv.conf (or whatever location did you select)
  7. Fill in and keep in this order

    search domain1.tld domain2.tld domain3.tld <---- This is optional, it should work without this line
    nameserver <---- Must have
    nameserver <---- Must have, google public DNS
    nameserver <---- Must have, google public DNS
    nameserver <---- This is your server IP

  8. Save and close
  9. Restart your server and check if it works

This little trick will copy resolv.conf every time when you restart your server and it will happen after DHCP make the changes but before anything else, e.g. starting up bind.

Thanks for the trick and I was thinking about something but don’t find it really nice :frowning:

In the meantime I found nearly the way to do it in correct way :wink:

Edit the /etc/dhcp/dhclient.conf (Ubuntu 16.04) and I added these two lines:
supersede domain-name “”;
supersede domain-name-servers;

My only issue is I’m confused by syntax for DNS servers. It’s supposed to accept each DNS separated by a comma but in my case it only considers first dns listed and that’s it :frowning:

Eh Ubuntu, maybe is the best if you wait for @unborn to jump in this topic. If i’m not mistaken he is the “Ubuntu guy”. :slight_smile:

So lost as I tried different syntaxes without much success and confused as syntax with commas looks the good one…

Desperate to resolve that stupid issue :frowning: Made lot of searches on internet and tried lot of things without success :frowning: