I've recently bought some cheap vps, and would like to open some ports, i already done that on server with ufw. btw I'm connecting to a VPN that allows me to forward ports to my local machine via OpenVPN since my local provder is blocking ports.

OpenVPN works fine on my pc all connected and working but it shows me only TCP ports are open,all UDP ports closed when i connected on VPN, but when i check on some webiste port checker and paste ip of server it tells its open..

i guess it has somehing with iptables or something like that..? Could anyone help me? THANKS

EDIT.I made this work by doing this command:

iptables -t nat -A PREROUTING -d SERVERIP -p UDP --dport 1234-j DNAT --to-dest

iptables -t filter -A INPUT -p udp -d --dport 3480 -j ACCEPT

and is ip of OPENVPN

  • 1
    Sorry, this is a bit confused, how did you check that UDP port is closed (this is technically not possible like you can do with TCP port with telnet by example). In fact, what do you want to open? – ob2 Apr 3 at 21:58
  • First of all thanks for answering. i want to host games in ps4 so my plan was to order server setup vpn and have open ports simple as that.. but when i setup everything i saw on ps4 that nat is still not open.. Then i check on my pc with this tool and saw this: TCP: img.techpowerup.org/190403/capture094-20190404.jpg and UDP: img.techpowerup.org/190403/capture095-20190404.jpg – Licika Apr 3 at 22:04

If I understood what you are trying to achieve, you are try to do NAT from a VPS and forward TCP and UDP port to a local network reachable through a VPN tunnel (OpenVPN). This is probably not working due a routeback issue, your local network is probably configured to reach internet without using OpenVPN connection, so traffic coming from your NAT will not answering to your VPS.

What you can try is proxying your traffic over a service (like nginx). Here an example.

Install Nginx (on your VPS):

apt install nginx

Create a new folder dedicated for your port rules

mkdir /etc/nginx/ports/

Add the following lines to the end of the file /etc/nginx/nginx.conf

stream {
  include /etc/nginx/ports/*;

Finally create any file you want with your rules, into this new folder. Here an example of tcp and udp redirect.

server {
  listen 1234;
  proxy_pass <computer-ip>:1234;

server {
  listen 1234 udp;
  proxy_pass <computer-ip>:1234;

Of course, port 1234 must be opened in your ufw as your mentioned.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.