[GH-ISSUE #196] Feature-request: udp port multiplexing #93

Open
opened 2026-10-14 04:03:31 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @RTechSn on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-go/issues/196

Hi.
Let's look at a scenario when any UDP port gets blocked for some time after sending\receiving some amount of traffic.
But each time you make a new connection to a new port, you can still send some data.

I suggest implementing a port range option for peers with de-muxing the transport connection between multiple ports.

[Interface]
ListenPort = 10000-20000
[Peer]
Endpoint = 1.2.3.4:10000-20000

Next step would be making multiple connections and stagger them in time.
For each of multiple connections peers pick a random port number from specified range. When one of the connections gets blocked, packets would seamlessly go through another one.
When a dead connection is detected, peer makes a new one on a random port from the range.

Even better, if you could specify multiple IP's if your server has them.

[Peer]
Endpoint = 1.2.3.4:10000-20000, 5.6.7.8:15000-20000
Connections = 4

I've done some tests on a vibe-coded tunnel and it works even if you manage to send only a couple of kilobytes per connection.

Originally created by @RTechSn on GitHub (Sep 16, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-go/issues/196 Hi. Let's look at a scenario when any UDP port gets blocked for some time after sending\receiving some amount of traffic. But each time you make a new connection to a new port, you can still send some data. I suggest implementing a port range option for peers with de-muxing the transport connection between multiple ports. ``` [Interface] ListenPort = 10000-20000 ``` ``` [Peer] Endpoint = 1.2.3.4:10000-20000 ``` Next step would be making multiple connections and stagger them in time. For each of multiple connections peers pick a random port number from specified range. When one of the connections gets blocked, packets would seamlessly go through another one. When a dead connection is detected, peer makes a new one on a random port from the range. Even better, if you could specify multiple IP's if your server has them. ``` [Peer] Endpoint = 1.2.3.4:10000-20000, 5.6.7.8:15000-20000 Connections = 4 ``` I've done some tests on a vibe-coded tunnel and it works even if you manage to send only a couple of kilobytes per connection.
Author
Owner

@anphsw commented on GitHub (Oct 14, 2026):

Very useful feature, it needs to implemented in user-level.

On kernel-level you can use (nftables example):
source port randomize:
type nat hook postrouting priority srcnat ->
udp dport xxxx masquerade fully-random

dst port randomize:
map nftable_testmap{ type mark:inet_service; elements = { 0: ....., 1: .... , ..... , 7: ...... }
type nat hook output priority 0 ->
udp dport xxxx dnat to : numgen random mod 8 map @nftables_testmap

<!-- gh-comment-id:6171328575 --> @anphsw commented on GitHub (Oct 14, 2026): Very useful feature, it needs to implemented in user-level. On kernel-level you can use (nftables example): source port randomize: type nat hook postrouting priority srcnat -> udp dport xxxx masquerade fully-random dst port randomize: map nftable_testmap{ type mark:inet_service; elements = { 0: ....., 1: .... , ..... , 7: ...... } type nat hook output priority 0 -> udp dport xxxx dnat to : numgen random mod 8 map @nftables_testmap
Author
Owner

@RTechSn commented on GitHub (Oct 15, 2026):

  1. On kernel-level you can use

I think port block would lead to a packet loss in this case.
AWG needs to be aware which ports are still alive, close the connection on them and open new ones.
The tunnel data should flow without interruption even if you can send just a couple of kilobytes per port.

<!-- gh-comment-id:6186879077 --> @RTechSn commented on GitHub (Oct 15, 2026): > 1. On kernel-level you can use I think port block would lead to a packet loss in this case. AWG needs to be aware which ports are still alive, close the connection on them and open new ones. The tunnel data should flow without interruption even if you can send just a couple of kilobytes per port.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-go#93
No description provided.