Trying to build a VPN gateway, struggling with routing
Posted: Thu Mar 18, 2021 9:26 pm
Good Evening,
I'm trying to build a router running Ubuntu 20.04 that will connect an ethernet network to a hosted VPN service.
My interfaces:
The only traffic that i want to use the VPN is traffic coming from the eth1 interface. I've found how to use policy routing in Ubuntu to select traffic based on source interface. Where I'm getting hung up is figuring out where to send it next. I'm using 'pull-filter ignore redirect-gateway' so prevent the VPN service from redirecting all traffic. What i think i need to do is somehow grab the IP address that was sent as the 'route-gateway' and apply that as the default gateway to the table i began with with 'ip rule add iif eth1 table vpn0'. Is there a clean way to do this? I do not believe i can trust that the gateway will stay the same on the hosted VPN side of things.
Thanks in advance,
I'm trying to build a router running Ubuntu 20.04 that will connect an ethernet network to a hosted VPN service.
My interfaces:
- eth0: Internet facing
- eth1: Internal network
- tun0: VPN connection that runs over eth0
The only traffic that i want to use the VPN is traffic coming from the eth1 interface. I've found how to use policy routing in Ubuntu to select traffic based on source interface. Where I'm getting hung up is figuring out where to send it next. I'm using 'pull-filter ignore redirect-gateway' so prevent the VPN service from redirecting all traffic. What i think i need to do is somehow grab the IP address that was sent as the 'route-gateway' and apply that as the default gateway to the table i began with with 'ip rule add iif eth1 table vpn0'. Is there a clean way to do this? I do not believe i can trust that the gateway will stay the same on the hosted VPN side of things.
Thanks in advance,