[GH-ISSUE #6878] [Feature]: Allow WireGuard/AmneziaWG clients on the same inbound to reach each other (client-to-client subnet) #4568

Open
opened 2026-10-31 20:40:34 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @torabi178 on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6878

Describe the bug

When creating an inbound configuration using WireGuard or AmneziaWG, it is possible to specify a subnet IP and a CIDR prefix.
For example: 192.168.50.0/24
However, when creating a client, the system only allows the definition of a /32 subnet. To enable multiple clients to belong to the same network—thereby allowing them to ping one another—it should be possible to use a prefix smaller than 32 (e.g., /24). Unfortunately, this is not currently supported; the system returns an "overlap" error, and clients must be defined using a /32 subnet. As a result, these clients do not ping each other and are not placed on the same network.
This is extremely useful—and often necessary—for setting up a network that allows you to remotely access the settings of a router or the devices connected to it. It provides a simple way to connect devices to one another via a VPS.

How to reproduce the problem

I don't know how to fix it. Please help me for more information or to fix this problem.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.10.2

Xray-core version

26.10.10

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Xray config generation

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 @torabi178 on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6878 ### Describe the bug When creating an inbound configuration using WireGuard or AmneziaWG, it is possible to specify a subnet IP and a CIDR prefix. For example: 192.168.50.0/24 However, when creating a client, the system only allows the definition of a /32 subnet. To enable multiple clients to belong to the same network—thereby allowing them to ping one another—it should be possible to use a prefix smaller than 32 (e.g., /24). Unfortunately, this is not currently supported; the system returns an "overlap" error, and clients must be defined using a /32 subnet. As a result, these clients do not ping each other and are not placed on the same network. This is extremely useful—and often necessary—for setting up a network that allows you to remotely access the settings of a router or the devices connected to it. It provides a simple way to connect devices to one another via a VPS. ### How to reproduce the problem I don't know how to fix it. Please help me for more information or to fix this problem. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.10.2 ### Xray-core version 26.10.10 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Xray config generation ### 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).
Author
Owner

@github-actions[bot] commented on GitHub (Oct 19, 2026):

The "overlaps" error is intentional, and allowing a /24 per client would not make clients reachable from each other. Client-to-client traffic is not something either the WireGuard or the AmneziaWG inbound supports today, so I'm treating this as a feature request, not a bug.

Why each client's address has to be its own host range

In this panel, a client's allowedIPs does two jobs:

  1. On the server, it is that peer's routing entry. The server credits a packet to the peer whose range contains its source address, and sends replies by the same table.
  2. In the client's .conf, it becomes the Address line. See internal/sub/service.go:998:
    fmt.Fprintf(&b, "Address = %s\n", strings.Join(client.AllowedIPs, ", "))
    

If client A owned 192.168.50.0/24, the server would route the whole /24 to A. Client B's traffic and replies would then be credited to, or sent to, the wrong peer. That is the bug fixed in c8a182b6, "fix(wireguard): reject allowedIPs that overlap another client's range" (closes #6623, shipped in v3.10.0). The check is wireguardAllowedIPsOverlap in internal/web/service/client_wireguard.go:197-215. It is pinned by TestDefaultWireguardClientsRejectsOverlappingAllowedIPs (internal/web/service/client_wireguard_test.go:368), whose comment says:

// xray credits a packet to the first peer whose allowedIPs contain its source,
// so a prefix covering another client's address steals that client's traffic.

The same check applies to AmneziaWG (internal/web/service/client_amneziawg.go:96). This matches how WireGuard itself works: every peer on a server gets a distinct /32, even when everyone sits on one /24.

Why clients still can't ping each other

The client config already sends every destination into the tunnel (AllowedIPs = 0.0.0.0/0, ::/0, internal/sub/service.go:1065). So the client side is fine; what's missing is on the server.

Neither inbound runs a routed network that forwards packets from one peer to another. In the embedded AmneziaWG runtime, every TCP connection a peer opens is accepted by a userspace netstack and handed to Xray through a loopback SOCKS relay (internal/amneziawgnet/manager.go:208-221):

relay.RelayTCP(conn, peer.Email, dest)

Xray then sends it out through its outbounds to the real network, where 192.168.50.x does not exist. Nothing sends it back into the tunnel to the other peer. My understanding is that Xray's own WireGuard inbound works the same way: it terminates the tunnel and passes traffic into Xray routing, not between peers. That part is an inference, because that code lives in xray-core, not in this repository.

What you can do now: for a site-to-site or "reach my router through the VPS" setup, run a plain kernel WireGuard (wg-quick) or AmneziaWG interface on the VPS outside the panel, with IP forwarding enabled. That gives you real peer-to-peer routing. Adding client-to-client forwarding to the panel would be new functionality, and it's up to the maintainer whether to take that on.

I changed the title from "[Bug]: Subnet definition not applied to client IPs for WireGuard and AmnesiaWireGuard inbound configurations" so it describes what you are actually asking for.

Verdict: Feature request

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

<!-- gh-comment-id:6279531047 --> @github-actions[bot] commented on GitHub (Oct 19, 2026): The "overlaps" error is intentional, and allowing a `/24` per client would not make clients reachable from each other. Client-to-client traffic is not something either the WireGuard or the AmneziaWG inbound supports today, so I'm treating this as a feature request, not a bug. **Why each client's address has to be its own host range** In this panel, a client's `allowedIPs` does two jobs: 1. **On the server**, it is that peer's routing entry. The server credits a packet to the peer whose range contains its source address, and sends replies by the same table. 2. **In the client's `.conf`**, it becomes the `Address` line. See `internal/sub/service.go:998`: ```go fmt.Fprintf(&b, "Address = %s\n", strings.Join(client.AllowedIPs, ", ")) ``` If client A owned `192.168.50.0/24`, the server would route the whole `/24` to A. Client B's traffic and replies would then be credited to, or sent to, the wrong peer. That is the bug fixed in c8a182b6, "fix(wireguard): reject allowedIPs that overlap another client's range" (closes #6623, shipped in v3.10.0). The check is `wireguardAllowedIPsOverlap` in `internal/web/service/client_wireguard.go:197-215`. It is pinned by `TestDefaultWireguardClientsRejectsOverlappingAllowedIPs` (`internal/web/service/client_wireguard_test.go:368`), whose comment says: ```go // xray credits a packet to the first peer whose allowedIPs contain its source, // so a prefix covering another client's address steals that client's traffic. ``` The same check applies to AmneziaWG (`internal/web/service/client_amneziawg.go:96`). This matches how WireGuard itself works: every peer on a server gets a distinct `/32`, even when everyone sits on one `/24`. **Why clients still can't ping each other** The client config already sends every destination into the tunnel (`AllowedIPs = 0.0.0.0/0, ::/0`, `internal/sub/service.go:1065`). So the client side is fine; what's missing is on the server. Neither inbound runs a routed network that forwards packets from one peer to another. In the embedded AmneziaWG runtime, every TCP connection a peer opens is accepted by a userspace netstack and handed to Xray through a loopback SOCKS relay (`internal/amneziawgnet/manager.go:208-221`): ```go relay.RelayTCP(conn, peer.Email, dest) ``` Xray then sends it out through its outbounds to the real network, where `192.168.50.x` does not exist. Nothing sends it back into the tunnel to the other peer. My understanding is that Xray's own WireGuard inbound works the same way: it terminates the tunnel and passes traffic into Xray routing, not between peers. That part is an inference, because that code lives in xray-core, not in this repository. **What you can do now:** for a site-to-site or "reach my router through the VPS" setup, run a plain kernel WireGuard (`wg-quick`) or AmneziaWG interface on the VPS outside the panel, with IP forwarding enabled. That gives you real peer-to-peer routing. Adding client-to-client forwarding to the panel would be new functionality, and it's up to the maintainer whether to take that on. I changed the title from "[Bug]: Subnet definition not applied to client IPs for WireGuard and AmnesiaWireGuard inbound configurations" so it describes what you are actually asking for. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#4568
No description provided.