Fix resolv-update script for MacOS (OpenVPN DNS)
script from https://github.com/andrewgdotcom/openvpn-mac-dns
This commit is contained in:
parent
5ad54bfdc1
commit
8d3e21d46a
1 changed files with 9 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Mac name-resolution updater based on @cl's script here:
|
# Mac name-resolution updater based on @cl's script here:
|
||||||
# https://blog.netnerds.net/2011/10/openvpn-update-client-dns-on-mac-os-x-using-from-the-command-line/
|
# https://blog.netnerds.net/2011/10/openvpn-update-client-dns-on-mac-os-x-using-from-the-command-line/
|
||||||
# Openvpn envvar parsing taken from the script in debian's openvpn package.
|
# Openvpn envar parsing taken from the script in debian's openvpn package.
|
||||||
# Smushed together and improved by @andrewgdotcom.
|
# Smushed together and improved by @andrewgdotcom.
|
||||||
|
|
||||||
# Parses DHCP options from openvpn to update resolv.conf
|
# Parses DHCP options from openvpn to update resolv.conf
|
||||||
|
@ -10,6 +10,8 @@
|
||||||
# up /etc/openvpn/update-resolv-conf
|
# up /etc/openvpn/update-resolv-conf
|
||||||
# down /etc/openvpn/update-resolv-conf
|
# down /etc/openvpn/update-resolv-conf
|
||||||
|
|
||||||
|
echo "*** starting update-resolv-config script ***"
|
||||||
|
|
||||||
[ "$script_type" ] || exit 0
|
[ "$script_type" ] || exit 0
|
||||||
[ "$dev" ] || exit 0
|
[ "$dev" ] || exit 0
|
||||||
|
|
||||||
|
@ -34,11 +36,11 @@ update_all_dns()
|
||||||
echo updating dns for $adapter
|
echo updating dns for $adapter
|
||||||
# set dns server to the vpn dns server
|
# set dns server to the vpn dns server
|
||||||
if [[ "${SRCHS[@]}" ]]; then
|
if [[ "${SRCHS[@]}" ]]; then
|
||||||
networksetup -setsearchdomains "$adapter" "${SRCHS[@]}"
|
networksetup -setsearchdomains "$adapter" "${SRCHS[@]}"
|
||||||
fi
|
fi
|
||||||
if [[ "${NMSRVRS[@]}" ]]; then
|
if [[ "${NMSRVRS[@]}" ]]; then
|
||||||
networksetup -setdnsservers "$adapter" "${NMSRVRS[@]}"
|
networksetup -setdnsservers "$adapter" "${NMSRVRS[@]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ case "$script_type" in
|
||||||
if [ "$part1" = "dhcp-option" ] ; then
|
if [ "$part1" = "dhcp-option" ] ; then
|
||||||
if [ "$part2" = "DNS" ] ; then
|
if [ "$part2" = "DNS" ] ; then
|
||||||
NMSRVRS=(${NMSRVRS[@]} $part3)
|
NMSRVRS=(${NMSRVRS[@]} $part3)
|
||||||
elif [ "$part2" = "DOMAIN" ] ; then
|
elif [ "$part2" = "DOMAIN" ] || [ "$part2" = "DOMAIN-SEARCH" ]; then
|
||||||
SRCHS=(${SRCHS[@]} $part3)
|
SRCHS=(${SRCHS[@]} $part3)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -72,3 +74,5 @@ case "$script_type" in
|
||||||
clear_all_dns
|
clear_all_dns
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
echo "*** finished update-resolv-config script ***"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue