打开官方仓库releases页面
https://github.com/SagerNet/sing-box/releases
下载符合你服务器架构的压缩包到/opt
解压
tar -zxf sing-box-
S
I
N
G
B
O
X
V
E
R
S
I
O
N
−
l
i
n
u
x
−
SING_BOX_VERSION-linux-
SINGBOXVERSION−linux−ARCH.tar.gz
将可执行文件移动到/usr/bin目录下
mv sing-box-
S
I
N
G
B
O
X
V
E
R
S
I
O
N
−
l
i
n
u
x
−
SING_BOX_VERSION-linux-
SINGBOXVERSION−linux−ARCH/sing-box /usr/bin
创建配置目录以及基本配置文件config.json
mkdir /etc/sing-box
echo “{}” > /etc/sing-box/config.json
配置系统服务文件
cat <<EOF> /etc/systemd/system/sing-box.service [Unit] Description=sing-box service Documentation=https://sing-box.sagernet.org After=network.target nss-lookup.target
[Service] CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH ExecStart=/usr/bin/sing-box -D /var/lib/sing-box -C /etc/sing-box run ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartSec=10s LimitNOFILE=infinity
[Install] WantedBy=multi-user.target EOF
刷新服务配置
systemctl daemon-reload
自启+启动
sudo systemctl enable sing-box.service --now
重启
sudo systemctl restart sing-box.service
sudo systemctl status sing-box.service
查看有无在端口启动
netstat -natp | grep 5353(your port)
config.json如下:
{ "inbounds": [ { "type": "mixed", "tag": "mixed-in", "listen": "::", "listen_port": 5353, "tcp_fast_open": true, "udp_fragment": true, "sniff": true, "set_system_proxy": false } ], "outbounds": [ { "type": "shadowsocks", "tag": "proxy", "server": "120.232.xxx.xxx", "server_port": 8088, "method": "2022-blake3-aes-128-gcm", "password": "8JCsPssfgS8tiRwiMlhARg==", "multiplex": { "enabled": true } }, { "type": "direct", "tag": "direct" }, { "type": "block", "tag": "block" }, { "type": "dns", "tag": "dns-out" } ] }