[GH-ISSUE #6328] [Bug]: AmneziaWG together with WireGuard for the same client invokes WG doesn't work #4298

Closed
opened 2026-10-31 20:38:39 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @Erapchu on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6328

Describe the bug

I'm expecting WG and AWG can work together for the same client

How to reproduce the problem

Create inbound AWG
Create inbound WG
Setup client to use WG
Save
Try use WG -- that works
Setup client to use AWG
Save
Try use WG -- it doesn't work anymore. Also I can't find some WG options in client's popup.

Expected behavior

WG works together with AWG

Actual behavior

WG doesn't work when AWG configured. AWG works as expected.

Relevant logs


Screenshots

Only AWG configured:
Image

AWG + WG:

Image

Only WG:

Image

3x-ui version

3.7.0

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04.4

Which parts of the panel are affected?

Other

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No response

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 @Erapchu on GitHub (Aug 25, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6328 ### Describe the bug I'm expecting WG and AWG can work together for the same client ### How to reproduce the problem Create inbound AWG Create inbound WG Setup client to use WG Save Try use WG -- that works Setup client to use AWG Save Try use WG -- it doesn't work anymore. Also I can't find some WG options in client's popup. ### Expected behavior WG works together with AWG ### Actual behavior WG doesn't work when AWG configured. AWG works as expected. ### Relevant logs ```shell ``` ### Screenshots Only AWG configured: <img width="863" height="1134" alt="Image" src="https://github.com/user-attachments/assets/71fe7576-4530-41b9-941e-63f57f731be9" /> AWG + WG: <img width="874" height="1151" alt="Image" src="https://github.com/user-attachments/assets/5752ca69-162d-41a7-a2e7-d3f4ab0af0f6" /> Only WG: <img width="875" height="1144" alt="Image" src="https://github.com/user-attachments/assets/fccba023-44dd-4689-9a31-e7c5940e813f" /> ### 3x-ui version 3.7.0 ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04.4 ### Which parts of the panel are affected? Other ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? _No response_ ### 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:38:39 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2026):

Confirmed bug, and it is not a conflict between the two protocols on the wire: your client identity has one WireGuard address column in the database, attaching it to the AmneziaWG inbound overwrites it, and the panel then rebuilds the WireGuard inbound's peer list from that overwritten value.

What actually happens

1. The panel deliberately gives the identity a different address on each tunnel inbound. WireGuard's default subnet is 10.0.0.0/24 (internal/web/service/client_wireguard.go:15, const defaultWireguardBase = "10.0.0.0/24") and AmneziaWG's is 10.8.1.0/24 (frontend/src/schemas/protocols/inbound/amneziawg.ts:54, subnetIp: z.string().default('10.8.1.0')). So when you attach an identity that already holds a WireGuard address to an AmneziaWG inbound, the inherited address is cleared and a fresh in-subnet one is allocated:

// internal/web/service/client_crud.go:839
		if !addressesFitAmneziaWGInbound(copyClient.AllowedIPs, inbound) {
			copyClient.AllowedIPs = nil
		}

2. Persisting that new AmneziaWG peer writes its address into the shared client row. model.ClientRecord has exactly one column for it — internal/database/model/model.go:928:

	AllowedIPs      string `json:"allowedIPs" gorm:"column:wg_allowed_ips"`

and every per-inbound persist funnels through the same merge (internal/web/service/client_link.go:51):

	if incoming.AllowedIPs != "" {
		row.AllowedIPs = incoming.AllowedIPs
	}

After the AmneziaWG save, clients.wg_allowed_ips for your email is the AmneziaWG address (e.g. 10.8.1.2/32).

3. The WireGuard inbound's peers[] is regenerated from that shared row, not from the WireGuard inbound's own settings JSON — internal/web/service/xray.go:183 and :246:

		dbClients, listErr := s.inboundService.clientService.ListForInbound(nil, inbound.Id)
...
			case model.WireGuard:
				wgPeers = append(wgPeers, model.WireguardPeerFromClient(c))

ListForInbound selects clients.* (internal/web/service/client_link.go:307-312), ClientRecord.ToClient maps that single column straight into the peer (internal/database/model/model.go:1200, AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs)), and WireguardPeerFromClient emits it verbatim (internal/database/model/model.go:438-439, peer["allowedIPs"] = c.AllowedIPs).

Net effect: the WireGuard inbound's peer for your email now carries 10.8.1.x/32 while your WireGuard client still sources packets from 10.0.0.x, so xray-core's WireGuard inbound drops them. AmneziaWG keeps working because its peers are derived from the inbound's own settings JSON, never from the clients table (internal/amneziawg/instance.go:27-46). Saving an AmneziaWG inbound also forces a full Xray restart rather than a hot swap (internal/xray/hot_diff.go:164-165), which is why it breaks the moment you press Save instead of at the next restart.

Check it on your server

jq '.inbounds[] | select(.protocol=="wireguard") | .settings.peers' /usr/local/x-ui/bin/config.json

If the allowedIPs printed there sits in your AmneziaWG subnet instead of your WireGuard one, that is this bug. (I cannot run the panel here, so this is the one thing worth confirming from your side.)

Workaround until it is fixed

Give the device two separate client identities — two different emails, one attached to the WireGuard inbound and one to the AmneziaWG inbound. Each gets its own clients row, so neither can overwrite the other's address. Attaching a single identity to both tunnel protocols is what triggers the overwrite.

The missing options in the client popup

That part is cosmetic and separate. When both a WireGuard and an AmneziaWG inbound are attached, the private key / public key / pre-shared key inputs get relabelled with the AmneziaWG strings even though they are the same shared fields — frontend/src/pages/clients/ClientFormModal.tsx:1194-1237, e.g. showAmneziawg ? 'pages.clients.amneziaWgPrivateKey' : 'pages.clients.wireguardPrivateKey'. The AllowedIPs input does correctly split into two separately labelled fields in that case (ClientFormModal.tsx:1240-1257). Nothing is removed; the labels just stop saying "WireGuard".


Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause: XrayService.GetXrayConfig builds a WireGuard inbound's peers[] from the shared clients row instead of that inbound's own settings JSON — internal/web/service/xray.go:183 (ListForInbound, which selects clients.*) feeding internal/web/service/xray.go:246-247 (model.WireguardPeerFromClient). model.ClientRecord has a single wg_allowed_ips column (internal/database/model/model.go:928), and applyClientRecordMerge (internal/web/service/client_link.go:51-52) lets the last tunnel inbound persisted win it. Triggering condition: one client identity attached to both a wireguard and an amneziawg inbound, which by design hold addresses in different subnets. Reachable since effcccce feat(amneziawg): add native AmneziaWG protocol support (#6105), the commit that introduced model.AmneziaWG as a second protocol sharing the WireGuard client columns; the ListForInbound-based peer generation itself is older.
Already fixed: Still present on the default branch (tip f727d04f, v3.7.0 — the same version reported).
Duplicate of: None. Related: #5785 (address duplication across two WireGuard inbounds) — same table, different root cause (allocation collision, addressed by the crossInboundUsed / otherTunnelAllowedIPs path in internal/web/service/client_inbound_apply.go:253), so not a duplicate.
Evidence: internal/web/service/xray.go:183 dbClients, listErr := s.inboundService.clientService.ListForInbound(nil, inbound.Id); internal/web/service/xray.go:246-247 case model.WireGuard: wgPeers = append(wgPeers, model.WireguardPeerFromClient(c)); internal/web/service/client_link.go:307-312 tx.Table("clients").Select("clients.*, client_inbounds.flow_override AS flow_override"); internal/database/model/model.go:928 AllowedIPs string \gorm:"column:wg_allowed_ips"`; internal/database/model/model.go:1200 AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs); internal/database/model/model.go:438-439 peer["allowedIPs"] = c.AllowedIPs; internal/web/service/client_link.go:51-52the guarded overwrite;internal/web/service/client_crud.go:839-840the Attach-side clear that guarantees the two addresses differ;internal/amneziawg/instance.go:27-46the AmneziaWG side reading the inbound settings instead. Intent evidence that per-inbound addresses are the design, not the record column:model.Client.AllowedIPsByInbound (internal/database/model/model.go:884-891), ClientService.TunnelAllowedIPsByInbound (internal/web/service/client_lookup.go:136-143, "ClientRecord's own single AllowedIPs column can't tell two different protocol addresses apart"), and TestUpdateBroadcastAllowedIPsDoesNotOverwriteOtherInboundWhenMismatched/TestUpdateAllowedIPsByInboundAppliesDistinctValuesPerInbound (internal/web/service/client_update_allowedips_test.go:60, :84) — both assert only on the inbounds' settings JSON via inboundAllowedIPs, never on the generated Xray config, which is exactly the gap. internal/web/service/xray_wireguard_config_test.gocovers WireGuard peer emission but only for single-inbound clients. Not determined: Whether the reporter's AmneziaWG inbound uses the default10.8.1.0/24subnet. If they had manually set it to the same subnet as the WireGuard inbound, the overwritten value could coincidentally still be routable. Thejqcommand above settles it. Suggested fix: Make the WireGuard branch ofGetXrayConfigread each peer'sallowedIPs(and pre-shared key) from the WireGuard inbound's own settings JSON, the way the liveGenXrayInboundConfigpath already does viamodel.WireguardClientsToPeers, instead of from the shared clientsrow. A regression test ininternal/web/service/xray_wireguard_config_test.goseeding the existingseedDualProtocolClienthelper and asserting the emittedpeers[].allowedIPs` would pin it.

@MHSanaei

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5414944822 --> @github-actions[bot] commented on GitHub (Aug 25, 2026): Confirmed bug, and it is not a conflict between the two protocols on the wire: your client identity has **one** WireGuard address column in the database, attaching it to the AmneziaWG inbound overwrites it, and the panel then rebuilds the *WireGuard* inbound's peer list from that overwritten value. ## What actually happens **1. The panel deliberately gives the identity a different address on each tunnel inbound.** WireGuard's default subnet is `10.0.0.0/24` (`internal/web/service/client_wireguard.go:15`, `const defaultWireguardBase = "10.0.0.0/24"`) and AmneziaWG's is `10.8.1.0/24` (`frontend/src/schemas/protocols/inbound/amneziawg.ts:54`, `subnetIp: z.string().default('10.8.1.0')`). So when you attach an identity that already holds a WireGuard address to an AmneziaWG inbound, the inherited address is cleared and a fresh in-subnet one is allocated: ```go // internal/web/service/client_crud.go:839 if !addressesFitAmneziaWGInbound(copyClient.AllowedIPs, inbound) { copyClient.AllowedIPs = nil } ``` **2. Persisting that new AmneziaWG peer writes its address into the *shared* client row.** `model.ClientRecord` has exactly one column for it — `internal/database/model/model.go:928`: ```go AllowedIPs string `json:"allowedIPs" gorm:"column:wg_allowed_ips"` ``` and every per-inbound persist funnels through the same merge (`internal/web/service/client_link.go:51`): ```go if incoming.AllowedIPs != "" { row.AllowedIPs = incoming.AllowedIPs } ``` After the AmneziaWG save, `clients.wg_allowed_ips` for your email is the AmneziaWG address (e.g. `10.8.1.2/32`). **3. The WireGuard inbound's `peers[]` is regenerated from that shared row, not from the WireGuard inbound's own settings JSON** — `internal/web/service/xray.go:183` and `:246`: ```go dbClients, listErr := s.inboundService.clientService.ListForInbound(nil, inbound.Id) ... case model.WireGuard: wgPeers = append(wgPeers, model.WireguardPeerFromClient(c)) ``` `ListForInbound` selects `clients.*` (`internal/web/service/client_link.go:307-312`), `ClientRecord.ToClient` maps that single column straight into the peer (`internal/database/model/model.go:1200`, `AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs)`), and `WireguardPeerFromClient` emits it verbatim (`internal/database/model/model.go:438-439`, `peer["allowedIPs"] = c.AllowedIPs`). Net effect: the WireGuard inbound's peer for your email now carries `10.8.1.x/32` while your WireGuard client still sources packets from `10.0.0.x`, so xray-core's WireGuard inbound drops them. AmneziaWG keeps working because its peers are derived from the inbound's own settings JSON, never from the clients table (`internal/amneziawg/instance.go:27-46`). Saving an AmneziaWG inbound also forces a full Xray restart rather than a hot swap (`internal/xray/hot_diff.go:164-165`), which is why it breaks the moment you press Save instead of at the next restart. ## Check it on your server ```bash jq '.inbounds[] | select(.protocol=="wireguard") | .settings.peers' /usr/local/x-ui/bin/config.json ``` If the `allowedIPs` printed there sits in your AmneziaWG subnet instead of your WireGuard one, that is this bug. (I cannot run the panel here, so this is the one thing worth confirming from your side.) ## Workaround until it is fixed Give the device **two separate client identities** — two different emails, one attached to the WireGuard inbound and one to the AmneziaWG inbound. Each gets its own `clients` row, so neither can overwrite the other's address. Attaching a single identity to both tunnel protocols is what triggers the overwrite. ## The missing options in the client popup That part is cosmetic and separate. When both a WireGuard and an AmneziaWG inbound are attached, the private key / public key / pre-shared key inputs get relabelled with the AmneziaWG strings even though they are the same shared fields — `frontend/src/pages/clients/ClientFormModal.tsx:1194-1237`, e.g. `showAmneziawg ? 'pages.clients.amneziaWgPrivateKey' : 'pages.clients.wireguardPrivateKey'`. The AllowedIPs input does correctly split into two separately labelled fields in that case (`ClientFormModal.tsx:1240-1257`). Nothing is removed; the labels just stop saying "WireGuard". --- Verdict: Confirmed bug Severity: High Confidence: High Root cause: `XrayService.GetXrayConfig` builds a WireGuard inbound's `peers[]` from the shared `clients` row instead of that inbound's own settings JSON — `internal/web/service/xray.go:183` (`ListForInbound`, which selects `clients.*`) feeding `internal/web/service/xray.go:246-247` (`model.WireguardPeerFromClient`). `model.ClientRecord` has a single `wg_allowed_ips` column (`internal/database/model/model.go:928`), and `applyClientRecordMerge` (`internal/web/service/client_link.go:51-52`) lets the last tunnel inbound persisted win it. Triggering condition: one client identity attached to both a `wireguard` and an `amneziawg` inbound, which by design hold addresses in different subnets. Reachable since effcccce `feat(amneziawg): add native AmneziaWG protocol support (#6105)`, the commit that introduced `model.AmneziaWG` as a second protocol sharing the WireGuard client columns; the `ListForInbound`-based peer generation itself is older. Already fixed: Still present on the default branch (tip `f727d04f`, `v3.7.0` — the same version reported). Duplicate of: None. Related: #5785 (address duplication across two WireGuard inbounds) — same table, different root cause (allocation collision, addressed by the `crossInboundUsed` / `otherTunnelAllowedIPs` path in `internal/web/service/client_inbound_apply.go:253`), so not a duplicate. Evidence: `internal/web/service/xray.go:183` `dbClients, listErr := s.inboundService.clientService.ListForInbound(nil, inbound.Id)`; `internal/web/service/xray.go:246-247` `case model.WireGuard: wgPeers = append(wgPeers, model.WireguardPeerFromClient(c))`; `internal/web/service/client_link.go:307-312` `tx.Table("clients").Select("clients.*, client_inbounds.flow_override AS flow_override")`; `internal/database/model/model.go:928` `AllowedIPs string \`gorm:"column:wg_allowed_ips"\``; `internal/database/model/model.go:1200` `AllowedIPs: splitWireguardAllowedIPs(r.AllowedIPs)`; `internal/database/model/model.go:438-439` `peer["allowedIPs"] = c.AllowedIPs`; `internal/web/service/client_link.go:51-52` the guarded overwrite; `internal/web/service/client_crud.go:839-840` the Attach-side clear that guarantees the two addresses differ; `internal/amneziawg/instance.go:27-46` the AmneziaWG side reading the inbound settings instead. Intent evidence that per-inbound addresses are the design, not the record column: `model.Client.AllowedIPsByInbound` (`internal/database/model/model.go:884-891`), `ClientService.TunnelAllowedIPsByInbound` (`internal/web/service/client_lookup.go:136-143`, "ClientRecord's own single AllowedIPs column can't tell two different protocol addresses apart"), and `TestUpdateBroadcastAllowedIPsDoesNotOverwriteOtherInboundWhenMismatched` / `TestUpdateAllowedIPsByInboundAppliesDistinctValuesPerInbound` (`internal/web/service/client_update_allowedips_test.go:60`, `:84`) — both assert only on the inbounds' settings JSON via `inboundAllowedIPs`, never on the generated Xray config, which is exactly the gap. `internal/web/service/xray_wireguard_config_test.go` covers WireGuard peer emission but only for single-inbound clients. Not determined: Whether the reporter's AmneziaWG inbound uses the default `10.8.1.0/24` subnet. If they had manually set it to the same subnet as the WireGuard inbound, the overwritten value could coincidentally still be routable. The `jq` command above settles it. Suggested fix: Make the WireGuard branch of `GetXrayConfig` read each peer's `allowedIPs` (and pre-shared key) from the WireGuard inbound's own settings JSON, the way the live `GenXrayInboundConfig` path already does via `model.WireguardClientsToPeers`, instead of from the shared `clients` row. A regression test in `internal/web/service/xray_wireguard_config_test.go` seeding the existing `seedDualProtocolClient` helper and asserting the emitted `peers[].allowedIPs` would pin it. @MHSanaei *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@Ramazik commented on GitHub (Aug 26, 2026):

I can confirm the error and the screenshots. AmneziaWG isn't working for me. I already had a WireGuard inbound configuration set up prior to the update. I tried disabling the WireGuard inbound configuration and removing the WireGuard subscription from the user profile. I tried various combinations of these steps, but I couldn't get AmneziaWG to work with the AmneziaVPN app (version v5.0.1.5), which supports protocol v3.1.

<!-- gh-comment-id:5425686771 --> @Ramazik commented on GitHub (Aug 26, 2026): I can confirm the error and the screenshots. AmneziaWG isn't working for me. I already had a WireGuard inbound configuration set up prior to the update. I tried disabling the WireGuard inbound configuration and removing the WireGuard subscription from the user profile. I tried various combinations of these steps, but I couldn't get AmneziaWG to work with the AmneziaVPN app (version v5.0.1.5), which supports protocol v3.1.
Author
Owner

@Erapchu commented on GitHub (Aug 26, 2026):

I can confirm the error and the screenshots. AmneziaWG isn't working for me. I already had a WireGuard inbound configuration set up prior to the update. I tried disabling the WireGuard inbound configuration and removing the WireGuard subscription from the user profile. I tried various combinations of these steps, but I couldn't get AmneziaWG to work with the AmneziaVPN app (version v5.0.1.5), which supports protocol v3.1.

Don't use AmneziaVPN to connect to AmneziaWG published via 3X-UI. Use AmneziaWG native app (almost same as WireGuard native app) on smart-phones or PC.

<!-- gh-comment-id:5428407373 --> @Erapchu commented on GitHub (Aug 26, 2026): > I can confirm the error and the screenshots. AmneziaWG isn't working for me. I already had a WireGuard inbound configuration set up prior to the update. I tried disabling the WireGuard inbound configuration and removing the WireGuard subscription from the user profile. I tried various combinations of these steps, but I couldn't get AmneziaWG to work with the AmneziaVPN app (version v5.0.1.5), which supports protocol v3.1. Don't use AmneziaVPN to connect to AmneziaWG published via 3X-UI. Use AmneziaWG native app (almost same as WireGuard native app) on smart-phones or PC.
Author
Owner

@Ramazik commented on GitHub (Aug 26, 2026):

Don't use AmneziaVPN to connect to AmneziaWG published via 3X-UI. Use AmneziaWG native app (almost same as WireGuard native app) on smart-phones or PC.

I use both apps. Updates adding support for the v3.1 protocol were released simultaneously for both AmneziaVPN and AmneziaWG, though I noticed the update for the latter later.

Just an update: the AWG protocol is working now (but the speed is very low, around 2.5 megabits).
The issue was an incompatibility with the running "zapret" application by bol-van. It’s a weird situation—apparently, it’s incompatible with protocol version 3.1, even though I never had to disable zapret with other AWG connections using earlier protocol versions.

<!-- gh-comment-id:5431188483 --> @Ramazik commented on GitHub (Aug 26, 2026): > Don't use AmneziaVPN to connect to AmneziaWG published via 3X-UI. Use AmneziaWG native app (almost same as WireGuard native app) on smart-phones or PC. I use both apps. Updates adding support for the v3.1 protocol were released simultaneously for both AmneziaVPN and AmneziaWG, though I noticed the update for the latter later. **Just an update: the AWG protocol is working now (but the speed is very low, around 2.5 megabits). The issue was an incompatibility with the running "zapret" application by bol-van. It’s a weird situation—apparently, it’s incompatible with protocol version 3.1, even though I never had to disable zapret with other AWG connections using earlier protocol versions.**
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#4298
No description provided.