I have running OpenVPN on my VPS which have static ip address. OpenVPN works as expected but I am not able to forward ports to OpenVPN client. I have tried few iptables rules but no luck. These are the iptables rules which I used, what can be the problem?

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 9292 -j DNAT --to-destination

iptables -t filter -A INPUT -p tcp -d --dport 9292 -j ACCEPT

iptables -A FORWARD -i eth0 -p tcp --dport 9292 -d -j ACCEPT is OpenVPN client ip and eth0 is VPS external - internet facing ip. I am behind NAT in VPS, my internal ip address is, am I suppose to forward ports to internal ip address from external ip address in VPS first?

  • Did you enable forwarding in the kernel? sysctl net.ipv4.ip_forward=1 – wurtel Jan 21 at 13:40
  • @wurtel yes I have. – Samet Jan 21 at 13:43
  • Are the iptables rules being hit? I.e. does iptables -vn -L ... show that packets are matching those rules? It might be that the client is not routing the return traffic via the openvpn link but instead routing it directly to the source IP. In that case you may need SNAT on the POSTROUTING. – wurtel Jan 21 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.