写在前面

在我看来,使用sing-box进行科学上网是最稳定的一种方案,我目前使用的这段时间里,有两点,其一是稳定,其二是安全性高,为什么我说安全性高呢?在我看来TUN模式下的DNS泄露是最考验代理工具是否具有足够的能力去捕获大众的芳心,而且是在Real-ip模式下,不是Fake-ip,而且在配置方面,当你熟悉了之后,其实也没有那么难写,就像写clash的配置文件一样,如鱼得水。

安装sing-box

我所使用的平台为x86架构的Debian12 Bookworm进行演示,我先给出sing-box的Github链接

https://github.com/SagerNet/sing-box/releases

我的话就选择后缀为amd64.deb这个安装包吧,链接在下面

https://github.com/SagerNet/sing-box/releases/download/v1.8.0/sing-box_1.8.0_linux_amd64.deb

运行以下命令进行下载安装

wget -O sing-box.deb https://github.com/SagerNet/sing-box/releases/download/v1.8.0/sing-box_1.8.0_linux_amd64.deb
dpkg -i sing-box && rm sing-box.deb

使用这个命令检查是否安装成功

sing-box version

有返回则没问题,可以进行下一步了

手搓配置文件

sing-box的配置文件时json格式的,所以我们要注意json的文本书写格式,不然会运行不起来

下面是我的示例配置文件,到时候只需要修改outbound就好了,节点格式的建议去官网查看,链接我也放到下面

官网链接

https://sing-box.sagernet.org/

配置示例

{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "google",
"address": "tls://8.8.8.8",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "cloudflare",
"address": "tls://1.0.0.1",
"strategy": "",
"detour": "direct"
},
{
"tag": "alidns",
"address": "tls://223.5.5.5",
"strategy": "",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://success"
}
],
"rules": [
{
"rule_set": [
"geoip-cn",
"geosite-cn",
"geosite-private",
"geosite-bing@cn",
"geosite-geolocation-cn.srs",
"geosite-apple@cn.srs",
"geosite-microsoft@cn.srs",
"geosite-steam@cn.srs"
],
"invert": true,
"disable_cache": true,
"server": "google"
},
{
"rule_set": ["geosite-category-ads-all"],
"server": "block"
}
],
"final": "alidns",
"strategy": "prefer_ipv4",
"disable_cache": false,
"disable_expire": false
},
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"inet4_address": "172.19.0.1/30",
"auto_route": true,
"strict_route": false,
"stack": "system",
"sniff": true,
"sniff_override_destination": false
},
{
"type": "mixed",
"tag": "mixed-in",
"listen": "::",
"listen_port": 5353,
"tcp_fast_open": false,
"sniff": true,
"sniff_override_destination": false,
"set_system_proxy": false
}
],
"outbounds": [
{
"type": "selector",
"tag": "proxy",
"outbounds": [
"node 1",
"node 2",
"node 3"
]
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"rules": [
{
"protocol": ["dns"],
"outbound": "dns-out"
},
{
"protocol": ["quic"],
"outbound": "block"
},
{
"rule_set": [
"geoip-cn",
"geosite-cn",
"geosite-private",
"geosite-bing@cn",
"geosite-geolocation-cn.srs",
"geosite-apple@cn.srs",
"geosite-microsoft@cn.srs",
"geosite-steam@cn.srs"
],
"invert": true,
"outbound": "proxy"
}
],
"rule_set": [
{
"tag": "geosite-category-ads-all",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-category-ads-all.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"
},
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-private",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-private.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-bing@cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-bing@cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-geolocation-cn.srs",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-apple@cn.srs",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-apple@cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-microsoft@cn.srs",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-microsoft@cn.srs",
"download_detour": "proxy"
},
{
"tag": "geosite-steam@cn.srs",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-steam@cn.srs",
"download_detour": "proxy"
}
],
"final": "direct",
"auto_detect_interface": true
},
"experimental": {
"cache_file": {
"enabled": true,
"path": "cache.db",
"cache_id": "mycacheid"
},
"clash_api": {
"external_controller": ":9099",
"external_ui_download_url": "https://raw.githubusercontent.com/Qyue66/dns-config/main/metacubexd.zip",
"external_ui_download_detour": "proxy",
"external_ui": "ui"
}
}
}