I have two working interfaces on my ubuntu machine
:
tun0
- OpenVPN server with the internal address of: 10.8.0.0/24
wg0
- WireGuard peer interface with the internal address of: 10.7.0.0/24 which is connected to an external WireGuard server with a successful handshake.
And I'm trying to tunnel all the requests for tun0
through wg0
. So when I connect to the OpenVPN tunnel, it would be as if I'm connected to the WireGuard server.
And this is how my iptables
backup looks like before making any changes:
*filter
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 10.8.0.0/24 -j ACCEPT
COMMIT
*nat
-A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source MACHINE_IP_ADDRESS
COMMIT
So by looking at this I figured if I replaced the MACHINE_IP_ADDRESS
with the internal IP of WireGuard connection it might work:
-A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source 10.7.0.0
Which did not work. I also tried:
-A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -o wg0
And in both cases, the OpenVPN connection was established but fully timed out.
Is there a way I can achieve this without too much configuration?