I have an orangepi (armbian) with an Ethernet interface (eth0) where I set up an interface (wlan0) for an AccessPoint and installed a VPN client (tun0). The objective is: All traffic from the wlan0 AP is directed to the vpn (tun0) and vice versa All traffic from system processes, programs, etc. is routed by default to 192.168.1.1 ISP destination
------------------- | | 10.8.3.2/24---|tun0 wlan0 |----192.168.2.1/24 192.168.1.31/24---|eth0 | WIFI AP | | ------------------- I have activated Forwarding: net.ipv4.ip_forward=1
And added rule in iptables: iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
Result: Access through AP OK and always routed through the VPN OK
Problem: All traffic is routed through the VPN and the idea is that the traffic generated by the processes is routed through the default 192.168.1.1
If from a terminal I perform ping, traceroute, etc. it routes tun0, I understand why it assigns tun0's 10.8.3.2 as the source IP and I think this is where the problem is, if it assigned eth0's 192.168.1.31, it would route by default 192.168. 1.1 and it would be solved.
The VPN client creates the default:
0.0.0.0 10.8.3.1 128.0.0.0 UG 0 0 0 tun0 Even if I delete it, everything remains the same.
What needs to be configured so that the rest of the traffic is routed by default to 192.168.1.1 ISP destination?
Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 10.8.3.1 128.0.0.0 UG 0 0 0 tun0 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 10.8.3.0 0.0.0.0 255.255.255.0 U 0 0 0 tun0 128.0.0.0 10.8.3.1 128.0.0.0 UG 0 0 0 tun0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlan0 178.239.165.30 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0 eth0: flags=4163 <UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.31 netmask 255.255.255.0 broadcast 192.168.1.255 ether 02:81:91:07:0c:a5 txqueuelen 1000 (Ethernet) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 10.8.3.2 netmask 255.255.255.0 destination 10.8.3.2 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255 ether 00:e0:4c:81:79:8a txqueuelen 1000 (Ethernet)