0

I have a virtual server instance on a cloud with Ubuntu 18.04 running on it which has public ip 123.456.789.100 (dummy ip here). I installed OpenVPN server which has added private ip of virtual server instance as 177.23.232.1 (dummy ip here). I connected my local machine to vpn and got ipv4 address 177.23.232.3 (dummy ip here). I am able to ping server to my local machine as they are in the same vpn and I am able to ping server on 177.23.232.1

I have hosted XAMPP server on local machine(windows) and I want if a client goes to 123.456.789.100 then it should internally route the traffic to my local machine as its active and i am able to ping.

I tried the following port forwarding but it didnt work.

iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 177.23.232.3:8080

iptables -t nat -A POSTROUTING -j MASQUERADE

Image of the insfra is below: https://i.stack.imgur.com/6bLr1.png

What should I do to achieve the above scenario?

1 Answers1

0

Run the shell script written by Nullivex

How can I port forward with iptables?

It works fine. This will forward the incoming internet traffic to local machine in the VPN.