OpenVPN Forward Traffic to Client

Hey everybody,

I was wondering if I could get some help with my OpenVPN server and client. I have an Ubuntu 14.04 Digital Ocean droplet that is my OpenVPN server and I have a Debian 8 vm on my server at home that is the client to that server. The VPN works great for sending traffic and searching the web. But I was wondering if I could do that in reverse. So be able to host a web server on that Debian 8 vm, and have the front end IP of that vm be the external IP of the Digital Ocean droplet. I know @wendell made a video mentioning that this is possible, and that he would go into it further, but I figured I'd ask here to see if anybody else knew. Thanks!

You must forward the traffic through the vpn to your local network. Iptables should be able to do that for you.

Tbh, never done it but it should be working.

Some resources after a quick google:


https://community.openvpn.net/openvpn/wiki/BridgingAndRouting

1 Like

You need to configure NAT on the VM to port forward to the client.

Presumably you've configured the VPS to forward traffic between the VPN network and the VPS network (so you can access the internet)? Did you do that by editing /etc/ufw/before.rules? Or did you do it with iptables? If you did it by editing the ufw files then add these lines:

make sure that at the top you have these lines (you will probably already have some of them but make sure you add the prerouting one)

*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]

bellow that you can add the port forwards, they should look something like this:

-A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination xxx.xxx.xxx.xxx

where eth0 is the interface wirth the piblic IP, -p tcp is the protocol, dport 80 is the port number and xxx.xxx.xxx.xxx is the IP you want to forward to

bellow that you should have the postrouting rules similar to this:

-A POSTROUTING -s 10.1.8.0/24 -o eth0 -j MASQUERADE

where 10.1.8.0/24 is your openvpn network and eth0 is the internet facing interface on the VPS

after this there should be the line COMMIT

make those changes and reload UFW and that should work.

1 Like

Look up this on Hak5

Link: https://www.youtube.com/watch?v=b7qr0laM8kA