Hi sunkai!
thanks for excellent script. With Zomboid VPN addons works very good (at least for NordVPN). However, connmanctl adding DNS server automaticaly adds route to this server via default gateway (ie. ethernet interface, not VPN interface). It creates problems with NordVPN where they derirect DNS according to IP address). My solutuion is to add ip route delete part. So the scrip looks following:
Code
#!/usr/bin/env sh
# Example envs set from openvpn:
# foreign_option_1='dhcp-option DNS 193.43.27.132'
# foreign_option_2='dhcp-option DNS 193.43.27.133'
# foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
# foreign_option_4='dhcp-option DOMAIN-SEARCH bnc.local'
connman_service="$(connmanctl services | awk '/^\*/ {print $3}')"
case $script_type in
up)
dns_nameservers=""
dns_search=""
option_count=1
option_name="foreign_option_${option_count}"
while eval "[ ! -z \"\${${option_name}+x}\" ]"; do
eval "option=\"\$${option_name}\""
echo $option
part1=$(echo "$option" | cut -d " " -f 1)
if [ "$part1" == "dhcp-option" ] ; then
part2=$(echo "$option" | cut -d " " -f 2)
part3=$(echo "$option" | cut -d " " -f 3)
if [ "$part2" == "DNS" ] ; then
dns_nameservers="$dns_nameservers $part3"
fi
if [[ "$part2" == "DOMAIN" || "$part2" == "DOMAIN-SEARCH" ]] ; then
dns_search="$dns_search $part3"
fi
fi
option_count=$((option_count+1))
option_name="foreign_option_${option_count}"
done
connmanctl config "$connman_service" nameservers "$dns_nameservers"
connmanctl config "$connman_service" domains "."
for dnsserver in ${dns_nameservers}; do
ip route delete $dnsserver
done
;;
down)
connmanctl config "$connman_service" nameservers ""
connmanctl config "$connman_service" domains ""
;;
esac
Display More