[Solved] Port forwarding (OpenVPN)

Hello, I can't handle it anymore... after day wasted on trying....
My setup is
VPS with Debian and OpenVPN server (eth0 - 162.212.2.5, tun0 10.8.0.1) ----> OpenWRT router which works as OpenVPN client (tun0-00 10.8.0.2) ----> my local PC (192.168.1.150)
I need somehow forward and open all route (port 8999) from VPS over OpenWRT router and then into my local pc.
I have no deeper understanding of iptables... but I have to use them... please help me because I'm starting to freaking out :smile:

Although this problem is not exactly connected to OpenWrt, you need to add a static route on VPS for 192.168.1.0/24 via 10.8.0.2 (if you haven't already)

ip route add 192.168.1.0/24 via 10.8.0.2 dev tun0

Then add a DNAT rule
iptables -t nat -A PREROUTING -p tcp -d 162.212.2.5 --dport 8999 -j DNAT --to-destination 192.168.1.150

That will work if you are not doing NAT on the vpn interface on the OpneWrt. If you are, then you don't need the static route, you do the DNAT to 10.8.0.2 and on OpenWrt another DNAT to 192.168.1.150.

1 Like

Thanks you my saviour many many thanks.
I'm doing NAT and thanks to you its all works fine
Thanks thanks thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.