Set different Upstream for specific source IP

I want to route everything comming from the local ip with destination internet via a VPN Interface. I tried to add and Outgoing Interface VPN under Network -> Routing -> IPv4 Rules but that is somehow ignored and traffic from that IP uses still the default route.

Looking at seems to be not what I need because this seems to have as goal to change the route for a target and not a specific source IP.

So if somebody could point me in the right direction I would be very gratefull.

Thank you

You need to do Policy Based Routing and you have 3 options:

  1. mwan3 package
  2. pbr package
  3. a set of rules/routes for each internet connection.

In your case you have not filled in the rule properly. You need to specify Incoming Interface, Source IP, and the Table. Then in static IPv4 Routes you need to add a default route and any local routes for that Table.

In addition to the above perhaps this example might help provide inspiration:

The idea is to set a routing table for each interface and then set rules for routing packets through each interface.

I think the reason your rule above doesn't work is because it lacks a routing table for VPN.

So I think you should label tables as described here:

Here are mine:

root@OpenWrt:~# cat /etc/iproute2/rt_tables
# reserved values
128     prelocal
255     local
254     main
253     default
0       unspec
# local
#1      inr.ruhep

1 br-lan
2 br-guest
3 vpn
4 wan

And then in LuCi assign tables to the interfaces.

And then set up rules in LuCi like you have been doing, only be sure to specify the appropriate routing table for each rule.

And if you want to use CAKE for sqm in this context consider this very simple script rather than the default package:

@trendy I believe OpenWrt somehow automatically sets up routing table entries with the above. At least it did for me.

I really like this approach because it is elegantly simple and allows a lot of manual customisation.


Ok thanks for the input, that looks promising but will need some time to set this up with 13 zones

1 Like

It could be like this, but I don't have 22.03 and I cannot tell, so I'll take your word for it.

Thanks Lynx, your answer did work I just was confused for a long time that everything would stop working as soon as I added the rules but that was because with the custom routing table intervlan routing does break if you don't exempt local IPs.

1 Like

I am glad this worked out!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.