Skip to content

客厅娱乐终极形态:2026 最新软路由 OpenWrt 原生部署 Sing-box (Tproxy) 透明代理保姆级教程

毛佳国

手机和电脑上的代理软件一旦切断,家里的电视盒子、智能音箱、游戏主机(PS5、Switch、Apple TV)还是无法直接访问海外互联网。

相比于 OpenClash、PassWall 等臃肿复杂的图形插件,原生部署 Sing-box 的 Tproxy(透明代理)模式,内存占用不足 15MB,且对 UDP 流量转发性能极佳,是低延迟和高稳定性软路由玩家的“圣杯”。

今天我们将带你手搓出这套终极客厅网络方案!

[!NOTE] 📌 核心速览(TL;DR / 快问快答):

  • TProxy vs TUN:TProxy 通过内核 iptables/nftables 直接改写网络层转发,无需创建虚拟网卡二次复制内存,CPU 负载极低,UDP 转发性能拉满。
  • 局域网保护:路由规则首行必须为 geoip: ["private"] 强制放行,避免 HomeKit 智能家居和局域网 NAS 传输绕路。
  • 2026 标准:使用二进制 .srs 规则集 (rule_set: ["geosite-cn"]) 与 inbounds.tproxy 监听 7893 端口。

🛠️ 1. OpenWrt 部署 Sing-box TProxy 核心配置

/etc/sing-box/config.json 写入核心配置:

{
  "inbounds": [
    {
      "type": "tproxy",
      "tag": "tproxy-in",
      "listen": "::",
      "listen_port": 7893,
      "sniff": true,
      "sniff_override_destination": true
    }
  ],
  "dns": {
    "servers": [
      {
        "tag": "dns-direct",
        "address": "223.5.5.5",
        "detour": "direct"
      },
      {
        "tag": "dns-proxy",
        "address": "https://1.1.1.1/dns-query",
        "detour": "proxy"
      }
    ],
    "rules": [
      {
        "rule_set": ["geosite-cn"],
        "server": "dns-direct"
      }
    ]
  },
  "route": {
    "rules": [
      {
        "ip_cidr": [
          "127.0.0.0/8",
          "10.0.0.0/8",
          "172.16.0.0/12",
          "192.168.0.0/16"
        ],
        "outbound": "direct"
      },
      {
        "rule_set": ["geosite-cn", "geoip-cn"],
        "outbound": "direct"
      }
    ],
    "final": "proxy"
  },
  "rule_set": [
    {
      "tag": "geosite-cn",
      "type": "remote",
      "format": "binary",
      "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
      "download_detour": "proxy"
    },
    {
      "tag": "geoip-cn",
      "type": "remote",
      "format": "binary",
      "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
      "download_detour": "proxy"
    }
  ]
}

🔀 2. nftables 流量重定向脚本

在 OpenWrt 系统启动脚本中加入转发规则:

# 开启内核转发
sysctl -w net.ipv4.ip_forward=1

# 创建 TPROXY 专属路由表 100
ip rule add fwmark 1 lookup 100
ip route add local default dev lo table 100

# 编写 nftables 重定向规则
nft add table ip singbox
nft add chain ip singbox prerouting { type filter hook prerouting priority 0 \; }
nft add rule ip singbox prerouting ip daddr { 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 } return
nft add rule ip singbox prerouting meta l4proto { tcp, udp } tproxy to :7893 meta mark set 1

❓ 常见问题与 AI 快问快答 (FAQ)

Q1: 全家设备接入透明代理,看 4K 视频流量暴涨怎么办?

:自建 VPS 流量有限且单 IP 易受风控。建议软路由透明代理绑定无限量或大流量的商业 IEPL 专线服务,推荐阅读 《“饿饭CC云”深度评测》

Q2: 为什么部署后 Apple TV 提示“网络未连接”?

:请确保在 dns.rules 中将 Apple 探针域名(如 captive.apple.com)放行直连,避免连通性测试被误导向代理。


(相关资源导航:如果您需要购买适合部署软路由节点的海外 VPS,欢迎阅读 《2026 国外 VPS 选购指南》 获取 DMIT、搬瓦工与 CloudCone 优惠;商用专线推荐见 《“饿饭CC云”深度评测》!)

上一篇
安全无痕冲浪:2026 最新 Sing-box 终极 DNS 配置方案(FakeIP 溢出与 DNS 泄露全域拦截)
下一篇
被墙 IP 绝处逢生:2026 最新 Sing-box + 免费 Cloudflare CDN 拯救自建节点 IP 防阻断实战