[GH-ISSUE #5523] [Question]: Is there a way to automaticly set outbounds to inbound's listen address #3855

Closed
opened 2026-10-31 20:35:26 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @herotm on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5523

What are you trying to do?

I have multiple nodes with multiple ip addresses, I understand the process of adding them manually via the Outbounds/Routing page to have them correspond to the Inbound ip.

Logging into multiple panels to do this manually is a bit Tedious, is there anyway this can be done easily to use outbound as its inbound.

What have you already tried?

No response

3x-ui version

3.4.0

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

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 @herotm on GitHub (Jun 23, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5523 ### What are you trying to do? I have multiple nodes with multiple ip addresses, I understand the process of adding them manually via the Outbounds/Routing page to have them correspond to the Inbound ip. Logging into multiple panels to do this manually is a bit Tedious, is there anyway this can be done easily to use outbound as its inbound. ### What have you already tried? _No response_ ### 3x-ui version 3.4.0 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### 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:35:26 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 23, 2026):

The panel has no built-in feature that automatically derives an outbound's bind address from an inbound's listen address. This was confirmed by reading internal/web/service/xray.go, internal/xray/config.go, and internal/database/model/model.go: the listen field on an inbound is used only to bind the listener socket and (optionally) to populate subscription share-links; it has no effect on outbound configuration.

What the current architecture supports

The Xray template JSON (editable under Settings → Xray Settings) is passed through to Xray-core as-is. Xray-core's outbound objects accept a sendThrough field that pins the source IP for outgoing connections. Routing rules support inboundTag as a match condition and can direct matched traffic to a specific outbound. Combining these two Xray-core primitives achieves the desired result:

  1. For each source IP on the server, add an outbound object to the template with sendThrough set to that IP and a unique tag:
    {
      "tag": "egress-192.0.2.10",
      "protocol": "freedom",
      "settings": {},
      "sendThrough": "192.0.2.10"
    }
    
  2. For each inbound that should use a particular source IP, add a routing rule that matches its tag and routes to the matching outbound:
    {
      "type": "field",
      "inboundTag": ["my-inbound-tag"],
      "outboundTag": "egress-192.0.2.10"
    }
    

These edits are made directly in the Xray Settings JSON editor in the panel. The template is stored in the SQLite database and applied at Xray startup.

Automating this across multiple panels

The panel exposes a REST API. The relevant endpoints, relative to your panel's base path, are:

  • POST /panel/api/xray/ — retrieves the current Xray template JSON (field xraySetting in the response)
  • POST /panel/api/xray/update — saves a new template and restarts Xray

Authentication uses the same session cookie as the web UI; you can obtain a session by POST /panel/api/login with {"username":"...","password":"..."} and pass the returned Set-Cookie in subsequent requests.

A script can therefore:

  1. Log in to each panel.
  2. GET the current template.
  3. Merge the appropriate sendThrough outbound entries and routing rules into the JSON.
  4. POST the updated template back.

The OpenAPI spec for the full API surface is served at <base-path>/panel/api/openapi.json and accessible via the in-panel API docs page.

Feature request note

If automatic derivation of outbound sendThrough from an inbound's listen address is something you want the panel to handle natively, that would be a new feature. You are welcome to open a separate feature request with a clear description of the desired behaviour (e.g., a checkbox per-inbound to auto-create a matching sendThrough outbound).

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

<!-- gh-comment-id:4784255502 --> @github-actions[bot] commented on GitHub (Jun 23, 2026): The panel has no built-in feature that automatically derives an outbound's bind address from an inbound's listen address. This was confirmed by reading `internal/web/service/xray.go`, `internal/xray/config.go`, and `internal/database/model/model.go`: the listen field on an inbound is used only to bind the listener socket and (optionally) to populate subscription share-links; it has no effect on outbound configuration. **What the current architecture supports** The Xray template JSON (editable under Settings → Xray Settings) is passed through to Xray-core as-is. Xray-core's outbound objects accept a `sendThrough` field that pins the source IP for outgoing connections. Routing rules support `inboundTag` as a match condition and can direct matched traffic to a specific outbound. Combining these two Xray-core primitives achieves the desired result: 1. For each source IP on the server, add an outbound object to the template with `sendThrough` set to that IP and a unique `tag`: ```json { "tag": "egress-192.0.2.10", "protocol": "freedom", "settings": {}, "sendThrough": "192.0.2.10" } ``` 2. For each inbound that should use a particular source IP, add a routing rule that matches its tag and routes to the matching outbound: ```json { "type": "field", "inboundTag": ["my-inbound-tag"], "outboundTag": "egress-192.0.2.10" } ``` These edits are made directly in the Xray Settings JSON editor in the panel. The template is stored in the SQLite database and applied at Xray startup. **Automating this across multiple panels** The panel exposes a REST API. The relevant endpoints, relative to your panel's base path, are: - `POST /panel/api/xray/` — retrieves the current Xray template JSON (field `xraySetting` in the response) - `POST /panel/api/xray/update` — saves a new template and restarts Xray Authentication uses the same session cookie as the web UI; you can obtain a session by `POST /panel/api/login` with `{"username":"...","password":"..."}` and pass the returned `Set-Cookie` in subsequent requests. A script can therefore: 1. Log in to each panel. 2. `GET` the current template. 3. Merge the appropriate `sendThrough` outbound entries and routing rules into the JSON. 4. `POST` the updated template back. The OpenAPI spec for the full API surface is served at `<base-path>/panel/api/openapi.json` and accessible via the in-panel API docs page. **Feature request note** If automatic derivation of outbound `sendThrough` from an inbound's listen address is something you want the panel to handle natively, that would be a new feature. You are welcome to open a separate feature request with a clear description of the desired behaviour (e.g., a checkbox per-inbound to auto-create a matching `sendThrough` outbound). *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jul 3, 2026):

There is no built-in option that auto-derives an outbound's source IP from an inbound's listen address, but the panel supports this pattern directly: create one outbound per source IP with sendThrough set (Xray → Outbounds), then add a routing rule matching each inbound's tag to the corresponding outbound (Xray → Routing).

To avoid doing this by hand on every panel, the same configuration can be scripted over the REST API — each panel serves its OpenAPI spec at /panel/api/openapi.json, and the Xray settings endpoints let you fetch the config, merge your sendThrough outbounds and routing rules, and push it back.

If you'd like a native per-inbound "bind outbound to listen address" toggle, feel free to open a focused feature request for that. Closing this one as an answered usage question.

<!-- gh-comment-id:4873746413 --> @MHSanaei commented on GitHub (Jul 3, 2026): There is no built-in option that auto-derives an outbound's source IP from an inbound's listen address, but the panel supports this pattern directly: create one outbound per source IP with `sendThrough` set (Xray → Outbounds), then add a routing rule matching each inbound's tag to the corresponding outbound (Xray → Routing). To avoid doing this by hand on every panel, the same configuration can be scripted over the REST API — each panel serves its OpenAPI spec at `/panel/api/openapi.json`, and the Xray settings endpoints let you fetch the config, merge your `sendThrough` outbounds and routing rules, and push it back. If you'd like a native per-inbound "bind outbound to listen address" toggle, feel free to open a focused feature request for that. Closing this one as an answered usage question.
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#3855
No description provided.