[GH-ISSUE #6798] [Question]: how to setup tcp port forwarding to wireguard peer? #4528

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

Originally created by @alexalv76-sudo on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6798

What are you trying to do?

https://github.com/MHSanaei/3x-ui/issues/4366#issue-4444225930

Here you said that this feature is implemented. But i can not setup it. Using 3x-ui pannel on server side and created "tunnel" inbound for listening tcp port. And using wireguard application for windows on peer side. Can not setup 3xui to route this traffic

What have you already tried?

No response

3x-ui version

3.10.0

How did you install 3x-ui?

install.sh script

Operating system

No response

Screenshots or config snippets

No response

Before submitting

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
Originally created by @alexalv76-sudo on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6798 ### What are you trying to do? https://github.com/MHSanaei/3x-ui/issues/4366#issue-4444225930 Here you said that this feature is implemented. But i can not setup it. Using 3x-ui pannel on server side and created "tunnel" inbound for listening tcp port. And using wireguard application for windows on peer side. Can not setup 3xui to route this traffic ### What have you already tried? _No response_ ### 3x-ui version 3.10.0 ### How did you install 3x-ui? install.sh script ### Operating system _No response_ ### Screenshots or config snippets _No response_ ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:40:17 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

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

The feature from #4366 is not set up with a Tunnel inbound, and it does not exist for the Xray WireGuard inbound. It is a per-client Forwarded Ports field that only AmneziaWG inbounds have. The panel opens the listener itself, so you don't need a Tunnel/Dokodemo inbound or a routing rule.

How to set it up

  1. Delete the Tunnel inbound you made for that port. The forward opens its own listener on the same port, so an inbound already holding that port would conflict with it.
  2. Add a new inbound with protocol AmneziaWG (not WireGuard).
  3. Add or edit a client on that inbound and fill in Forwarded Ports, for example 27015 or 80, 443, 8000-8100.
  4. Download that client's .conf (or its vpn:// link) and import it into an AmneziaWG-capable client on Windows, such as AmneziaVPN or the AmneziaWG client. The .conf contains AmneziaWG obfuscation keys (Jc, S1, H1, …), and the docs only list the AmneziaWG/AmneziaVPN apps as able to import it. So the plain WireGuard for Windows app is not expected to work here. That last point is my inference from the docs; I didn't test it.
  5. On the Windows PC, run the game or service on the same port number and allow it through Windows Firewall. The server forwards server:PORT to <client tunnel IP>:PORT with no port remapping. It forwards both TCP and UDP.

Docs: docs/content/docs/en/config/amneziawg.mdx, section "Optional: forward ports to a client".

Limits worth knowing (from the source)

  • Each port maps to the same port number on the peer. You can't map external port A to peer port B.
  • One client can forward at most 100 ports in total (MaxForwardedPorts = 100).
  • Bytes sent through a forwarded port are not added to the client's traffic stats or quota.

Evidence

  • frontend/src/pages/clients/ClientFormModal.tsx:739-743 only sends the field for AmneziaWG clients:
    // Port-forwarding has no WireGuard equivalent — Xray-native WireGuard
    // has no host-level iptables layer to hang per-client DNAT off of.
    if (showAmneziawg) {
      clientPayload.forwardedPorts = values.awgForwardedPorts.trim();
    
  • internal/amneziawgnet/portfwd.go:307 opens a real host listener on the port: net.JoinHostPort(wildcardBindHost, strconv.Itoa(key.port)). Line 342 then dials the peer's tunnel address on that same port: gonet.DialContextTCP(ctx, gstack, tunnelFullAddress(addr, key.port), ...).
  • internal/amneziawgnet/portfwd.go:42-45 gives every forwarded port both a TCP and a UDP socket.
  • internal/amneziawg/portfwd.go:100 sets the cap: const MaxForwardedPorts = 100.
  • internal/amneziawgnet/portfwd.go:16-18: forwarded-port bytes "don't appear in Xray's per-email stats/quota counters".

Verdict: Not a bug (user configuration). The feature works only on an AmneziaWG inbound, through the client's Forwarded Ports field, not through a Tunnel inbound on a WireGuard setup.

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

<!-- gh-comment-id:6129104217 --> @github-actions[bot] commented on GitHub (Oct 12, 2026): The feature from #4366 is not set up with a **Tunnel** inbound, and it does not exist for the Xray **WireGuard** inbound. It is a per-client **Forwarded Ports** field that only **AmneziaWG** inbounds have. The panel opens the listener itself, so you don't need a Tunnel/Dokodemo inbound or a routing rule. **How to set it up** 1. Delete the Tunnel inbound you made for that port. The forward opens its own listener on the same port, so an inbound already holding that port would conflict with it. 2. Add a new inbound with protocol **AmneziaWG** (not WireGuard). 3. Add or edit a client on that inbound and fill in **Forwarded Ports**, for example `27015` or `80, 443, 8000-8100`. 4. Download that client's `.conf` (or its `vpn://` link) and import it into an AmneziaWG-capable client on Windows, such as AmneziaVPN or the AmneziaWG client. The `.conf` contains AmneziaWG obfuscation keys (`Jc`, `S1`, `H1`, …), and the docs only list the AmneziaWG/AmneziaVPN apps as able to import it. So the plain WireGuard for Windows app is not expected to work here. That last point is my inference from the docs; I didn't test it. 5. On the Windows PC, run the game or service on **the same port number** and allow it through Windows Firewall. The server forwards `server:PORT` to `<client tunnel IP>:PORT` with no port remapping. It forwards both TCP and UDP. Docs: `docs/content/docs/en/config/amneziawg.mdx`, section "Optional: forward ports to a client". **Limits worth knowing (from the source)** - Each port maps to the same port number on the peer. You can't map external port A to peer port B. - One client can forward at most 100 ports in total (`MaxForwardedPorts = 100`). - Bytes sent through a forwarded port are not added to the client's traffic stats or quota. **Evidence** - `frontend/src/pages/clients/ClientFormModal.tsx:739-743` only sends the field for AmneziaWG clients: ```ts // Port-forwarding has no WireGuard equivalent — Xray-native WireGuard // has no host-level iptables layer to hang per-client DNAT off of. if (showAmneziawg) { clientPayload.forwardedPorts = values.awgForwardedPorts.trim(); ``` - `internal/amneziawgnet/portfwd.go:307` opens a real host listener on the port: `net.JoinHostPort(wildcardBindHost, strconv.Itoa(key.port))`. Line 342 then dials the peer's tunnel address on that same port: `gonet.DialContextTCP(ctx, gstack, tunnelFullAddress(addr, key.port), ...)`. - `internal/amneziawgnet/portfwd.go:42-45` gives every forwarded port both a TCP and a UDP socket. - `internal/amneziawg/portfwd.go:100` sets the cap: `const MaxForwardedPorts = 100`. - `internal/amneziawgnet/portfwd.go:16-18`: forwarded-port bytes "don't appear in Xray's per-email stats/quota counters". Verdict: Not a bug (user configuration). The feature works only on an AmneziaWG inbound, through the client's Forwarded Ports field, not through a Tunnel inbound on a WireGuard setup. *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#4528
No description provided.