prof7bit / udp-reverse-tunnel

Create an UDP-over-UDP reverse tunnel to make a VPN server behind (CG-)NAT accessible from the outside
30 stars 13 forks source link

Reconnects and breaks UDP flow #2

Closed DmitryMyadzelets closed 1 year ago

DmitryMyadzelets commented 1 year ago

I have two machines (A and B) behind NATs and one public server (S). A and B had constant bidirectional UDP flow (RTP audio) using port forwarding. Now without port forwarding they exchange UDP flow with help of udp-reverse-tunnel as follows:

A --> 5001:S --> 5001:B
A:5002 <-- S:5002 <-- A

OS on the machines:

A: Linux 5.10.103-v7+ armv7l
B: Linux 4.4.202-1237-rockchip-ayufan-gfd4492386213 aarch64
S: Linux 5.10.0-20-amd64 x86_64

The UDP flow from machine A to B works perfectly with no interruptions. The flow from machine B to A interrupts after one-two seconds and may recover after tens of seconds.

The ssh connections are stable. Seems the problem occurs only with UDP tunnel. Changing ports doesn't help.

The logs for the non stable UDP tunnel:

$ udp-tunnel -o 111.111.111.111:5002 -s 127.0.0.1:5002
<6>UDP tunnel inside agent v1.2
<6>building tunnels to outside agent at 111.111.111.111, port 5002
<6>forwarding incomimg UDP to 127.0.0.1, port 5002
<6>creating initial outgoing tunnel
$ udp-tunnel -l 5002
<6>UDP tunnel outside agent v1.2
<6>listening on port 5002
<6>new incoming reverse tunnel from: 222.222.222.222:27110
<6>Total: 1, active: 0, spare: 1
<6>new incoming reverse tunnel from: 222.222.222.222:29156
<6>Total: 2, active: 0, spare: 2
<6>removing connection
<6>Total: 1, active: 0, spare: 1
<6>new incoming reverse tunnel from: 222.222.222.222:11751
<6>Total: 2, active: 0, spare: 2
<6>removing connection
<6>Total: 1, active: 0, spare: 1
DmitryMyadzelets commented 1 year ago

I've managed to fix the problem by decreasing the keepalive interval down to to 10 seconds:

client: $ udp-tunnel -o 111.111.111.111:5002 -s 127.0.0.1:5002 -t 10
server: $ udp-tunnel -l 5002 -t 10

Still have no idea why the problem occurs.

freecode505 commented 3 weeks ago

Hello, how should it work?

Server:

./udp-tunnel -l 9092

customer

/udp-tunnel -o 51.79.84.21:9092 -s 127.0.0.1:445 -t 10

127.0.0.1:445

Is the listener for my ovpn server in UDP? true but I can't make a connection on this port

@DmitryMyadzelets

how do you connect to a vpn