Open yuxincs opened 1 year ago
You can add an ipv6 route by yourself in /etc/config/network Something like:
config route6
option interface 'wgc0'
option target '::/0'
option metric '256'
option table 'pbr_wgc0'
Adapt interface and table to your config. Make sure to set option masq6 '1' in your wg/vpn zone config. Make sure forwarding is allowed from your lan to wg/vpn zone. Setup your pbr rules as usual and it should work for both ipv4 and ipv6. No need to disable prefix delegation. pbr setups the proper rules but no default routing table, so you have to setup it by yourself as described above.
@schm0 Thanks a lot! that indeed fixed the issue!
Keeping this issue open for pbr to add default routing table
You can add an ipv6 route by yourself in /etc/config/network Something like:
config route6 option interface 'wgc0' option target '::/0' option metric '256' option table 'pbr_wgc0'
Adapt interface and table to your config. Make sure to set option masq6 '1' in your wg/vpn zone config. Make sure forwarding is allowed from your lan to wg/vpn zone. Setup your pbr rules as usual and it should work for both ipv4 and ipv6. No need to disable prefix delegation. pbr setups the proper rules but no default routing table, so you have to setup it by yourself as described above.
@schm0 is it something you believe pbr should be adding to the tables it creates?
Without a proper route this obviously can't work. PBR copies the routes already in place. For WAN/WAN6 this is no problem because there is usually already a "catchall" default route in place (0.0.0.0, ::/0) But for tunnel connections in combination with policy based routing this is most likely not the case because it would route all traffic through the tunnel and that defeats the purpose of policy based routing.
I don't know... PBR creates it own tables anyway.... Why not use 0.0.0.0, ::/0 for those?
The question is... why does the ipv4 pbr_wgc0 table has a 0.0.0.0 target but the ipv6 one has no ::/0 target?
Without a proper route this obviously can't work. PBR copies the routes already in place. For WAN/WAN6 this is no problem because there is usually already a "catchall" default route in place (0.0.0.0, ::/0) But for tunnel connections in combination with policy based routing this is most likely not the case because it would route all traffic through the tunnel and that defeats the purpose of policy based routing.
I don't know... PBR creates it own tables anyway.... Why not use 0.0.0.0, ::/0 for those?
The question is... why does the ipv4 pbr_wgc0 table has a 0.0.0.0 target but the ipv6 one has no ::/0 target?
Would something like this work then? Nevermind the Makefile changes, just the extra line in the init script?
Can you explain what your intention with this change is?
Going through all that code is a bit much.
|| ipv4_error=1
this should be ipv6_error=1 ?
I'm trying to figure out why the pbr tables for IPv4 do have a 0.0.0.0 target but the IPv6 don't have a ::/0 target. Did pbr copy the IPv4 route from the wan interface? Or where does this come from?
Isn't it just easier to let pbr create tables with 0.0.0.0 and ::/0 ? What is the actual reason to copy the routes over to the pbr route tables?
Bumping this issue.
In the meantime, creating a static route sort of works. Except, when reloading pbr I have to disable then re-enable the rule to get ipv6 connectivity again.
Maintainer: @stangri (find it by checking history of the package Makefile) Environment: (put here arch, model, OpenWrt version) X86 in a proxmox vm, openwrt 22.03.5, pbr version: 1.1.1-7 using nft
Description:
I'm running a wireguard client and server in openwrt, and I'm using pbr to only route my trusted network (
192.168.2.0/24
,fd00::1ced:cafe::20/64
) through the VPN client, everything else can go through WAN.So I added a policy to route
192.168.2.0/24 fc00:1ced:cafe::20/64
throughvpn
interface in the prerouting chain, and the ipv6 support is enabled. After this, I was able to get VPN working for ipv4 (tested on my dev machine in trusted zone), however, I couldn't access any ipv6 sites, andping6 google.com
hangs forever:Then I ran
/etc/init.d/pbr status
on the openwrt host and sawSo it seems that an ipv6 default route to the VPN client is not properly setup. I must admit that I don't have too much knowledge of ipv6 routing in general, but I'm more than happy to hack the script for further debugging if given a direction!
More background information:
My VPN provider unfortunately only hands out /128 ipv6 ULA, so I had to run NAT66 (masquerade for ipv6 on the vpn client zone in firewall settings). Maybe that makes ipv6 routing a little bit more complex. Moreover, I had to disable ipv6 delegation from my ISP (ipv6 prefix filter set to
local
on trusted interface) and disable source routing on wan6 interface as well.Just for sake of debugging, I removed pbr and used the default route (set route_allowed_ips in the wireguard client) for the VPN client and ipv6 works as expected, so the VPN client setup should be OK.
Here's the entire output from
/etc/init.d/pbr status
, hope that helps!Redacted information: