12

I've been working with custom route tables on Linux, and I'm a bit confused by some of the documentation and behavior of the "ip route" command. It seems that the only valid values should be 0-255 plus the names defined in /etc/iproute2/rt_tables:

255 local
254 main
253 default
0   unspec

This would leave 1-252 for custom tables. Attempting to use an undefined table name gives an error:

$ ip route show table kermit
Error: argument "kermit" is wrong: table id value is invalid

However, it seems that I can use numbers far higher than 255 without error:

$ ip route show table 1000
[no output]
$ ip route add 10.10.10.0/24 dev eth0 table 1000
[no output]
$ ip route show table 1000
10.10.10.0/24 dev eth0  scope link

At some point, things get even weirder. Right at maxint (2^31), it "overflows" into the local table (255):

$ ip route show table 2147483647
[no output]
$ ip route show table 2147483648
[exact output of table 255 (local)]

Can anyone explain what is happening? Are there actually maxint custom routing tables that can be used?

Bob
  • 223

1 Answers1

8

As far as the 2.6 kernel is concerned, the max table is 0xFFFFFFFF (from rtnetlink.h). However, iproute2 uses a signed integer in it's filter to do the lookup so at 2^31 it thinks you specified an invalid table and defaults to showing you table 255.

Ciclamino
  • 381