systemd-resolved, resolvconf.service, resolvconf and openresolv. Why, which and how?
I managed to change the script that handles these configuration items in OpenVPN in Ubuntu (tested on 18.04). Here is a patch for that:
--- /etc/openvpn/update-resolv-conf.orig 2019-03-13 19:14:16.163914424 +0400
+++ /etc/openvpn/update-resolv-conf 2019-03-13 19:29:30.380420708 +0400
@@ -15,7 +15,7 @@
# foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
#
-[ -x /sbin/resolvconf ] || exit 0
+[ -x /usr/bin/systemd-resolve ] || exit 0
[ "$script_type" ] || exit 0
[ "$dev" ] || exit 0
@@ -43,16 +43,16 @@
fi
done
R=""
- [ "$SRCHS" ] && R="search $SRCHS
-"
+ for SRCH in $SRCHS ; do
+ R="${R}--set-domain=$SRCH "
+ done
for NS in $NMSRVRS ; do
- R="${R}nameserver $NS
-"
+ R="${R}--set-dns=$NS "
done
- echo -n "$R" | /sbin/resolvconf -a "${dev}.openvpn"
+ /usr/bin/systemd-resolve -i ${dev} ${R}
;;
down)
- /sbin/resolvconf -d "${dev}.openvpn"
+ echo "Doing nothing, interface disappears."
;;
esac
You will need to add the following items to your OpenVPN configuration file:
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf