mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-20 12:39:06 +01:00
Sort IPv4 routing tables in 'show routing'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
7d1bb30175
commit
b7235cebb0
@ -410,6 +410,34 @@ save_config() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Recent Linux systems seem to like to print a randomly-ordered
|
||||||
|
# view of routing tables. This hack sorts the output into the
|
||||||
|
# order we all know and love
|
||||||
|
#
|
||||||
|
sort_routes() {
|
||||||
|
local dest
|
||||||
|
local rest
|
||||||
|
local crvsn
|
||||||
|
|
||||||
|
while read dest rest; do
|
||||||
|
if [ -n "$dest" ]; then
|
||||||
|
case "$dest" in
|
||||||
|
default)
|
||||||
|
echo "00 $dest $rest"
|
||||||
|
;;
|
||||||
|
*/*)
|
||||||
|
crvsn=${dest#*/}
|
||||||
|
printf "%02d %s\n" $crvsn "$dest $rest"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "32 $dest $rest"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done | sort -r | while read dest rest; do echo $rest; done
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Show routing configuration
|
# Show routing configuration
|
||||||
#
|
#
|
||||||
@ -424,7 +452,7 @@ show_routing() {
|
|||||||
if [ $g_family -eq 6 ]; then
|
if [ $g_family -eq 6 ]; then
|
||||||
ip -$g_family -o route list table $table | fgrep -v cache
|
ip -$g_family -o route list table $table | fgrep -v cache
|
||||||
else
|
else
|
||||||
ip -4 route list table $table
|
ip -4 -o route list table $table | sort_routes
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -434,7 +462,11 @@ show_routing() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
heading "Routing Table"
|
heading "Routing Table"
|
||||||
ip -$g_family route list
|
if [ $g_family -eq 6 ]; then
|
||||||
|
ip -$g_family -o route list | fgrep -v cache
|
||||||
|
else
|
||||||
|
ip -4 -o route list table $table | sort_routes
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user