udp2raw icon indicating copy to clipboard operation
udp2raw copied to clipboard

Reverse tunnel

Open ghazel opened this issue 5 years ago • 8 comments

How can udp2raw be configured to run a reverse tunnel? For example, when the client can accept inbound TCP connections, but the server cannot.

The example shows how to forward UDP packets sent to client port 3333 over tcp port 4096 tunnel to server port 7777:

# Run at server side:
./udp2raw_amd64 -s -l0.0.0.0:4096 -r 127.0.0.1:7777    -k "passwd" --raw-mode faketcp -a

# Run at client side
./udp2raw_amd64 -c -l0.0.0.0:3333  -r44.55.66.77:4096  -k "passwd" --raw-mode faketcp -a

However, I would like the server to initiate the connection. Simply reversing the commands fails, since the server-side UDP port is already listening (so I get a bind error).

ghazel avatar May 30 '20 02:05 ghazel

udp2raw itself doesn't implement the function of reverse tunnel, but you can use udp2raw together with a vpn or a tunnel which supports reverse tunnel.

For example, with udp2raw + openvpn, once the vpn connection is established, upper-level connection can be establish in any direction.

(openvpn maybe too heavy weight for your purpose, I am just using it as an example here. you can replace openvpn with anything that supports reverse tunnel)

wangyu- avatar Jun 05 '20 12:06 wangyu-

Since just the client can accept inbound TCP connections, the only way to establish a vpn connection would be to set up a reverse tunnel. (Establishing a reverse connection over the vpn would therefore be too late)

ghazel avatar Jun 05 '20 19:06 ghazel

the only way to establish a vpn connection would be to set up a reverse tunnel

no, you just run udp2raw server+vpn server on your client, and udp2raw client+vpn client on your server. Once vpn connection is established, upper level connection can be established in any direction

wangyu- avatar Jun 06 '20 06:06 wangyu-

When trying to run udp2raw client on my server, I get [FATAL]socket bind error, since the UDP port my VPN is listening on is already open.

ghazel avatar Jun 06 '20 08:06 ghazel

reverse tunnel is a most required feature for a cutting edge application, please consider to implement in the next version.

steom avatar Jun 23 '20 20:06 steom

reverse tunnel is a most required feature for a cutting edge application, please consider to implement in the next version.

I have already explained how to do reverse tunnel.

wangyu- avatar Jun 23 '20 21:06 wangyu-

Yes but with other programs. That's not the point.

steom avatar Jun 23 '20 21:06 steom

Hey! 1st of all, thanks for this nice software!! I have the same question. I need to initiate udp2raw-connection from udp2raw-server-side (i have my server behind NAT and gray ip). What i want to do is expose port from inside NAT area to internet. For now i am using ssh port porwarding to external VPC server, but sometimes its unstable and says "port already used". Looks like udp2raw would help here..

a0s avatar Feb 01 '24 11:02 a0s