mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6570] [Bug]: Awg outbound can't connect to the server #4402
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#4402
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 @AdLf0208 on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6570
Describe the bug
I wanted to try out awg outbound and stuck with the issue of not being able to connect to the server. On my Keenetic router and android everything works as intended. I thought that as based on awg documentation if I were to delete I1 then system would fallback to awg 1.0 or 1.5 implementation but even that didn't help. Routing itself works via xray, I can see that outbound works on my awg easy server panel but 50 percent of the time probing the http or real delay results in fail.
And right after this failed attempt:
I got suspicious since there no I2 to I5 parametrs and only I1 available in the UI. Is that an intended behaviour?
No I2 to I5 which I can specify and I assume that's why server fails to response properly
Also I don't quite understand why it's using Ipv6 if I excplicitely used Ipv4 in my configuration and even if used domain could it realize that ipv6 is unavailable and fallback to ipv4? (See the logs)
How to reproduce the problem
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.8.5
Xray-core version
25.9.9
How did you install 3x-ui?
install.sh script
Operating system
docker
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 (Sep 16, 2026):
Confirmed bug — but not the one you suspected. The missing I2–I5 fields are a real UI gap (details at the bottom), yet they are not what makes your probes fail. Your tunnel handshake is clearly working; what fails is the panel's own in-tunnel DNS, which falls back to an AAAA record on an IPv4-only tunnel and then tries to dial an address the tunnel has no route for.
Why it dialled IPv6 even though your config is IPv4-only
Your log line is emitted verbatim here:
The destination that reached that line was already an IPv6 address. It got there like this:
The HTTP / Real Delay probe uses
defaultTestURL = "https://www.google.com/generate_204"(internal/web/service/outbound/probe_http.go:63) —2001:4860::/32is Google's range, and the port in your log is443. The temp probe config is built with"domainStrategy": "AsIs"and nodnssection (probe_http.go:451), and as the code itself notes, "The test URL's hostname is resolved by xray (Go's SOCKS5 client sends the domain to the proxy), so DNS goes through the outbound too" (probe_http.go:491-492). So the domain, not an IP, arrives at the AmneziaWG egress.The egress resolves it inside your tunnel.
exchangeTunnelDNSWithFallbackdecides which record types to ask for:hasV6is used only to reorder the two queries. It never excludes AAAA. So when the A query fails, the loop asks for AAAA and happily returns an IPv6 address on a tunnel whose address list is IPv4-only.hasV6comes from the outbound's Address field (internal/amneziawgnet/client_device.go:101,108,120), not from the peer'sAllowedIPs. The form pre-fillsallowedIPs: ['0.0.0.0/0', '::/0'](frontend/src/pages/xray/outbounds/protocols/amneziawg.tsx:98), so the config looks dual-stack while the netstack is v4-only — exactly the mismatch you hit.relayTCPthen dials withtunnelNetwork(dest.Addr())(internal/amneziawgnet/portfwd.go:275-280), gets "network is unreachable", logs, and returns SOCKS failure0x01. There is no retry and no fall back to the A record.Why it looks like a clean 50/50
Two amplifiers, both citable:
tunnelDNSPacketTimeout = 1200 * time.Millisecond×tunnelDNSAttempts = 3= 3.6 s (dns.go:56-58). A cold tunnel that is still completing its WireGuard handshake can eat that whole budget, after which the AAAA branch runs against a now-warm tunnel and succeeds.tunnelDNSCacheTTL = 60 * time.Secondunder a key oftag|dnsServer|hostwith no address-family component (dns.go:72, 77-79, 116-121). So one unlucky AAAA fallback poisons every probe of that host for the next minute, which turns a rare race into long alternating runs of pass/fail.A second, independent way into the same dead end: literal IP targets skip the check entirely —
so if your main Xray routing uses
domainStrategy: IPIfNonMatch/IPOnDemand, or Xray's built-in DNS hands over an AAAA, real traffic hits the identical failure. (You may also see harmless2606:4700:…warnings from the same log line: the non-real-delay probe deliberately dials Cloudflare's IPv6 literal for egress metadata and ignores the result —probe_http.go:588-634.)What you can do today
Neither of these removes the fallback; they stop the A lookup from losing in the first place.
10.8.0.1, rather than leaving it empty (empty defaults to1.1.1.1:53,internal/amneziawgnet/dns.go:23,47-52). The field accepts a bare IP orIP:port; a hostname is rejected (internal/amneziawg/outbound.go:240-254).To confirm the diagnosis on your box, restart with
XUI_LOG_LEVEL=debugand look foramneziawgnet: resolved tag="awg" "www.google.com" -> … via tunnel(dns.go:122) right before a failure. An IPv6 on that line proves the AAAA fallback fired.The I2–I5 question — yes, that is a separate real gap
The outbound form renders only
i1:while the inbound form renders all five (
frontend/src/pages/inbounds/form/protocols/amneziawg.tsx:134-152). Everything behind the form already supports I1–I5: the Zod schema (frontend/src/schemas/protocols/outbound/amneziawg.ts:33-37), the wire adapter in both directions (frontend/src/lib/xray/outbound-form-adapter.ts:433-437and479-495), the Go settings struct (internal/amneziawg/outbound.go:58-62),InstanceFromOutbound(outbound.go:152) and the UAPI renderer (internal/amneziawgnet/client_device.go:35-39). The form's own hint reads "Must exactly match the server side parameters." (internal/web/translation/en-US.json:2150), which you cannot satisfy for a server that sets I2–I5.Workaround: Xray → Advanced →
outboundSettings, and add"i2"…"i5"to the outbound's settings object by hand. The adapter preserves them on later form edits (outbound-form-adapter.ts:479-495), so they will not be silently dropped.One correction to the assumption in your report: an obfuscation mismatch prevents the handshake outright rather than causing per-request 50/50 failures, and your peer is visibly up in awg-easy — so I1–I5 are not the cause here. (That part is protocol reasoning about amneziawg-go, not something this repository pins.) Removing
I1does exactly what you expected on the panel side: the line is simply omitted from the UAPI config when empty (client_device.go:35).I could not read the two attached screenshots. If the probe errors they show say something other than what is analysed above, please paste the exact error text and I will re-check.
Verdict: Confirmed bug
Severity: High
Confidence: High for the code path and the log line; Medium that the AAAA fallback (rather than an IPv6 literal from your main routing config) is the trigger in your specific run, since the log line prints the dial, not the address's origin.
Root cause:
exchangeTunnelDNSWithFallbackininternal/amneziawgnet/dns.go:140-161retries the other address family whenever the first query fails, gating only the order ondeviceHasV6(line 146) and never excluding AAAA on a device with no IPv6 local address.internal/amneziawgnet/netstack.go:95-97installs an IPv6 default route only when the device has an IPv6 address, so the returned AAAA is unroutable andrelayTCP(internal/amneziawgnet/egress.go:383-398) fails with "network is unreachable". The 60 s family-agnostic cache atdns.go:72,116-121then holds the bad answer. Trigger: an AmneziaWG outbound whoseaddressis IPv4-only, a dual-stack destination host, and any A-query failure inside the tunnel (a cold handshake is enough). Introduced with the feature itself ind5ab84e8feat(amneziawg): add AmneziaWG as an outbound protocol (#6320). The secondary path, an IPv6 literal from Xray, is unguarded ategress.go:361-364.Already fixed: Still present on the default branch.
git log -- internal/amneziawgnet/dns.go internal/amneziawgnet/egress.goshows onlyd5ab84e8and3f1e52f0(refactor(panel): drop two duplicated helpers); no behavioural change since.d5ab84e8is tagged v3.8.0, v3.8.5 and dev-latest.Duplicate of: None. The three AmneziaWG issues that surface on these keywords — #6302, #6303, #6310 — are a feature request, an inbound throughput report and a Clash-subscription omission, all with different root causes.
Evidence:
internal/amneziawgnet/dns.go:141-160(hasV6only reorderstypes; the loop tries both families regardless);internal/amneziawgnet/dns.go:56-58(tunnelDNSPacketTimeout = 1200 * time.Millisecond,tunnelDNSAttempts = 3→ a 3.6 s A-query budget inside atunnelResolveTimeout = 4 * time.Secondcontext);internal/amneziawgnet/dns.go:72,77-79,116-121(60 s cache, keytag|dnsServer|host, no family);internal/amneziawgnet/netstack.go:92-97(if hasV6 { AddRoute(IPv6EmptySubnet) });internal/amneziawgnet/client_device.go:101,108,120(localAddrscomes frominst.Address, not from peerAllowedIPs);internal/amneziawgnet/egress.go:395(the exact warning string) andegress.go:361-364(literal IPs bypass any family check);internal/web/service/outbound/probe_http.go:63,451,491-492(Google probe URL,domainStrategy: "AsIs", domain forwarded to the proxy). No test pins the current behaviour:deviceHasV6has exactly one caller (dns.go:142), andinternal/amneziawgnet/egress_domain_test.go:650-660covers onlydefaultDNSFor. UI gap:frontend/src/pages/xray/outbounds/protocols/amneziawg.tsx:81vsfrontend/src/pages/inbounds/form/protocols/amneziawg.tsx:134-152, with backend support atinternal/amneziawg/outbound.go:58-62,152andinternal/amneziawgnet/client_device.go:35-39.Not determined: Whether this particular run went through the AAAA fallback or through an IPv6 literal handed over by the reporter's main routing config. A single
XUI_LOG_LEVEL=debugrun showing thedns.go:122"resolved … via tunnel" line immediately before the failure settles it.Suggested fix: Gate the second-family retry in
exchangeTunnelDNSWithFallbackon the device actually having that family — skip AAAA when!deviceHasV6(addrs)and skip A when!deviceHasV4(addrs)— so an unroutable answer is never returned or cached. The literal-IP path ategress.go:361-364wants the same one-line family check so an IPv6 literal from Xray fails with a clear reason rather than a dial timeout.@MHSanaei — confirmed High-severity defect in the AmneziaWG outbound egress; root cause and suggested fix above.
This reply was generated automatically; a maintainer may follow up.
@AdLf0208 commented on GitHub (Sep 16, 2026):
yep, added I2 to I5 manually but still got issues with ipv6. It seems that since I have ipv6 on my laptop firstly it tries to probe ipv6 on domain google.com
I created a temp socks proxy which would route all trafic through awg outbound and that's the result
curl -4 -x socks5://192.168.1.152:27741 https://google.com
<HTML><HEAD> </HEAD>301 Moved
The document has moved here. </HTML>curl -6 -x socks5://192.168.1.152:27741 https://google.com
curl: (35) Recv failure: Connection reset by peer
Although I have a working ipv6 address. So is there a way to configure ipv6 subnet within the ui of 3x-ui?
And also the thing is that even if ipv6 is not properly set up on the server if shouldn't affect the connection: so the fallback mechanism should be in place so the outbound could at least connect to the server
@AdLf0208 commented on GitHub (Sep 16, 2026):
Update on the matter: I tried to manually specify the ipv6 address and found out that it never even tried to contact the server via this ipv6 address even ones (checked via tcpdump)
tcpdump -n -i any ip6 dst ... and udp port ...
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
So not even one. But ipv4 is successfully being called:
tcpdump -n -i any dst ... and udp port ...
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
13:51:45.691843 ens3 In IP ... > ...: UDP, length 531
13:51:45.691942 ens3 In IP ... > ...: UDP, length 210
@AdLf0208 commented on GitHub (Sep 16, 2026):
Okay, maybe ipv6 issue related to the fact that I didn't have like client ipv6 and only ipv4 within the tunnel itself but still every other client app connects as it should without any issues(including keenetic OS routers)
There're no other logs in debug mode, only related to ipv6 probe failure, where to dig deeper in order to debug?
@AdLf0208 commented on GitHub (Sep 16, 2026):
I changed dns from 1.1.1.1 to 8.8.8.8 in awg GUI configuration and now everything works!!! That's weird. But there's still an UI issue which needs to be fixed since it's cumbersome to type I2-I5 params via json config instead of GUI outbound interface
[GH-ISSUE #6570] [Bug]: Awg outbound can't connect to the serverto [GH-ISSUE #6570] [Bug]: Awg outbound can't connect to the server