wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
6.95k stars 1.15k forks source link

Reverse tunnel #320

Open ghazel opened 4 years ago

ghazel commented 4 years ago

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).

wangyu- commented 4 years ago

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)

ghazel commented 4 years ago

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)

wangyu- commented 4 years ago

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

ghazel commented 4 years ago

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.

steom commented 4 years ago

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

wangyu- commented 4 years ago

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.

steom commented 4 years ago

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

a0s commented 4 months ago

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..