Add Netmanager gateway detection

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2019-01-03 11:22:15 -08:00
parent a71a44346e
commit f3ecbc185c
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10

View File

@ -874,6 +874,7 @@ detect_dynamic_gateway() { # $1 = interface
GATEWAYS=
local gateway
local file
local nmcli
gateway=$(run_findgw_exit $1);
@ -897,6 +898,14 @@ detect_dynamic_gateway() { # $1 = interface
fi
done
if [ -z "$gateway" -a -n "$(mywhich nmcli)" ]; then
if [ $g_family = 4 ]; then
gateway=$(nmcli --fields DHCP4.OPTION,IP4.GATEWAY device show ${1} 2> /dev/null | sed -rn '/( routers = |IP4.GATEWAY:.*[1-9])/{s/.* //;p;q}')
else
gateway=$(nmcli --terse --fields IP6.GATEWAY device show ${1} 2> /dev/null | cut -f2- -d':')
fi
fi
[ -n "$gateway" ] && echo $gateway
}