[GH-ISSUE #4992] [Bug]: The node becomes unreachable after enabling port hopping in Hy2. Please fix this as soon as possible. #3510

Closed
opened 2026-10-31 20:32:56 +07:00 by bsakaguchi · 2 comments
Owner

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:32:56 +07:00
Author
Owner

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

<!-- gh-comment-id:4636835941 --> @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.
Author
Owner

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

<!-- gh-comment-id:4636872630 --> @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.
Sign in to join this conversation.
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
MHSanaei/3x-ui#3510
No description provided.