Forwarding port from VPS to local with OpenVPN
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
linux openvpn port-forwarding vps
New contributor
add a comment |
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
linux openvpn port-forwarding vps
New contributor
add a comment |
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
linux openvpn port-forwarding vps
New contributor
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
linux openvpn port-forwarding vps
linux openvpn port-forwarding vps
New contributor
New contributor
New contributor
asked 4 mins ago
ZeusZeus
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Zeus is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495613%2fforwarding-port-from-vps-to-local-with-openvpn%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Zeus is a new contributor. Be nice, and check out our Code of Conduct.
Zeus is a new contributor. Be nice, and check out our Code of Conduct.
Zeus is a new contributor. Be nice, and check out our Code of Conduct.
Zeus is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495613%2fforwarding-port-from-vps-to-local-with-openvpn%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown