Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
So, an invalid name gives you an error, but an invalid integer gives you 255? Also, I assume that 255 was the previous max (in 2.4 maybe?) but was increased to a 32-bit number in kernel 2.6? –  Bob Sep 27 '11 at 18:07
    
Yes, the max in 2.4 and 2.2 was 255. –  Ciclamino Sep 27 '11 at 19:36
    
Also, always showing table 255 for values with the 32nd bit doesn't appear to be any sort of planned behaviour, just a bug. With a one line patch to iproute I was able to create and show a table with number 4294967290. However, it may not be as simple as that, there may other pieces that still don't deal with 2^32 tables. –  Ciclamino Sep 27 '11 at 20:02
    
Accepted, thanks. Maybe you should submit your patch :) –  Bob Oct 6 '11 at 11:41

Well, I can't comment, but I did want to note the following:

~# ip route list table 79456894975
~# ip route list table 79456894976
... stuff that appears to be table 0 ...

So it looks 79456894976 is the highest unique routing table number.

Also, number > 79456894976 all seem to show route table 0. I don't know where the limit comes in, but that appears to be the practical limit.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.