0

I've setup an OpenVPN server on my Raspberry pi at home. However, I do not have a static public IP address. For that reason, I made an OpenVPN tunnel on a custom public VPS server with another OpenVPN server. At least now I can ssh on my raspberry pi anywhere even if my public IP changes (through the vpn tunnel).

I'm trying to use iptables to forward the raspberry pi OpenVPN server tcp port 1195 on that specific vpn tunnel (10.8.0.3).

sudo iptables -A FORWARD -p tcp --dport 1121 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 1121 -j DNAT --to-dest 10.8.0.3:1121
sudo iptables -t nat -A POSTROUTING -d 10.8.0.3 -j MASQUERADE

I can connect to my raspberry pi openvpn server (trough my vps on tcp port 1121) but I do not have any internet access and I don't know why. My raspberry pi receives requests and send it back to my vps (I checked with tcpdump) but my vps seems to be unable to send it back to the original client (my pc).

Do you know a better way? A hint on where to look ? How to fix the problem ?

2
  • 1
    Couldn't you use a DynamicDNS provider with an update script on the Pi to always have a resolvable, known address? Commented Aug 17, 2018 at 3:50
  • Yes, I've just checked my modem/router does support that! I'll probably use it. Thanks for the tip! Commented Aug 17, 2018 at 19:21

1 Answer 1

0

I found the solution. I forgot to setup iptables on my Raspberry PI.

sudo iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o eth0 -j SNAT --to-source 192.168.1.14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .