summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-misc/openvpn/files/up.sh')
-rwxr-xr-xnet-misc/openvpn/files/up.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/net-misc/openvpn/files/up.sh b/net-misc/openvpn/files/up.sh
index f950577532b7..0a18876aae93 100755
--- a/net-misc/openvpn/files/up.sh
+++ b/net-misc/openvpn/files/up.sh
@@ -11,11 +11,19 @@
# and will use the first one that responds - maybe the LAN ones?
# non resolvconf users just the the VPN resolv.conf
-DNS="$(set | sed -n "s/^foreign_option_.* DNS \(.*\)'/nameserver \1/; T next; p;
- :next; s/^foreign_option_.* DOMAIN \(.*\)'/domain \1/; T; p;")"
+NS=
+DOMAIN=
+for var in ${!foreign_option_*} ; do
+ opt="${!var}"
+ if [[ ${opt} =~ "dhcp-option DOMAIN (.*)" ]] ; then
+ DOMAIN="${DNS}domain ${BASH_REMATCH[1]}\n"
+ elif [[ ${opt} =~ "dhcp-option DNS (.*)" ]] ; then
+ NS="${DNS}nameserver ${BASH_REMATCH[1]}\n"
+ fi
+done
-if [[ -n ${DNS} ]] ; then
- DNS="# Generated by openvpn for interface ${dev}\n${DNS}"
+if [[ -n ${NS} ]] ; then
+ DNS="# Generated by openvpn for interface ${dev}\n${DOMAIN}${NS}"
if [[ -x /sbin/resolvconf ]] ; then
echo -e "${DNS}" | /sbin/resolvconf -a "${dev}"
else