How to stop resolv.conf from being updated

如何不讓/etc/resolv.conf組態被更動

Comment out the following lines from /sbin/dhclient-script

make_resolv_conf() {
if [ x"$new_domain_name_servers" != x ]; then
if [ "x$new_domain_name" != x ]; then
echo search $new_domain_name >/etc/resolv.conf
else
rm /etc/resolv.conf
fi
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
fi
}

This will prevent dhcp from making a new /etc/resolv.conf file (on boot,
re-boot). Whatever nameserver you enter in /etc/resolv.conf will stay put.

(I had to take this approach some years ago when I was using an apple airport
basestation as my gateway, and the dhcp server software kept assigning
10.0.1.1 as my nameserver in /etc/resolv.conf.)

Check the dhclient.conf man page, too, for less drastic measures.

You could always use chflags to make the file un-writeable... Tho' there
is probably a better solution

#chflags schg /etc/resolv.conf


In ext2/ext3 file system, we can type following commands to
avoid changing
resolv.conf (then resolv.conf will be read only.):

# chattr +i /etc/resolv.conf
# lsattr /etc/resolv.conf
----i--------- /etc/resolv.conf





arrow
arrow
    全站熱搜

    Bluelove1968 發表在 痞客邦 留言(0) 人氣()