[LARTC] iproute2: gatewayed routes in ancillary tables

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

Tomas Bonnedahl and I recently corresponded about a rather odd behaviour
with routes in ancillary routing tables.

We both receive a "Network is unreachable" error when we try to add
gatewayed routes to ancillary tables and the main routing table does not
contain an entry for the gateway IP.

It seems that unless a route to the gateway IP exists in the main routing
table, I cannot add a route through the gateway IP, even if there is a
route to the destination in the ancillary routing table.

Why is this?

Tomas has used the workaround as described in the annotated example below,
and there is no problem with this solution, but it strikes both of us as a
bit kludgy.

See the annotated example script below.

-Martin

# -- the below set of commands are annotated to describe what
#    is happening
#
# -- empty the ancillary routing table; I chose 4 as an arbitary routing
#    table--it could be any other non-main routing table
#
ip route flush table 4
#
# -- add a route to a locally reachable destination into table 4
#    this command succeeds
#
ip route add 192.168.237.0/24 dev eth0 table 4
#
# -- adding a gatewayed route fails, returning this error message:
#
#   RTNETLINK answers: Network is unreachable
#
ip route add default via 192.168.237.1 table 4
#
# -- even a route to a non-default route....same error:
#
ip route add 192.168.236.0/24 via 192.168.237.1 table 4
#
# -- now, if we put a route for our locally connected network into
#    the main routing table....
#
ip route add 192.168.237.0/24 dev eth0 table main
#
# -- and try to add a gatewayed route to table 4, it works!
#    same with a default route (just another gatewayed route)
#
ip route add 192.168.236.0/24 via 192.168.237.1 table 4
ip route add default via 192.168.237.1 table 4
#
# -- now, if we remove the route from table main,
#    things still operate as we had initially desired
#
ip route del 192.168.237.0/24 dev eth0 table main
#
# -- when we display the routing table it looks exactly like we want
#
ip route show table 4
#
# -- should look like this:
#
#   192.168.236.0/24 via 192.168.237.1 dev eth0
#   192.168.237.0/24 dev eth0  scope link
#   default via 192.168.237.1 dev eth0

-- 
Martin A. Brown --- SecurePipe, Inc. --- mabrown@xxxxxxxxxxxxxx



[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux