network via dhcp internet gateway 192.168.x.1 dhcp server 192.168.x.10 dhcp gateway 192.168.x.2 => this gateway has a permanent vpn tunnel via openvpn to vpn provider, so I want to route all traffic through it vpn server 192.168.x.9 => has a manual gateway set to 192.168.x.1 as otherwise clients are not able to establish vpn connections because answers are routed via VPN tunnel (192.168.x.2)
clients are establishing vpn connections (openvpn or ipsec) to vpn server. On vpn server I have iptable rules to route requests from vpn clients to internal network and internet:
-A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j MASQUERADE
Problem now is that internet traffic is routed via 192.168.x.1 as this is the default gateway for vpn server. I am not able to tell the vpn server to route everything from vpn clients via vpn gateway. I have tried several things now like changing vpn configuration to provide different gateways (not my favorite solution), putting various iptable rules (preferred solution), creating virtual interface with different gateway and route through it, but in all cases I failed.
So 2 questions:
- is it possible to set the vpn server gateway to the vpn gateway and still clients are able to establish vpn connection?
- what is the right configuration on vpn server to route everything from vpn network via vpn gateway?