-
Notifications
You must be signed in to change notification settings - Fork 154
Open
Description
# - - - - - - - - - - -
copy_routing_table () {
# - - - - - - - - - - -
#
# -- accepts one paramater:
#
# $1: table identifier for the routing table to create
#
test "$#" -lt "1" && return
DTABLE=$1
test "$#" -gt "1" && STABLE="$2"
test "$STABLE" = "" && STABLE="main"
ip route flush table $DTABLE
ip route show table $STABLE | grep -Ev '^default' \
| while read ROUTE ; do
ip route add table $DTABLE $ROUTE
done
}
It will not work when an equivalent route exists in the routing table, For example:
[root@k8s-master topo_build]# ip route show
1.1.1.1 proto 188 metric 20
nexthop via 10.0.0.2 dev tun1 weight 1
nexthop via 10.0.2.2 dev tun3 weight 1
2.0.0.2 proto 188 metric 20
nexthop via 10.0.1.2 dev tun2 weight 1
nexthop via 10.0.3.2 dev tun4 weight 1
it will not work when we take routing in this way, It splits a route that occupies three rows into three routes...
[root@k8s-master topo_build]# ip route show | while read ROUTE; do echo [${i}] $ROUTE; let i++; done
[] 1.1.1.1 proto 188 metric 20
[1] nexthop via 10.0.0.2 dev tun1 weight 1
[2] nexthop via 10.0.2.2 dev tun3 weight 1
[3] 2.0.0.2 proto 188 metric 20
[4] nexthop via 10.0.1.2 dev tun2 weight 1
[5] nexthop via 10.0.3.2 dev tun4 weight 1
Metadata
Metadata
Assignees
Labels
No labels