I want to install it manually. I've tried to add the route in a few different ways, but I've failed to achieve the desired effect.
I've tried things like:
config route
option interface 'lan2'
option target '192.168.50.1' # wireguard local interface IP
option netmask '255.255.255.0'
option gateway 'XXX' IP from wireguard remote server
but this failed.
Would you be able to point me to the right direction?
Create a routing table with default route via the VPN:
Luci: Interfaces > VPN interface > Advanced setting: Override IPv4 interface and Add custom table 100
You will now have arouting table 100 with default via the VPN
Create a rule to let the interface/ipaddresses use table 100, below some examples:
Luci: Routing > IPv4 Rules:
No, rules determine which route to use, they don't route directly. Routes are in tables. Adding table 100 (the number isn't particularly important) allows you to have a different default route that you can use a rule to send traffic through.
When I add the ipv4 table 100 with option ip4table '100', it creates the following additional rules:
$ip rule
0: from all lookup local 10000: from 192.168.50.1 lookup 100 20000: from all to 192.168.50.1 lookup 100
32766: from all lookup main
32767: from all lookup default 91538: from all iif lo lookup 100
The 2 first rules seem great, exactly what I need.
However the last rule seem quite wrong. I do not want all loopback to go to the vpn.
I'm pretty sure this rule is never actually applied, but why would it even be added?
Also, the table 100 is like this:
ip route show table 100
192.168.50.1 dev wg0 scope link
I was expected to contain a default value, that directs all unspecified IPs to wg0.
As it is now, I am not sure that, say, 192.168.50.2 will be redirected to the wg0 vpn interface?
The lo stands for loopback, a virtual network interface for local usage, it is there for completeness, but you will likely not use it anyway.
Please leave "Route allowed IPs" and "Use default gateway" enabled the "Override IPv4 routing table" will already take care of disabling default routing in the main routing table.
Restart the network service: service network restart and there should be a default gateway in table 100.
Do not forget the rule to assign a client on your network to use table 100 e.g.: