Forward VPN traffic to another server
First you need to establish a VPN link between server A and B, let's say server B will get 10.10.0.1
as address, server A 10.10.0.2
and the virtual interface on server A will be called tun1
. You can use whichever technology you fill more comfortable.
Then, as remarked by davidgo, you need to use policy based routing on server A. In order to do so:
-
Add a new routing table to the file
/etc/iproute2/rt_tables
:200 vpn
-
Add a selection rule to use the routing table
vpn
for all traffic coming from the private network:ip rule add from 10.0.0.0/8 table vpn
-
Fill the routing table
ip route add 10.8.0.0/16 dev tun0 src 10.8.0.1 table vpn ip route add 10.9.0.0/16 dev wg0 src 10.9.0.1 table vpn ip route add 10.10.0.0/16 dev tun1 src 10.10.0.2 table vpn ip route add default via 10.10.0.1 dev tun1 table vpn