编译安装
snap install go --classic
git clone -b dev-next https://github.com/sagernet/sing-box
cd sing-box/cmd/sing-box
GOOS=linux GOARCH=amd64 go build -tags with_quic,with_acme -trimpath -ldflags "-s -w -buildid=" -o /usr/local/bin/ycycxz-sing-box
chmod +x /usr/local/bin/ycycxz-sing-box
mkdir -p /etc/ycycxz-sing-box
cd;ycycxz-sing-box version服务器端配置
/etc/ycycxz-sing-box/ycycxz.jsoncat <<EOF > /etc/ycycxz-sing-box/ycycxz.json
{
"inbounds": [
{
"type": "shadowtls",
"listen_port": 42324,
"version": 2,
"password": "ycycxz",
"handshake": {
"server": "tesla.com",
"server_port": 443
},
"detour": "trojan-in"
},
{
"type": "trojan",
"tag": "trojan-in",
"listen": "127.0.0.1",
"users": [
{
"password": "ycycxz"
}
]
}
]
}
EOFsystemd
cat <<EOF > /etc/systemd/system/ycycxz-sing-box.service
[Unit]
Description=ycycxz-sing-box
After=network-online.target
[Service]
LimitAS=infinity
LimitNOFILE=infinity
LimitNPROC=infinity
TasksMax=infinity
ExecStart=/usr/local/bin/ycycxz-sing-box run -c /etc/ycycxz-sing-box/ycycxz.json
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable ycycxz-sing-box启动
systemctl start ycycxz-sing-box
#systemctl status ycycxz-sing-box客户端
{
"inbounds": [
{
"type": "mixed",
"listen": "127.0.0.1",
"listen_port": 1080
}
],
"outbounds": [
{
"type": "trojan",
"password": "ycycxz",
"detour": "shadowtls-out"
},
{
"type": "shadowtls",
"tag": "shadowtls-out",
"server": "4.2.3.24",
"server_port": 42324,
"version": 2,
"password": "ycycxz",
"tls": {
"enabled": true,
"server_name": "tesla.com"
}
}
]
}卸载
systemctl stop ycycxz-sing-box
rm /etc/systemd/system/ycycxz-sing-box.service
systemctl daemon-reload
rm -rf /etc/ycycxz-sing-box
rm -f /usr/local/bin/ycycxz-sing-box视频教程
How was it? Did this tutorial work? Yes No