My situation is as follows:

I have currently trying to have a program between two Hosts send UDP packets over a SSH Tunnel. There is also a host intermediate between the two hosts. Note Server01 separates two subnets

Subnet: //// 10.11.X.X ///////// 192.168.X.X
Host: Client <------> Server01 <-----> Server02

enter image description here

I have successfully established a SSH connection and have used RSA key's so passwords are not needed.

I than followed this tutorial:

SSH Port Forwarding for UDP

In summary it tells me to use socat to configure a TCP-UDP relay on server01 by typing in:

server01$ socat tcp4-listen:8000,reuseaddr,fork udp:server02:53

and a UDP-TCP relay on the client using socat also:

client$ socat -T15 udp4-recvfrom:53000,reuseaddr,fork tcp:localhost:8000

Now comes the problem. When I attempt to have my program create a socket on the localhost UDP Port 53000 and send data,

channel 2: open failed: connect failed: Connection refused
channel 2: open failed: connect failed: Connection refused
channel 2: open failed: connect failed: Connection refused

I believe my program is fine because when I put server02 on the same subnet as client my programs will exchange UDP packets perfectly.

Is there a setting I need to enable for my program to access the UDP port 53000 Socket? Or is it just impossible to create a socket on the UDP port because socat using it? I've been stuck on this for a while... Any help would be great.

Thanks in advance.

2 Answers 2


I realized the program needed to be run as sudo so it could access the port... Hopefully this helps someone in the future.

EDITED: The c program I have needs sudo permission to connect a socket to the UDP PORT 53000 and to send packets through that port.

  • You shouldn't need root privileges (i.e. sudo) to open listening ports numbered above 1024.
    – roaima
    Oct 27, 2015 at 22:06
  • @roaima I didn't use sudo to open listening ports. I needed sudo to allow my program to connect a socket to the UDP Port and send packets through.
    – sphchow
    Oct 27, 2015 at 22:16

socat is here to convert TCP to UDP

but in you explanation you dont talk about ssh

you must run ssh with -L to forward client TCP 8000 to server01 tcp 8000

you must run something like ssh -L 8000:localhost:8000 server01 from your client

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.