Centos – ip route and rule on boot

centosiproute2networkingrouting

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 10.1.10.10/10 dev my-tun table my-table
ip route add default via 100.1.1.1 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 10.1.10.10/10 table my-table

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

default via 100.1.1.1 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…

Best Answer

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

default via 100.1.1.1 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!