From 0a05dfb6615313ab0b0b8cd9f190e4d3a088694e Mon Sep 17 00:00:00 2001 From: Bapt Abl Date: Wed, 10 Nov 2021 02:32:21 +0100 Subject: [PATCH 1/2] Better setting of new_internet_device --- conf/ynh-hotspot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index 9e4cb52..374c363 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -327,7 +327,7 @@ if [ "$1" != restart ]; then done old_internet_device=$(ynh_setting_get hotspot internet_device) - new_internet_device=$(ip route | awk '/default via/ { print $NF; }') + new_internet_device=$(ip --json route | jq -r '.[] | select(.dst == "default") | .dev') # Switch the NAT interface if there is a VPN ip link show dev tun0 &> /dev/null From b41ad50c5bfde04465f3a2e71b1b4bec4247efce Mon Sep 17 00:00:00 2001 From: Bapt Abl Date: Thu, 11 Nov 2021 18:20:45 +0100 Subject: [PATCH 2/2] Support any subnet for default gateway --- conf/ynh-hotspot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index 374c363..82623a9 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -327,7 +327,7 @@ if [ "$1" != restart ]; then done old_internet_device=$(ynh_setting_get hotspot internet_device) - new_internet_device=$(ip --json route | jq -r '.[] | select(.dst == "default") | .dev') + new_internet_device=$(ip route get 1.2.3.4 | awk '{ print $5; }') # Switch the NAT interface if there is a VPN ip link show dev tun0 &> /dev/null