仅作技术交流,请勿违反所在地法律或从事非法活动。
本文探讨用233boy的sing-box一键脚本实现的技术可能性。
版本:sing-box 1.13.8 / sing-box script v1.15 1.修改 Service 文件(注入环境变量)
为了在不彻底重写所有旧配置的情况下兼容新内核,必须在 Systemd 服务中注入允许旧语法的环境变量。
文件路径:/lib/systemd/system/sing-box.service
在 [Service] 块下添加以下两行:
Environment="ENABLE_DEPRECATED_LEGACY_DNS_SERVERS=true"
Environment="ENABLE_DEPRECATED_LEGACY_DOMAIN_STRATEGY_OPTIONS=true"贴一个完整配置
[Unit]
Description=sing-box Service
Documentation=https://sing-box.sagernet.org/
After=network.target nss-lookup.target
[Service]
Environment="ENABLE_DEPRECATED_LEGACY_DNS_SERVERS=true"
Environment="ENABLE_DEPRECATED_LEGACY_DOMAIN_STRATEGY_OPTIONS=true"
#User=nobody
User=root
NoNewPrivileges=true
ExecStart=/etc/sing-box/bin/sing-box run -c /etc/sing-box/config.json -C /etc/sing-box/conf
Restart=on-failure
RestartPreventExitStatus=23
LimitNPROC=10000
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
#CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target生效命令
systemctl daemon-reload
systemctl restart sing-box2.精简主配置文件 config.json
在多分片模式下,主文件应保持简洁,仅保留全局日志和基础 DNS 设置。
文件路径:/etc/sing-box/config.json
{
"log": {
"output": "/var/log/sing-box/access.log",
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "google",
"address": "udp://8.8.8.8"
}
]
}
}
3.新增自定义功能分片(如 IPv6 优先路由)
为了不破坏脚本生成的 VLESS/VMESS 文件,将自定义路由逻辑单独存放在 conf 文件夹中。
文件路径:/etc/sing-box/conf/00_custom_route.json
功能:指定 Google/YouTube 流量优先走 IPv6:
{
"outbounds": [
{
"type": "direct",
"tag": "direct-6",
"domain_strategy": "prefer_ipv6"
}
],
"route": {
"rules": [
{
"domain_keyword": ["google", "googlevideo","youtube"],
"outbound": "direct-6"
}
]
}
}配置检查命令/etc/sing-box/bin/sing-box check -c /etc/sing-box/config.json -C /etc/sing-box/conf
参考文章:IPv4单栈VPS 装Cloudflare WARP 使用IPv6访问Google 解决人机身份验证 YouTube不能评论
dd/rn