Skip to content

Possibly inadvertent script in LDP/LDP/guide/docbook/linux-ip/scripts/copy-routing-table.sh #91

@huangy7

Description

@huangy7
# - - - - - - - - - - -
  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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions