I'm trying to have the following rule and route added automaticaly on boot. Adding them manually make things work. I'm running CentOS.

ip rule add from dev my-tun table my-table
ip route add default via dev eth0 table my-table

I've added this to /etc/iproute2/rt_tables

1234    my-table

I've added this to /etc/sysconfig/network-scripts/rule-my-tun

from table my-table

I've added this to /etc/sysconfig/network-scripts/route-my-tun

default via dev eth0 table my-table

But when reboot the route and rule does not figure in ip rule list and ip route list - only after I've added them manually again. The table seems to be added correctly.

I have to mention, the my-tun is created by an application, so perhaps the interface is simply not existing when I try to add the route and rule - but I have no clue...

  • Any help would be appreciated... From what I can read this should be the correct way... But doesn't reflect on reboot. – Alfred Balle Jun 18 '18 at 8:17

I think that you don't have your default definition created "permanently" for your "route-eth0" file, which would just be:

default via dev eth0 table my-table

Here's a CentOS based description of configuring both temporary and permanent routes: https://my.esecuredata.com/index.php?/knowledgebase/article/2/add-a-static-route-on-centos

Let me know if this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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