跳转至
编辑此页

透明代理入站(TProxy 与 Redir)

除 TUN 之外,ClashRS 还支持基于内核转发的 TProxy(TCP + UDP)与 Redir(TCP)透明代理入站。

TProxy 入站(type: tproxy)

  • 支持平台:仅 Linux 与 Android(其他平台启用时会打印警告并跳过)。
  • 编译特性:tproxy(默认 standard 构建已启用)。
  • 传输层:TCP 与 UDP(依赖 IP_TRANSPARENT)。
  • 类型别名:同时支持 type: tproxy 与 type: t-proxy。

独有字段

除通用监听器字段(name、listen、port、allow-lan、fw-mark)外:

YAML 键名 类型 默认值 说明
udp bool true 配置字段兼容;运行时 TproxyInbound 始终处理 UDP。
dns-hijack bool true 是否劫持经由 TProxy 的 UDP DNS 流量交由内置 DNS 解析。
tproxy-port: 7893
routing-mark: 6666
listeners:
  - name: tproxy-in
    type: tproxy
    listen: 0.0.0.0
    port: 7893
    udp: true
    dns-hijack: true
    fw-mark: 6666

Linux 路由防环

务必配置顶层 routing-mark(或 fw-mark),并在 iptables / nftables 的 TPROXY 规则中跳过带有该标记的数据包,避免 ClashRS 自身发出的出站流量再次回流至 tproxy-port。

Redir 入站(type: redir)

  • 支持平台:仅 Linux(依赖 SO_ORIGINAL_DST / IP6T_SO_ORIGINAL_DST)。
  • 编译特性:redir(默认 standard 构建已启用)。
  • 传输层:仅 TCP。
  • 独有字段:除通用监听器字段外无额外字段。
redir-port: 7892
routing-mark: 6666
listeners:
  - name: redir-in
    type: redir
    listen: 0.0.0.0
    port: 7892
    allow-lan: true
    fw-mark: 6666