Created
January 26, 2018 04:29
-
-
Save wohali/636f1c4dbbd8fbffbef40dbf74901b3c to your computer and use it in GitHub Desktop.
save this as /etc/dhcp/dhclient-enter-hooks.d/no_default_route and chmod +x it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# prevent dhclient-script from setting any default route | |
# except for ens6, which is our public interface | |
INTERFACE_DEFAULT_ROUTE="ens6" | |
DEBUG_FILE="/tmp/dhclient-nodefroute.debug" | |
echo "Interface ${interface} entered DHCP because of $reason." >> $DEBUG_FILE | |
case "$reason" in | |
BOUND|RENEW|REBIND|REBOOT|TIMEOUT) | |
echo "New DHCP conenction for interface ${interface} because of $reason." >> $DEBUG_FILE | |
if [ ${interface} != $INTERFACE_DEFAULT_ROUTE ]; then | |
echo "${interface} doesn't match ${INTERFACE_DEFAULT_ROUTE}, not setting default route." >> $DEBUG_FILE | |
unset new_routers | |
else | |
echo "Allowing default route for ${interface}" >> $DEBUG_FILE | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment