I have an openWRT router with near default config and with openvpn configured.
My subnetworks are:
lan - 192.168.2.0/24 - must go throught vpn
wi-fi1 - interface name: woof 10.0.9.0/24 - must go through vpn
wi-fi2 - interface name: bold 10.0.7.0/24 - must go directly to ISP
I had a task to do split tunneling in such a way that I could choose which subnet would go directly through the ISP and which through the VPN.
But I don't just want to do it, I want to get at least a little bit of a handle on the theoretical part of what I'm doing.
1. The first thing I want to understand. Is it possible to do split tunneling without PBR and creating additional routing tables?
If yes, how? And can static routes help me with this?
What was I trying to do?
Following AI's advice, I tried to disable the creation of default routes for vpn. I unchecked the "use default gateway" option for the vpnN (tun0) interface and added the following line in the ovpn config:
pull-filter ignore "redirect-gateway"
Next, I tried to add static routes using Luci. It looked something like this:
config route
option target '0.0.0.0/1'
option gateway '10.44.44.1'
option interface 'vpnN'
option metric '0'
option table 'main'
config route
option interface 'vpnN'
option target '128.0.0.0/1'
option gateway '10.44.44.1'
option metric '0'
option table 'main'
config route
option interface 'wan'
option gateway '170.30.230.1'
option target '80.70.70.72/32'
option metric '0'
option table 'main'
config route
option target '192.168.2.0/24'
option gateway '10.44.44.1'
option interface 'vpnN'
option metric '10'
option table 'main'
config route
option target '10.0.7.0/24'
option gateway '170.30.230.1'
option interface 'wan'
option metric '0'
option table 'main'
No matter what I did, the route for the 10.0.7.0 network did not work. Devices connected to this network remained without internet.
If it is possible, I want to do split tunneling using static routes without using routing tables and PBR.
If this is not possible, then how to do it with routing tables?
And then I want to feel and understand why it is not convenient and why everyone uses PBR. I want to understand the inconveniences and limitations of the standard openwrt shell
I'm still taking my first steps in openwrt and so I want to configure things more through lucy than through cli or config files. Both options complement each other for a better visualisation, though.
If I am misrepresenting something, please correct my misconceptions. Give me fish and teach me fishing)
2. The second thing. I understand that split tunneling can be done via "WAN default" and "VPN default". I want to understand how to do it both ways and understand the differences.
My current setup without static routes (Default routes and all traffic goes through VPN.)
My routing table (automatic default routes) is:
0.0.0.0/1 via 10.44.44.1 dev tun0
default via 170.30.230.1 dev pppoe-wan
10.0.7.0/24 dev br-bold scope link src 10.0.7.1
10.0.9.0/24 dev br-woof scope link src 10.0.9.1
10.44.44.0/22 dev tun0 scope link src 10.44.44.5
80.70.70.72 via 170.30.230.1 dev pppoe-wan
128.0.0.0/1 via 10.44.44.1 dev tun0
170.30.230.1 dev pppoe-wan scope link src 10.180.150.180
192.168.2.0/24 dev br-lan scope link src 192.168.2.1
| Column 1 | Column 2 | Column 3 | Column 4 | E | F |
|---|---|---|---|---|---|
| Destination | Gateway | Genmask | Flags | Metric | Iface |
| 0.0.0.0 | 10.44.44.1 | 128.0.0.0 | UG | 0 | tun0 |
| 10.44.44.0 | 0.0.0.0 | 255.255.252.0 | U | 0 | tun0 |
| 128.0.0.0 | 10.44.44.1 | 128.0.0.0 | UG | 0 | tun0 |
| 0.0.0.0 | 170.30.230.1 | 0.0.0.0 | UG | 0 | pppoe-wan |
| 80.70.70.72 | 170.30.230.1 | 255.255.255.255 | UGH | 0 | pppoe-wan |
| 170.30.230.1 | 0.0.0.0 | 255.255.255.255 | UH | 0 | pppoe-wan |
| 10.0.7.0 | 0.0.0.0 | 255.255.255.0 | U | 0 | br-bold |
| 10.0.9.0 | 0.0.0.0 | 255.255.255.0 | U | 0 | br-woof |
| 192.168.2.0 | 0.0.0.0 | 255.255.255.0 | U | 0 | br-lan |
etc/config/network
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.2.1'
option netmask '255.255.255.0'
option ip6assign '60'
list dns '10.0.254.1'
config interface 'wan'
option device 'wan'
option proto 'pppoe'
option username 'username'
option password 'password'
option ipv6 'auto'
option peerdns '0'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
option reqaddress 'try'
option reqprefix 'auto'
option norelease '1'
option peerdns '0'
config device
option name 'wan'
config device
option name 'eth0'
config device
option name 'lan1'
config device
option name 'lan2'
config interface 'vpnN'
option proto 'none'
option device 'tun0'
config device
option type 'bridge'
option name 'br-woof'
option bridge_empty '1'
config device
option type 'bridge'
option name 'br-bold'
option bridge_empty '1'
config interface 'woof'
option proto 'static'
option device 'br-woof'
option ipaddr '10.0.9.1'
option netmask '255.255.255.0'
list dns '10.0.254.1'
config interface 'bold'
option proto 'static'
option device 'br-bold'
option ipaddr '10.0.7.1'
option netmask '255.255.255.0'
IPs changed, mac addresses removed, unnecessary removed for better perception