2

I'm trying to persist (between reboots) routes and rules from iproute2 in Alpine Linux, so far without success.

Here are the commands:

ip route add default via 192.168.200.1 dev eth1 table net2
ip rule add from 192.168.200.10/24 table net2
ip rule add to 192.168.200.1/32 table net2

So the proper way to do this should be theoretically by using the "post-up" callback in the "/etc/network/interfaces" file in the eth1 interface. So I added these lines to the interface:

post-up route add default via 192.168.200.1 dev eth1 table net2
post-up ip rule add from 192.168.200.10/24 table net2
post-up ip rule add to 192.168.200.1/32 table net2

But it doesn't works. It seems like the callback is never run. The same goes with "up". I tried a simple "touch /tmp/ok" and the file gets never created.

Alternatively I tried creating a script inside the "/etc/network/if-post-up.d" but the script gets called for every interface that goes up, resulting in repeated entries in the rules. What would be the right way to make this work properly (With that I mean run the rule only once when the interface goes up, and undo the rules when it goes down).

1
  • 1
    Alpine is a very cut down distribution, and some of the rules of Debian might not apply. The if-post-xxxx might also be a construct of a particular DHCP client. Dec 8, 2018 at 19:36

1 Answer 1

1

Edit the static routes file in /etc/conf.d/staticroute

Ensure staticroute starts at boot time in order to reload those configs, with:

rc-update add staticroute

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .