Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 8
    Wow, this is exactly what I was looking for. In case anyone is looking, for RH-based distros, you can put the relevant rule and route commands in files named 'rule-eth0' or 'route-eth0' (for example) which will be added or removed on ifup/ifdown. Place these files alongside the ifcfg-eth0 file. For IPv6, there is 'route6-eth0' functionality built in, but no 'rule6-eth0' built in (yet). Commented Dec 30, 2011 at 3:58
  • 26
    For me it worked only when I left out the dev param in the ip rule command, so running ip rule add from <interface_IP> table isp2 Commented Dec 13, 2015 at 17:09
  • 2
    You can make these be created when the interface goes up by adding up ip rule add from <interface_IP> table isp2 and up ip route add default via <gateway_IP> dev ppp0 table isp2 to your /etc/network/interfaces under the relevant interface. Commented Apr 5, 2016 at 4:59
  • 6
    I had to remove dev <interface> from ip rule to get it to work on my box. If I’m understanding right, dev <interface> was filtering out packets which were somehow set on the wrong interface which needed to be wrested over to the correct interface by the overridden route but the rule filtering by interface was preventing that from happening. Commented Oct 2, 2016 at 3:52
  • 2
    Like most other people, I had to remove dev <interface> from the ip rule command for this to work. Please update the answer ! Except for that detail, it worked like a charm. Thanks a lot, @Peter ! Commented May 14, 2018 at 9:09