How to View the IP routing table

Orlo asked:

How can I see ip routes I’ve added with ip route add default via x.x.x.55 table test1
for example I added 199 test1 and 198 test2 and 197 test3 to /etc/iproute2/rt_tables

then I run:

ip route add default via x.x.x.55 table test1
ip route add default via x.x.x.55 table test2
ip route add default via x.x.x.55 table test3

then when I check route -n, this is the only thing I see

x.x.x.x   0.0.0.0         255.255.255.224 U     0      0        0 tun0

additional test

ip route flush x.x.x.55
ip route add default via x.x.x.55 table test1
RTNETLINK answers: File exists

Where is the test1, test2 and test3 I’ve added?

My answer:


Stop using the netstat and route commands, they will just confuse you and they don’t have the necessary functionality anyway.

To view the basic IPv4 routing table:

ip route

To view a specific table:

ip route list table test1

To view everything:

ip route list table all

And remember that these arguments can be abbreviated as long as they remain uniquely identifiable:

ip r l t all

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.