I am new to VPN and Traffic rerouting. I already read this thread: Port forward to VPN Client? But I didn't get it working :/ That is why I am asking again.

So here is my problem: I have a server (Raspberry Pi) behind a vodafone router which does not allow direct connections from WAN to the server. Therefore I created a VPN connections between the RPi to an openSVN server. It looks like this:

-----------------------       ---------------------------------------
| Pi                  |       | openVPN Server                       |
| (VPN IP: 172.X.X.2) | <---> | (VPN IP: 127.X.X.1; WAN IP: Y.Y.Y.Y) |
-----------------------       ----------------------------------------

the VPN connection works. If I call

wget 172.X.X.2:8080

from the openVPN Server, it works and the result is the expected website.

So what I want is: If I call Y.Y.Y.Y:54321 from WAN it should be forwarded to 172.X.X.2:8080 to allow the access from outside on the RPi.

Is this possible? I already enabled port forwarding and tried to following:

# sysctl -w net.ipv4.ip_forward=1
# iptables -t nat -A PREROUTING -d Y.Y.Y.Y -p tcp --dport 8080 -j DNAT --to-dest 172.X.X.2:8080
# iptables -t nat -A POSTROUTING -d 172.X.X.2 -p tcp --dport 8080 -j SNAT --to-source 127.X.X.1

Can you please tell me where my mistake is or how it should be working? :)


You must log in to answer this question.

Browse other questions tagged .