Question regarding PBR order when setting up VPN Client

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

MvW

Senior Member
For those who followed my previous adventures, I've set up one client, just to make sure that I'm not taking too big steps. Everything seems to work fine so far, but I just want to verify something.

I was wondering: when filling the PBR-table, does the order matter? I've entered all clients, including the router and the AIMesh Node, in order. So from the lowest last octet to the hightest last octet. But I don't even know whether that's necessary. All clients specified are being directed to the WAN, including for the router and the node. The list is closed with 192.x.x.0/24, to make sure directed towards the VPN.

And a last question: are these PBR rules stored in a file I can edit directly (specifically if the order does matter) with nano, because deleting the table every time almost completely because I forget one in the right order (yes, I have OCD*) is rather time consuming.]

*No seriously, I do, I'm officially diagnosed


Screenshot_2021-04-11 ASUS Wireless Router RT-AC86U - OpenVPN Client Settings.png
 

eibgrad

Very Senior Member
The order as specified in the list does NOT matter. It's an unordered list. What does matter is the network interface chosen. Those rules which specify the WAN always take precedence over those that specify the VPN.

So …

Code:
192.168.1.0/24 VPN
192.168.1.1 WAN

and …

Code:
192.168.1.1 WAN
192.168.1.0/24 VPN

… are exactly the same. Either way, 192.168.1.1 is going to get routed out the WAN since it has precedence based on network interface, NOT its ordering in the list.

When you add additional OpenVPN clients (2, 3, …), the low-numbered VPN clients take precedence over the higher-numbered VPN clients.

So you don't need to worry about how the lists are ordered, but more importantly which VPN client takes precedence over the other should there be any overlap/redundancy in your rules between multiple VPN clients.
 

eibgrad

Very Senior Member
P.S. If you want/need to verify any of this, you can use ssh to dump the ip rules created from your routing policy rules and see for yourself.

Code:
ip rule show

Low-numbered rules (left-most column) always take precedence over high-numbered rules in that dump. Each rule points to a particular routing table (main, ovnpc1, ovpnc2, etc.). And you can dump those as well using ssh.

Code:
ip route show table main
ip route show table ovpnc1
ip route show table ovpnc2
...

If you start rummaging through these data structures, a lot of this starts to make more sense, and it eliminates much of the mystery.
 
Last edited:
  • Like
Reactions: MvW

ColinTaylor

Part of the Furniture
From the wiki:
The "Iface" field (short for Interface) lets you determine if matching traffic should be sent through the VPN tunnel or through your regular Internet access (WAN). This allows you to define exceptions (WAN rules being processed before the VPN rules).
 
  • Like
Reactions: MvW

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top