Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created June 29, 2018 20:01
Show Gist options
  • Save ilyaevseev/eead03df5b6eb3c789b712701d579a6a to your computer and use it in GitHub Desktop.
Save ilyaevseev/eead03df5b6eb3c789b712701d579a6a to your computer and use it in GitHub Desktop.
Quick and dirty update-resolv-conf for OpenVPN under Fedora
#!/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