璟雯院

珺璟如晔,雯华若锦

用户工具

站点工具


tech:homelab:sing-box

Sing-box

先说结论:婕莺也不知道怎么就跑起来了,真的太奇妙了。反正跑起来了。就先这样用吧。

首先需要软路由配置:Openwrt 23.0以上。需要打开的网页:

安装Sing-Box

opkg update
opkg install kmod-inet-diag kmod-netlink-diag kmod-tun kmod-tcp-bbr
opkg install sing-box curl nano

在 /etc/sing-box 中存在一个配置文件,该配置文件是全局配置文件,所有的配置都从这设置。所以在网络上生成的配置都需要存这里。

可以使用命令

wget -U "sing-box" "订阅地址" -O /etc/sing-box/xxx.json

生成配置的服务是: sing-box-subscribe

可以简单写个Dockerfile挂在VSP上跑。

 

然后直接docker run即可,不过在挂载的时候可能遇到无法下载images的验证问题,用GPT-4问问就解决了。

配置Sing-Box

婕莺使用TUN模式,当然此模式不好的地方在于慢和ssh无法使用,不过婕莺也尝试了Tproxy配置,配了一天还是放弃了。

配置主要分为2步:

  1. 修改防火墙
  2. 修改Sing-Box配置
config zone
        option name 'proxy'
        option forward 'REJECT'
        option output 'ACCEPT'
        option input 'ACCEPT'
        option mtu_fix '1'
        option device 'tun0'
        list network 'proxy'
 
config forwarding
        option name 'lan-proxy'
        option dest 'proxy'
        option src 'lan'
 
config interface 'proxy'
        option proto 'none'
        option device 'tun0'
{
      "type": "tun",
      "tag": "tun-in",
      "interface_name": "tun0",
      "mtu": 9000,
      "inet4_address": "172.19.0.1/30",
      "auto_route": true,
      "stack": "system",
      "sniff": true,
      "sniff_override_destination": true
}

然后重启OpenWRT的firewall。启动Sing-Box,结束。

/app/www/public/data/pages/tech/homelab/sing-box.txt · 最后更改: 2024/04/09 12:24 由 温婕莺