diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 72407177a..f9567c05c 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -730,7 +730,7 @@ sub start_providers() { emit ( '#', '# Capture the default route(s) if we don\'t have it (them) already.', '#', - '[ -f ${VARDIR}/default_route ] || $IP -' . $family . ' route list | grep -E \'^\s*(default |nexthop )\' > ${VARDIR}/default_route', + "[ -f \${VARDIR}/default_route ] || \$IP -$family route ls | save_default_route > \${VARDIR}/default_route", '#', '# Initialize the file that holds \'undo\' commands', '#', diff --git a/Shorewall/Perl/prog.header b/Shorewall/Perl/prog.header index 7461fa468..3c37d43a6 100644 --- a/Shorewall/Perl/prog.header +++ b/Shorewall/Perl/prog.header @@ -504,6 +504,17 @@ undo_routing() { } +# +# Save the default route +# +save_default_route() { + awk \ + 'BEGIN {default=0;}; \ + /^default / {default=1; print; next}; \ + /nexthop/ {if (default == 1 ) {print ; next} }; \ + { default=0; };' +} + # # Restore the default route that was in place before the initial 'shorewall start' # diff --git a/Shorewall/Perl/prog.header6 b/Shorewall/Perl/prog.header6 index 588fd89b8..e708e88d4 100644 --- a/Shorewall/Perl/prog.header6 +++ b/Shorewall/Perl/prog.header6 @@ -492,6 +492,17 @@ undo_routing() { } +# +# Save the default route +# +save_default_route() { + awk \ + 'BEGIN {default=0;}; \ + /^default / {default=1; print; next}; \ + /nexthop/ {if (default == 1 ) {print ; next} }; \ + { default=0; };' +} + # # Restore the default route that was in place before the initial 'shorewall start' #