Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Prevent resolv.conf overwrite by DHCP

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
corsairetc
Posts: 73
Joined: 2014-11-14 05:30

Prevent resolv.conf overwrite by DHCP

#1 Post by corsairetc »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Prevent resolv.conf overwrite by DHCP

#2 Post by Head_on_a_Stick »

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:
deadbang

corsairetc
Posts: 73
Joined: 2014-11-14 05:30

Re: Prevent resolv.conf overwrite by DHCP

#3 Post by corsairetc »

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: 73
Joined: 2014-11-14 05:30

Re: Prevent resolv.conf overwrite by DHCP

#4 Post by corsairetc »

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.

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: Prevent resolv.conf overwrite by DHCP

#5 Post by sunrat »

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!

Post Reply