I'm having a really hard time getting the following to work:
Problem 1. I cannot get 2 wireguard vpns running at the same time.
Problem 2. I cannot get lan -> vpn1 and wlan -> vpn2
It should not be that difficult, but apparently I'm a moron, I could really use the help.
EDIT:
Finally managed to get both VPNs working on the router itself. I see TX/RX counters increase and can ping the WireGuard servers and resolve a dns query from the router. (nslookup domain remote_vpn_ip)
However now I need to route LAN/WLAN to their individual VPNs
And I tried adding tables, marking traffic, but my knowledge is just insufficient.
for IPV in 4
do
uci set network.lan.ip${IPV}table="1"
uci set network.vpn.ip${IPV}table="2"
uci -q delete network.lan_vpn${IPV%4}
uci set network.lan_vpn${IPV%4}="rule${IPV%4}"
uci set network.lan_vpn${IPV%4}.in="lan"
uci set network.lan_vpn${IPV%4}.lookup="2"
uci set network.lan_vpn${IPV%4}.priority="30000"
done
uci commit network
service network restart
Result:
Not working, external ip address over lan is the same as wan
That is a purposeful setting, I only want lan to route to vpn, not wlan. Otherwise it will just add a default route similar to : ip route add default dev vpn and route everything over vpn.
config rule
# for ip source:
option src '192.168.30.0/24'
# destination e.g. from all to dest
option dest '25.52.71.40/32'
# for interface
option in 'lan'
# for proto
option ipproto 'icmp`
option lookup '2'
The problem with using netifd for PBR like you are doing is that local routes are not copied so you only have a default gateway for your LAN but can not connect to your other local networks.
Maybe that is not a problem but if it is you need to copy local routes from main table to table 2.
But if you have already table 2 for the VPN then doing this makes not much sense to me:
You end up with a table 1 with only a local route for the LAN, I can imagine you want that route in table 2 so using this could make sense:
uci set network.lan.ip4table="2"
then you have your local route in table 2 together with the default route.
But it looks like you are overcomplicating things or you want a fine grained PBR for which using the PBR app:
https://openwrt.org/docs/guide-user/network/routing/pbr_app
It also has a LuCi app to configure: https://docs.openwrt.melmac.net/pbr/
is more suited
netifd is a powerful tool but it has its limitations