]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
*BSDs: get_default_gw needs to EXCLUDE routes through tunnel for attempt-reconnect...
authorDaniel Lenski <dlenski@gmail.com>
Tue, 15 Dec 2020 01:40:23 +0000 (17:40 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Thu, 17 Dec 2020 00:26:19 +0000 (16:26 -0800)
See explanation here: https://gitlab.com/openconnect/vpnc-scripts/-/commit/ecf656700c283267912a7c073bb75e8100064316#note_466648051

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
vpnc-script

index 0e20a0f4d4ac6231238b403ebdefbe54aa23e50f..726f23ead3817e0b660fc98d32097c07816af755 100755 (executable)
@@ -399,6 +399,10 @@ else # use route command
                # apperently not...
                # Get rid of lines containing IPv6 addresses (':')
                # Get rid of lines for link-local routes (https://superuser.com/a/1067742)
+               netstat -r -n | awk '/:/ { next; } /link\#/ { next; } /^(default|0\.0\.0\.0([[:space:]]|\/0))/ { print $2; exit; }'
+       }
+
+       get_default_gw_excl_tunnel() {
                # Get rid of lines containing $TUNDEV (we don't want loopback)
                netstat -r -n | awk '/:/ { next; } /link\#/ { next; } /[[:space:]]'"$TUNDEV"'([[:space:]]|$)/ { next; } /^(default|0\.0\.0\.0([[:space:]]|\/0))/ { print $2; exit; }'
        }
@@ -414,7 +418,10 @@ else # use route command
        }
 
         set_vpngateway_route_attempt_reconnect() {
-               set_vpngateway_route
+               case "$VPNGATEWAY" in
+               *:*)    route add $route_syntax_inet6_host "$VPNGATEWAY" $route_syntax_gw "`get_ipv6_default_gw_excl_tunnel`";;
+               *)      route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw_excl_tunnel`";;
+               esac
         }
 
        del_vpngateway_route() {
@@ -492,6 +499,10 @@ else # use route command
                netstat -r -n $netstat_syntax_ipv6 | awk '/^(default|::\/0)/ { if ($NF!~/^lo/) { print ($2~/^fe[89ab]/ ? $2"%"$NF : $2); } }'
        }
 
+       get_ipv6_default_gw_excl_tunnel() {
+               netstat -r -n $netstat_syntax_ipv6 | awk '/^(default|::\/0)/ { if ($NF!~/^lo/ && /$NF!~/'"$TUNDEV"'([[:space:]]|$)/) { print ($2~/^fe[89ab]/ ? $2"%"$NF : $2); } }'
+       }
+
        set_ipv6_default_route() {
                DEFAULTGW="`get_ipv6_default_gw`"
                echo "$DEFAULTGW" > "$DEFAULT_ROUTE_FILE_IPV6"