Created
June 29, 2018 20:01
-
-
Save ilyaevseev/eead03df5b6eb3c789b712701d579a6a to your computer and use it in GitHub Desktop.
Quick and dirty update-resolv-conf for OpenVPN under Fedora
This file contains hidden or 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 | |
test -z "$dev" && exit 0 | |
DNS="$(printenv | awk '/^foreign_option_.*=dhcp-option DNS / { print $NF; exit; }')" | |
test -z "$DNS" && exit 0 | |
# Error: Reading applied connection from device 'tun0' (/org/freedesktop/NetworkManager/Devices/6) failed: Device is not activated | |
# When called manually after connection esablished: removes all routes! | |
#/usr/bin/nmcli dev modify "$dev" +ipv4.dns $DNS | |
# Quick and dirty workaround: | |
case "$script_type" in | |
up ) sed -i "1i nameserver $DNS" /etc/resolv.conf ;; | |
down ) sed -i "/^nameserver $DNS\$/d" /etc/resolv.conf ;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment