1

I have a server exposed to the internet and a personal computer in a private network.

I have an application (Project Zomboid dedicated server) that communicates through UDP ports 16261 and 8766.

I want to be able to listen to those ports in my server and forward the traffic to my personal computer.

My personal computer has Windows 10 and the VPS has Amazon Linux 2

In a TCP escenario I can achieve that executing the following command in my personal computer:

For this example, the server public IP is 123.45.67.89

ssh user@123.45.67.89 -R 0.0.0.0:16261:127.0.0.1:16261 -R 0.0.0.0:8766:127.0.0.1:8766

My question is, how can I achieve the same behavior for UDP protocol?

Clamari
  • 121
  • 7
  • UDP cannot act as a tunnel by itself, because it is a connectionless protocol. Solutions for tunneling UDP traffic involve using a connection-oriented protocol like TCP to create the tunnel. Here is some info on using an ssh TCP tunnel to carry UDP traffic: https://superuser.com/questions/53103/udp-traffic-through-ssh-tunnel – Frank Thomas Aug 19 '22 at 18:43
  • @FrankThomas nothing stops UDP being tunneled over UDP – user253751 Aug 19 '22 at 19:20
  • I should clarify, you cannot use UDP for **Reverse** tunneling by itself. Generally the point of the reverse tunnel is to allow bidirectional messaging through DNAT, without port forwarding, which does require connection-state. – Frank Thomas Aug 19 '22 at 19:46
  • There is a dedicated technic for that, called "UDP hole punching" – Dmitry Mar 17 '23 at 08:09

2 Answers2

2

The following free and open-source project might solve your problem.

reverse-tunnel rtun is described as:

Reverse tunnel TCP and UDP

rtun is a tool for exposing TCP and UDP ports to the Internet via a public gateway server. You can expose ssh and mosh server on a machine behind firewall and NAT.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • I'm trying this solution and it looks like it works but still something is missing because I am not able to connect to the game server. When I run rtun.exe in my computer, I get logs like this: `Tunneling remote connection from 123.45.67.89:1340 to 127.0.0.1:16261` but for an unknown reason to me, seems like my app is not receiving this data. I must clarify taht I am able to connect to the server through my localhost, but not through the public IP of my VPS – Clamari Aug 20 '22 at 21:38
  • I tried to add the port 25565/tcp to the configuration to try out my minecraft server and it works perfect. – Clamari Aug 21 '22 at 00:04
0

The UDP reverse tunnel by the author of TorChat does the job.

It simply does the following using UDP hole punching technique:

[Private] <--UDP-- [NAT] <--UDP-- [Public]

You can achieve the same result with port forwarding at NAT level and UDP packets forwarding at the Public Server, though.

In my case I have no access to NAT layer, so this tool came handy to receive an UDP traffic from Gstreamer.

Dmitry
  • 111
  • 3