Skip to content

Linux TUN auto outbound interface can be lost after autoSystemRoutingTable routes traffic through TUN #6412

Closed

Description

@Katze-942

Integrity requirements

  • I have read all the comments in the issue template and ensured that this issue meet the requirements.
  • I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
  • I searched issues and did not find any similar issues.
  • The problem can be successfully reproduced in the latest Release

Description

When Linux native TUN is used with autoSystemRoutingTable: ["0.0.0.0/0"] and without an explicit autoOutboundsInterface, Xray initially selects the physical outbound interface correctly. However, after a route/link update, automatic interface detection can fail.

I assume that after the TUN route is installed, a route update is emitted, which causes findOutboundInterface() to run again. After the TUN default route is installed, any later route/link update can make Xray re-run automatic outbound interface detection.

This is reproducible with freedom outbound only, so no server-side Xray instance is required.

Reproduction Method

  1. Use a Linux environment where Xray can create a TUN interface and manage routes.
  2. Make sure the existing physical IPv4 default route has a higher metric than the route Xray will install for TUN. For example:
ip -4 route

Example before starting Xray:

  default via 10.94.42.1 dev eth0 metric 100
  1. Start Xray with the client configuration provided below. Do not manually change routes after startup.
  2. Optionally, in another terminal, run this before starting Xray to observe the kernel route/link events:
ip monitor route link
  1. After Xray starts, it initially detects the physical outbound interface correctly:
[tun] update interface eth0 ...
xray_tun up
Xray 26.6.27 started
  1. Wait a few seconds. The system emits route/link events for the newly created TUN interface, such as xray_tun becoming UP, IPv6 link-local routes being added, and the TUN default route being installed.
  2. Xray then re-runs automatic outbound interface detection and fails:
  [tun] failed to update interface > proxy/tun: no usable outbound interface found

No manual route changes are required to reproduce this in my test environment. The route/link events are produced by the TUN interface setup itself.

Client config

Details

{
  "log": {
    "loglevel": "debug",
    "dnsLog": true
  },
  "inbounds": [
    {
      "tag": "tun-in",
      "port": 0,
      "protocol": "tun",
      "settings": {
        "name": "xray_tun",
        "mtu": 1500,
        "autoSystemRoutingTable": [
          "0.0.0.0/0"
        ]
      }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "process": [
          "curl"
        ],
        "outboundTag": "direct"
      },
      {
        "type": "field",
        "inboundTag": [
          "tun-in"
        ],
        "outboundTag": "direct"
      }
    ]
  }
}

Server config

No server is needed.

Client log

Details

Xray 26.6.27 (Xray, Penetrates Everything.) 45cf289 (go1.26.4 linux/amd64)
A unified platform for anti-censorship.
2026/06/30 12:16:56.761963 [Info] infra/conf/serial: Reading config: &{Name:/tmp/xray-compact.json Format:json}
2026/06/30 12:16:56.764315 [Debug] app/log: Logger started
2026/06/30 12:16:56.767334 [Info] proxy/tun: [tun] update interface eth0 488
2026/06/30 12:16:56.767374 [Info] proxy/tun: xray_tun created
2026/06/30 12:16:56.772696 [Info] proxy/tun: xray_tun up
2026/06/30 12:16:56.772858 [Warning] core: Xray 26.6.27 started
2026/06/30 12:16:58.739816 [Info] proxy/tun: [tun] failed to update interface > proxy/tun: no usable outbound interface found
2026/06/30 12:16:58.846031 [Info] proxy/tun: [tun] failed to update interface > proxy/tun: no usable outbound interface found

Server log

No server is needed.

Activity

  1. Jasper344612 commented on Jun 30, 2026

    @Jasper344612
    Contributor

    I will check the problem as soon as fast.

  2. Jasper344612 commented on Jun 30, 2026

    @Jasper344612
    Contributor

    This bug happens because the route monitor run again after the tun interface created.

  3. Fangliding commented on Jun 30, 2026

    @Fangliding
    Member

    #6366 似乎使用了错误的方法计算默认出站 如果路由表只有一条默认通向xray tun的路由 那么可能会被过滤掉然后找不到接口 并且丢弃了详细错误

  4. Jasper344612 commented on Jun 30, 2026

    @Jasper344612
    Contributor

    #6366 似乎使用了错误的方法计算默认出站 如果路由表只有一条默认通向xray tun的路由 那么可能会被过滤掉然后找不到接口 并且丢弃了详细错误

    是的,我在我的电脑上没能复现,因为在tun启动后任然有一条原来的默认路由,不过这个问题确实可能发生,我会尽快修好

    phillip@phillip-virtual-machine:~/Desktop$ ip route 
    default dev xray_tun metric 1 
    default via 192.168.200.2 dev ens33 proto dhcp metric 100 
    169.254.0.0/16 dev ens33 scope link metric 1000 
    192.168.200.0/24 dev ens33 proto kernel scope link src 192.168.200.132 metric 100 
    
    
    Image
  5. added a commit that references this issue on Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions