Prevent resolv.conf overwrite by DHCP

Kernels & Hardware, configuring network, installing services

Prevent resolv.conf overwrite by DHCP

Postby corsairetc » 2017-10-26 04:43

Hello,
I am using bind+isc-dhcp-server, my ISP give me IP by DHCP. I need entry in resolv.conf:
domain mydomain.local
search mydomain.local
nameserver 127.0.0.1

Every refresh od DHCP overwrite resolv.conf back to ISP nameservers. How can I prevet this ?
Thank you for help.
corsairetc
 
Posts: 69
Joined: 2014-11-14 05:30

Re: Prevent resolv.conf overwrite by DHCP

Postby Head_on_a_Stick » 2017-10-26 05:39

Install the resolvconf package and set the nameservers in /etc/network/interfaces, see interfaces(5) for details.

I've never used isc-dhcp-server but you may be able to stop it over-writing /etc/resolv.conf by editing /etc/dhcp/dhcpd.conf, I know that is possible with Debian's usual dhclient package.

Also, even if your ISP uses DHCP it may still be possible to define static addresses if you prefer.

Finally, bind is extemely crusty, have you tried unbound? :mrgreen:
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6666
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Prevent resolv.conf overwrite by DHCP

Postby corsairetc » 2017-10-26 06:28

Thank you,
I can set dns-nameservers to interfaces but I need also domain and search.
Bind works good. Before I using dnsmasq. Now I have more interfaces and network and need zones with ddns to isc-dhcp-server.
corsairetc
 
Posts: 69
Joined: 2014-11-14 05:30

Re: Prevent resolv.conf overwrite by DHCP

Postby corsairetc » 2017-10-26 07:00

Solved, here is how to:
sudo nano /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
Type this to file nodnsupdate:
Code: Select all
#!/bin/sh
make_resolv_conf(){
    :
}

Make it exacutable:
sudo chmod +x nodnsupdate
Reboot. It is done after reboot all entry I manually add to resolv.conf stay.

Hope this will be usefull for others.
corsairetc
 
Posts: 69
Joined: 2014-11-14 05:30

Re: Prevent resolv.conf overwrite by DHCP

Postby sunrat » 2017-10-27 00:13

Alternatively you can set the DNS servers with a line in dhclient.conf:
Code: Select all
supersede domain-name-servers 208.67.222.222,208.67.220.220;

That's for OpenDNS so replace with your desired IP addresses.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!
User avatar
sunrat
 
Posts: 2035
Joined: 2006-08-29 09:12
Location: Melbourne, Australia


Return to System configuration

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable