0

My ISP has me double-NAT'ed me so I can't open any ports. I want to forward all connections via port 9292 through VPS's IP to OpenVPN so I can listen port 9292 from my local network when I connected to VPN.

I have installed OpenVPN to my Google Cloud VPS and added iptable rules as following but still I can't listen port 9292 with VPN. I also allowed connections for port 9292 from Google Cloud's firewall. Am I doing something wrong here?

-A INPUT -i tun0 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 443 -j ACCEPT
-A INPUT -d 10.8.0.2/32 -p tcp -m tcp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.2/32 -p udp -m udp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.3/32 -p tcp -m tcp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.3/32 -p udp -m udp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.4/32 -p tcp -m tcp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.4/32 -p udp -m udp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.5/32 -p tcp -m tcp --dport 9292 -j ACCEPT
-A INPUT -d 10.8.0.5/32 -p udp -m udp --dport 9292 -j ACCEPT
-A FORWARD -i eth0 -o tun0 -j ACCEPT
-A FORWARD -i tun0 -o eth0 -j ACCEPT
-A FORWARD -d 10.8.0.2/32 -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.2/32 -i 35.204.7.151 -p udp -m udp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.3/32 -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.3/32 -i 35.204.7.151 -p udp -m udp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.4/32 -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.4/32 -i 35.204.7.151 -p udp -m udp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.5/32 -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j ACCEPT
-A FORWARD -d 10.8.0.5/32 -i 35.204.7.151 -p udp -m udp --dport 9292 -j ACCEPT
COMMIT
# Completed on Sun Jan 20 15:50:20 2019
# Generated by iptables-save v1.6.0 on Sun Jan 20 15:50:20 2019
*nat
:PREROUTING ACCEPT [1462:86937]
:INPUT ACCEPT [1111:57853]
:OUTPUT ACCEPT [128:8319]
:POSTROUTING ACCEPT [128:8319]
-A PREROUTING -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j DNAT --to-destination 10.8.0.2
-A PREROUTING -i 35.204.7.151 -p udp -m udp --dport 9292 -j DNAT --to-destination 10.8.0.2
-A PREROUTING -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j DNAT --to-destination 10.8.0.3
-A PREROUTING -i 35.204.7.151 -p udp -m udp --dport 9292 -j DNAT --to-destination 10.8.0.3
-A PREROUTING -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j DNAT --to-destination 10.8.0.4
-A PREROUTING -i 35.204.7.151 -p udp -m udp --dport 9292 -j DNAT --to-destination 10.8.0.4
-A PREROUTING -i 35.204.7.151 -p tcp -m tcp --dport 9292 -j DNAT --to-destination 10.8.0.5
-A PREROUTING -i 35.204.7.151 -p udp -m udp --dport 9292 -j DNAT --to-destination 10.8.0.5
-A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  • Wouldn't it be easier to create an OpenVPN tunnel out from your home double-NAT environment to your Google VPS, and then you can do whatever you want with your VPS to forward traffic inwards. – roaima Jan 20 at 16:40
  • These firewall rules... they're on your VPS? What is 10.8.0.2/32 used for? Is 35.204.7.151 your VPS public IP address, or the ISP one that your home device is double-NATted behind? It looks like you're showing us the iptables save file. Have you actually applied these rules? – roaima Jan 20 at 16:41

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.