Jump to content
TorGuard
  • 0
poly_boi

Port Forwarding in Ubuntu 16.04

Rate this question

Question

poly_boi

I'm trying to forward ports in Ubuntu 16.04. I was trying to edit the .ovpn file I used to import the settings to include something like this...

iptables -I FORWARD -i tun0 -p udp -d 10.35.0.30 --dport 51413 -j ACCEPT
iptables -I FORWARD -i tun0 -p tcp -d 10.35.0.30 --dport 51413 -j ACCEPT
iptables -t nat -I PREROUTING -i tun0 -p tcp --dport 51413 -j DNAT --to-destination 10.35.0.30
iptables -t nat -I PREROUTING -i tun0 -p udp --dport 51413 -j DNAT --to-destination 10.35.0.30

Am I on the right track? Are there other commands I need to add?

I was thinking that maybe I need to somehow use a command that forwards packets from enp3s0 to tun0? Is that how it works? I connect to the internet through enp3s0=>tun0=>VPN Server=>Internet? I'm really out of my depth here and I just don't have the time to research all of it. I have already been trying for 4 hours. Any help would be appreciated.

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
Support
3 hours ago, poly_boi said:

I'm trying to forward ports in Ubuntu 16.04. I was trying to edit the .ovpn file I used to import the settings to include something like this...

iptables -I FORWARD -i tun0 -p udp -d 10.35.0.30 --dport 51413 -j ACCEPT
iptables -I FORWARD -i tun0 -p tcp -d 10.35.0.30 --dport 51413 -j ACCEPT
iptables -t nat -I PREROUTING -i tun0 -p tcp --dport 51413 -j DNAT --to-destination 10.35.0.30
iptables -t nat -I PREROUTING -i tun0 -p udp --dport 51413 -j DNAT --to-destination 10.35.0.30

Am I on the right track? Are there other commands I need to add?

I was thinking that maybe I need to somehow use a command that forwards packets from enp3s0 to tun0? Is that how it works? I connect to the internet through enp3s0=>tun0=>VPN Server=>Internet? I'm really out of my depth here and I just don't have the time to research all of it. I have already been trying for 4 hours. Any help would be appreciated.

 

Hello Poly

Those rules are for if you are connecting to OpenVPN directly on a router - you do not need to use any firewall rules other than to allow incoming/outgoing on the ports you want to open  and connect via the correct IP/cipher/protocol - do you have a dedicated IP? Please make the request here from within your account area dashboard  >> Management Actions >> Request Port Forward

Before making the request you would normally connect to the location you want and then visit iplocation.net and enter this IP that it shows you, we would suggest doing some speed tests and finding the right server for you first.

Regards

Share this post


Link to post
Share on other sites
  • 0
poly_boi

Thanks for your help. I only just realised you had replied so sorry for the late response. What do you mean by connect via correct IP/cipher/protocol? What do you mean by dedicated IP? I have already requested the ports to be forwarded in the dashboard through the server that I generally use. At the moment I have all the ports open in the firewall that I need open and I have requested the ports to be forwarded in the dashboard but I still can't get them to work.

Share this post


Link to post
Share on other sites
  • 0
Support
On 31/03/2018 at 9:10 PM, poly_boi said:

Thanks for your help. I only just realised you had replied so sorry for the late response. What do you mean by connect via correct IP/cipher/protocol? What do you mean by dedicated IP? I have already requested the ports to be forwarded in the dashboard through the server that I generally use. At the moment I have all the ports open in the firewall that I need open and I have requested the ports to be forwarded in the dashboard but I still can't get them to work.

 

Are you connecting directly to the IP that you used to request the port forward?

Regards

Share this post


Link to post
Share on other sites
  • 0
poly_boi

I'm trying to figure out how to do that. I tried using the ovpn generator but when I connect it work but when I try to browse to a web page it just hangs on connecting until I get a notification saying the VPN connection failed.

Share this post


Link to post
Share on other sites
  • 0
poly_boi

I have tried only with TCP but using SHA 1 and SHA 256 as well as with AES-128-CBC and BF-CBC and they have the same result. Would using UDP be better?

Share this post


Link to post
Share on other sites
  • 0
Support

Can you PM me your username?

Regards

Share this post


Link to post
Share on other sites
  • 0
193964_1511348161

the iptables rules dont go in the ovpn file if im not mistaken. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×