From f3ecbc185c72ddbe695f0eb52860d113cdbc4dee Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 3 Jan 2019 11:22:15 -0800 Subject: [PATCH] Add Netmanager gateway detection Signed-off-by: Tom Eastep --- Shorewall/Perl/lib.runtime | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Shorewall/Perl/lib.runtime b/Shorewall/Perl/lib.runtime index f2036c8fb..f5cfb8454 100644 --- a/Shorewall/Perl/lib.runtime +++ b/Shorewall/Perl/lib.runtime @@ -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 }