dhclient hook not overwritten /etc/resolv.conf

Reindl Harald h.reindl at thelounge.net
Thu Dec 19 09:28:48 UTC 2019



Am 19.12.19 um 10:01 schrieb Zhengyu Pan:
> My OS is Centos7. I add a bash script dns.sh in
> /etc/dhcp/dhclient-exit-hooks.d . The script content is
> 
> #!/bin/bash
> echo“nameserver1.1.1.1”>>/etc/resolv.conf
> 
> I want to append a nameserver in /etc/resove.conf.
> However, when I restart network. /etc/resove.conf not changed.
> /etc/resove.conf.save append this line. 
> Why happens that? How can I append a nameserver in /etc/resove.conf?

not a named qurstion at all, however

becasue something overwrote /etc/resolv.conf after your script which
maybe means your script runs way too early

chattr +i /etc/resove.conf under normal conditions

chattr -i /etc/resove.conf at the start of your script
chattr +i /etc/resove.conf at the end of your script

https://www.tecmint.com/chattr-command-examples/

this is a supported way to prevent resolv.conf overwritten by whatever
stuff running on the system, be it dhclient, networkmanager or another
smartass stuff which lives in a authistic world pretend to know what my
nameservers are


More information about the bind-users mailing list