Shell

by 神秘人 at 2022-11-01

Shell

在 Surge 官网根据你的服务器获取独立服务端二进制文件: https://manual.nssurge.com/others/snell.html

此处以debian linux-amd64 为例:

如果系统没有预装可能需要先下载安装 wget 及 unzip

APT

apt-get update&&apt-get upgrade

apt install sudo

apt install  vim 

sudo apt update && sudo apt install wget unzip

下载 Snell Server

wget https://dl.nssurge.com/snell/snell-server-v4.0.0-linux-amd64.zip

解压 Snell Server 到指定目录

sudo unzip snell-server-v4.0.0-linux-amd64.zip -d /usr/local/bin

然后编写配置文件:

可以使用 Snell 的 wizard 生成一个配置文件

sudo snell-server --wizard -c /etc/snell-server.conf

或者自己编写一个

sudo vim /etc/snell-server.conf

[snell-server]
listen = 0.0.0.0:11807
psk = AijHCeos15IvqDZTb1cJMX5GcgZzIVE
ipv6 = false

listen:监听地址及端口;

psk:密钥;

ipv6:如果需要 IPv6 支持将值为 – true;

obfs:off 为关闭混淆,或使用流量混淆 http;

然后配置 Systemd 服务文件:

sudo vim /lib/systemd/system/snell.service

[Unit]
Description=Snell Proxy Service
After=network.target

[Service]
Type=simple
User=nobody
Group=nogroup
LimitNOFILE=32768
ExecStart=/usr/local/bin/snell-server -c /etc/snell-server.conf
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=snell-server

[Install]
WantedBy=multi-user.target

在一些 Linux 发行版 (CentOS7) 中并无 nogroup 群组,但可以尝试修改成 Group=nobody 解决或注释 Group; 如果需要使用特权端口,可以在 [Service] 增加一条:AmbientCapabilities=CAP_NET_BIND_SERVICE 以解决权限不足不能绑定的问题;

然后使用命令:

重载服务

sudo systemctl daemon-reload

开机运行 Snell

sudo systemctl enable snell

开启 Snell

sudo systemctl start snell

关闭 Snell

sudo systemctl stop snell

查看 Snell 状态

sudo systemctl status snell

对于 Snell v3 可以尝试增加内核缓冲区大小可以显著提高 UDP 性能:

sudo sysctl -w net.core.rmem_max=26214400
sudo sysctl -w net.core.rmem_default=26214400

转自 https://divineengine.net/article/deploying-a-snell-server/