Commit 7e6b3f6d authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Added configurable DNS for VPN connection

parent 2c30c7a6
......@@ -67,6 +67,11 @@ case "$${PLUTO_VERB}" in
for net in "$${SUBNETS[@]}"; do
ip route add "$net" dev "$${VTI_IF}" 2> /dev/null
done
DNS=`/sbin/uci -q get vpn.hub.dns`
if [[ -n "$$DNS" ]]; then
DNS_SERVERS=$$(echo "$$DNS" | tr ',' ' ' | xargs)
resolvectl dns $${VTI_IF} $$DNS_SERVERS
fi
sysctl -w "net.ipv4.conf.$${VTI_IF}.disable_policy=1"
networks=`printf %s "$$(ip route list proto kernel scope link | awk -F " " "{ print \\$$1 }")" | tr '\\n' ','`
if [ ! -z "$$networks" ] ; then
......@@ -94,6 +99,7 @@ define VPN_CONFIG
config vpn 'hub'
option address ''
option subnet ''
option dns ''
config ca 'issuer'
option uri ''
......
......@@ -18,6 +18,7 @@ entry_execute_method_root_VPN() {
common_execute_method_param "$DMROOT.VPN.CertificateStatus" "0" "vpn_get_certificate_status"
common_execute_method_param "$DMROOT.VPN.Hub" "1" "vpn_get_hub" "vpn_set_hub"
common_execute_method_param "$DMROOT.VPN.Subnet" "1" "vpn_get_subnet" "vpn_set_subnet"
common_execute_method_param "$DMROOT.VPN.DNS" "1" "vpn_get_DNS" "vpn_set_DNS"
common_execute_method_param "$DMROOT.VPN.Issuer" "1" "vpn_get_issuer_URI" "vpn_set_issuer_URI"
common_execute_method_param "$DMROOT.VPN.DN" "1" "vpn_get_DN" "vpn_set_DN"
return 0;
......@@ -157,6 +158,19 @@ vpn_set_subnet() {
fi
}
vpn_get_DNS() {
echo `$UCI_GET vpn.hub.dns`
}
vpn_set_DNS() {
local dns=`$UCI_GET vpn.hub.dns`
if [ "$dns" != "$1" ]; then
$UCI_SET vpn.hub.dns="$1"
$UCI_COMMIT
configure_ipsec
fi
}
vpn_get_issuer_URI() {
echo `$UCI_GET vpn.issuer.uri`
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment