
dhclient-script(8) defines the enter hook path is /etc/dhcp/dhclient-enter-hooks: "On after defining the make_resolv_conf function, the client script checks for the presence of an executable /etc/dhcp/dhclient-enter-hooks script, and if present, it invokes the script inline, using the Bourne shell command." This was confirmed to be valid on RHEL and CentOS 7-8, and Fedora 28-30. Change-Id: I473f1e5c6862ebf0d691a8191d17649ccf51e7f4 Task: 35725 Story: 2006190
21 lines
598 B
Bash
Executable File
21 lines
598 B
Bash
Executable File
#!/bin/bash
|
|
echo "" > /etc/resolv.conf
|
|
echo "" > /etc/resolv.conf.ORIG
|
|
if [ -d /etc/dhcp/dhclient-enter-hooks.d ]
|
|
then
|
|
# Debian/Ubuntu
|
|
echo "#!/bin/sh
|
|
make_resolv_conf() { : ; }" > /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
|
|
chmod +x /etc/dhcp/dhclient-enter-hooks.d/noresolvconf
|
|
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolvconf
|
|
else
|
|
# RHEL/CentOS/Fedora
|
|
echo "#!/bin/sh
|
|
make_resolv_conf() { : ; }" > /etc/dhcp/dhclient-enter-hooks
|
|
chmod +x /etc/dhcp/dhclient-enter-hooks
|
|
fi
|
|
|
|
if [ -e /etc/nsswitch.conf ]; then
|
|
sed -i -e "/hosts:/ s/dns//g" /etc/nsswitch.conf
|
|
fi
|