mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
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#4320
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 @dexiusprime-oss on GitHub (Aug 30, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6366
Is your feature request related to a problem?
Problem
With a 3x-ui WireGuard/AmneziaWG inbound (protocol=wireguard|amneziawg):
✅ client connects; tunnel up
✅ TCP/UDP to the internet works (HTTP/HTTPS, SSH)
✅ ping (e.g. 10.8.1.1) works — answered locally by xray
❌ ping to any internet IP → 100% loss
❌ ping to another WG client in the same subnet → 100% loss
❌ traceroute outside the tunnel → all hops *
Confirmed on Debian 11, 3x-ui 3.4.0, AmneziaWG inbound (port 44219, subnet 10.8.1.0/24, server 10.8.1.1, client 10.8.1.2, mtu 1380). MTU is fine (DF probe boundary exactly 1380); DNS routing is a separate matter.
Root-cause hypothesis
The WG/AWG inbound is implemented userspace, inside xray (there is no kernel wg0 / awg0 interface on the host — the same observation as in #3821). As a result:
ICMP is stateless and there is no proxying “session” for it, and the panel does not install the L3 plumbing a real WG tunnel needs:
net.ipv4.ip_forward
iptables/nftables MASQUERADE (POSTROUTING) for the WG subnet
a kernel route for the WG subnet / AllowedIPs, and per-peer routing
TCP/UDP happen to work because xray opens an outbound socket and binds replies back to the inbound flow.
So it’s a TCP/UDP proxy masquerading as a VPN, not a true layer-3 network.
Describe the solution you'd like
Make WireGuard/AmneziaWG inbound behave as a full L3 VPN (feature):
Kernel integration (preferred): wire up the WG/AWG tunnel at the kernel level (wg-quick / wireguard-linux / AWG kernel module) when the panel creates an inbound — create the real interface, assign subnet, add peer routes from AllowedIPs/settings.clients.
L3 plumbing for the subnet:
enable ip_forward for the WG interface,
install MASQUERADE/NAT (POSTROUTING) so replies return,
allow client-to-client traffic within the WG subnet,
route ICMP (echo) to/from the internet.
Panel surface: expose the knob (e.g. “kernel mode” / “userspace mode”) and the subnet/NAT settings so it’s configurable, not hardcoded.
Verification criteria (what “works” means):
ping to internet IPs from a WG client → reply,
ping client-to-client within the subnet → reply,
ping still works,
TCP/UDP keep working,
external port only needs the single WG UDP port (no per-client NAT port).
Acceptance test (already scriptable)
From a connected WG client:
ping # must PASS
ping 1.1.1.1 # must PASS after fix (currently 100% loss)
ping # must PASS after fix (currently 100% loss)
curl -4 https://ifconfig.me # must still PASS
Environment
3x-ui: 3.4.0 (Debian 11 bullseye)
xray: latest from panel
Inbound: AmneziaWG, MTU 1380, subnet 10.8.1.0/24
Host: Debian 11, kernel supports WireGuard natively (no custom module needed)
If a fully kernel-backed tunnel is out of scope for xray, a fallback would be to add the L3 plumbing (ip_forward + NAT + subnet route) around the userspace inbound — that alone fixes ICMP transit and client-to-client.
Alternatives you've considered
No response
Concrete use case
No response
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
No response
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Aug 30, 2026):
Your observations are accurate, but the root cause you propose is not the one in the code — and the fallback you suggest (
net.ipv4.ip_forward+MASQUERADE+ a subnet route) would change nothing, because no decapsulated tunnel packet ever reaches the host kernel in the first place. Treating this as a valid feature request for ICMP transit + client-to-client, not as a bug, and explaining below exactly where it would have to land.Why ICMP does not transit
Both WireGuard-family inbounds are userspace, but in two different processes:
amneziawginbounds are terminated inside the panel process —internal/amneziawgnet/netstack.go:1, "Package amneziawgnet embeds amneziawg-go … directly in the panel process". They are deliberately excluded from the generated Xray config atinternal/web/service/xray.go:177:wireguardinbounds are handed to xray-core: peers are rewritten into xray's shape atinternal/database/model/model.go:364(case WireGuard:→WireguardClientsToPeers) and emitted atinternal/web/service/xray.go:246.In the embedded stack, ICMP is registered —
internal/amneziawgnet/netstack.go:62:That registration is why
ping 10.8.1.1answers: the userspace stack replies to an echo addressed to its own interface address. But only two transport handlers are ever attached, and neither is ICMP:internal/amneziawgnet/forwarder.go:42—gstack.SetTransportProtocolHandler(tcp.ProtocolNumber, fwd.HandlePacket)internal/amneziawgnet/udp.go:34—gstack.SetTransportProtocolHandler(udp.ProtocolNumber, func(...) bool {Everything that leaves the tunnel leaves through a loopback SOCKS5 dial into Xray:
RelayTCPissues a SOCKS5 CONNECT (internal/amneziawgnet/relay.go:67), and UDP goes over UDP ASSOCIATE (relay.go:44-45, "udp:true is required: RelayUDP depends on the inbound accepting UDP ASSOCIATE, not just CONNECT"). RFC 1928 defines CONNECT, BIND and UDP ASSOCIATE — there is no verb that can carry an ICMP echo, so ICMP has no representation on that egress path at all. Forwireguardinbounds the same shape applies one layer over: this repo's own forwarder is annotated "Adapted from xtls/xray-core'sproxy/wireguard/tun.gocreateForwarder (MIT)" (forwarder.go:22) and its UDP path likewise (udp.go:28-30), withnetstack.go:38-41noting xray-core'sproxy/wireguard/netstack.gotakes the same gVisor approach — TCP and UDP paths only. (That last part about xray-core is an inference from these comments; I did not read the xray-core source here.)Why ip_forward + MASQUERADE cannot fix it
There is no kernel interface for those rules to act on. The repo states this directly —
internal/amneziawgnet/portfwd.go:5-8:A
10.8.1.xpacket exists only as bytes inside a gVisorstack.Stackin the panel's address space. It never enters the host's IP stack, so it never traversesFORWARD, never hitsPOSTROUTING, andnet.ipv4.ip_forwardnever applies. That is also why per-client port forwarding had to be reimplemented as real Go listeners instead of DNAT rules.Client-to-client is a separate, non-ICMP problem too
ping 10.8.1.3failing is not really an ICMP issue. The TCP forwarder relays every destination into Xray's SOCKS5 inbound, tunnel-internal addresses included (internal/amneziawgnet/manager.go:177-198), and Xray cannot reach them —portfwd.go:12-16:So TCP between two peers on the same inbound does not work either, for the same reason. Worth noting because this half needs no kernel work at all — it is a short-circuit inside the stack before the relay — and is much smaller than the ICMP half.
On "kernel mode" as a panel option
That path existed in this fork and was deliberately removed —
internal/amneziawg/instance.go:4-10:Reintroducing it as a toggle means reintroducing DKMS builds, Secure Boot signing and container-vs-bare-metal divergence, and it would bypass the SOCKS5 relay that currently supplies per-client stats, quota and routing (
relay.go:1-6). That is a maintainer-level architectural call, not a small addition — flagging the cost rather than arguing against the request.One correction on your environment
3x-ui 3.4.0 has no
amneziawgprotocol. Atv3.4.0the constants ininternal/database/model/model.goend atMTProto Protocol = "mtproto";AmneziaWG Protocol = "amneziawg"was added by commiteffcccce("feat(amneziawg): add native AmneziaWG protocol support (#6105)", 2026-08-24), whose first tag is v3.7.0. So what you tested is awireguardinbound, possibly configured from an Amnezia client app. It does not change the conclusion — both are userspace and neither transits ICMP — but if you want to re-run your acceptance script against the embedded stack described above, you need v3.7.0 or newer.Two things I could not settle here, since I cannot run the panel: whether v3.7.0's promiscuous+spoofing NIC (
netstack.go:229-232) causes gVisor to answer echo requests addressed to arbitrary destinations — if it does,ping 1.1.1.1would appear to pass while being a locally forged reply rather than real transit, which your acceptance test could not distinguish; and whether IPv6 behaves identically. Running your four-command script on v3.7.0 and reporting the raw output would settle both.Related: #3821 (the original report, closed as a question) and #6350, which answered the kernel-vs-userspace question for 3.7.0. Neither shares a defect with this, so this stays open on its own. No documentation page currently states the ICMP limitation —
grep -rn -i icmp docs/content/docs/en/matches onlyconfig/transports.mdx:128(thexicmpUDP mask, unrelated) — so documenting it is arguably the smallest useful step here.Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.