mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4992] [Bug]: The node becomes unreachable after enabling port hopping in Hy2. Please fix this as soon as possible. #3510
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3510
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lxhifu on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4992
Describe the bug
The node becomes unreachable after enabling port hopping in Hy2. Please fix this as soon as possible.
How to reproduce the problem
Set up a new Hysteria2 node with port hopping enabled.
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
v3.2.8
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Debian12
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 6, 2026):
This is a duplicate of #4974, which reports the same symptom from the same environment. Closing to consolidate the discussion there.
To summarise what the investigation in #4974 found, and add one correction to that earlier analysis:
How server-side port hopping actually works in Xray-core
Xray-core's Hysteria2 server only binds to a single UDP port (the one configured in the inbound). Looking at the upstream source, the server Listen function calls internet.ListenSystemPacket with a single Port — one socket, one port, no range. Port hopping is a client-side feature: the client randomly picks a port from the configured range and connects there.
For the server to accept those connections, you need OS-level DNAT rules that redirect every port in the hop range to the single listening port.
Required server-side setup
Replace 20000:50000 with your hop port range and 443 with the actual inbound port:
IPv4:
iptables -t nat -A PREROUTING -p udp --dport 20000:50000 -j REDIRECT --to-port 443
IPv6:
ip6tables -t nat -A PREROUTING -p udp --dport 20000:50000 -j REDIRECT --to-port 443
Make rules survive reboots on Debian:
apt-get install -y iptables-persistent
netfilter-persistent save
3x-ui does not create these rules automatically. Without them, clients that land on a hop port find no listener and the connection fails.
Why it may have worked before the upgrade
update.sh does not reset iptables. If you previously had DNAT rules in place and they were lost (e.g. reboot without persistence, VPS re-image, or iptables flush) that would explain the failure independently of any 3x-ui version change.
Please check #4974 for the full investigation. If you have additional details — especially the output of 'iptables -t nat -L -n -v' and Xray logs from a failing connection attempt — please add them as a comment on that issue.
@lxhifu commented on GitHub (Jun 6, 2026):
Port hopping only works if I manually apply the NAT routing rule via SSH:
iptables -t nat -A PREROUTING -p udp --dport 20000:50000 -j REDIRECT --to-port 443
It's not viable to manually run this command every time the node restarts or updates. This is definitely a bug where the panel fails to auto-configure the iptables rules.