Implementing Policy-Based Routing for Tailscale and WireGuard on OpenWRT

Well, the problem is tailscale table priority (5270) is always lower value than the PBR tables(30000-30001), so it always get prioritized before it even hit the PBR decision:

root@LAM_BUT:~# ip rule show
0:      from all lookup local
5210:   from all fwmark 0x80000/0xff0000 lookup main
5230:   from all fwmark 0x80000/0xff0000 lookup default
5250:   from all fwmark 0x80000/0xff0000 unreachable
5270:   from all lookup 52
30000:  from all fwmark 0x10000/0xff0000 lookup pbr_wanb
30001:  from all fwmark 0x20000/0xff0000 lookup pbr_tailscale
32766:  from all lookup main
32767:  from all lookup default

The only way to make it work is to change the priority to be higher value than the BPR tables, however this change is not persistent and you will have to do it everytime you reboot the OpenWRT router.