在 Arch Linux 上安装与配置 shadowsocks-rust
🧩 一、简介
shadowsocks-rust 是用 Rust 实现的高性能、跨平台的 shadowsocks 客户端/服务器,性能和安全性都比旧版 Python/Go 实现更优。
GitHub 项目地址:https://github.com/shadowsocks/shadowsocks-rust
🧱 二、安装
Arch 官方仓库已经提供:
sudo pacman -S shadowsocks-rust
安装后会得到几个主要命令:
ssserver— 服务端sslocal— 客户端ssurl— URL 工具(可生成/解析 ss:// 链接)
⚙️ 三、客户端配置(用于连接代理)
创建配置文件(假设路径:~/.config/shadowsocks/config.json):
mkdir -p ~/.config/shadowsocks
nano ~/.config/shadowsocks/config.json
写入内容(示例):
{
"server": "your.server.ip",
"server_port": 8388,
"password": "your_password",
"method": "aes-256-gcm",
"local_address": "127.0.0.1",
"local_port": 1080
}
说明
server:你的远程 Shadowsocks 服务器 IPserver_port:端口method:加密算法(推荐aes-256-gcm或chacha20-ietf-poly1305)local_port:本地 socks5 代理端口,默认 1080
🚀 四、运行客户端
sslocal -c ~/.config/shadowsocks/config.json -v
成功后,本地会开启一个 socks5://127.0.0.1:1080 代理端口。
🧰 五、系统代理设置
1️⃣ 临时设置(命令行代理)
export https_proxy="socks5h://127.0.0.1:1080"
export http_proxy="socks5h://127.0.0.1:1080"
然后测试:
curl -I https://www.google.com
如果返回 200 OK,说明代理工作正常。
2️⃣ 桌面环境代理
如果你使用 GNOME / KDE,可以在「网络 → 代理」里设置:
SOCKS 主机:127.0.0.1
端口:1080
🔁 六、开机自启(systemd)
创建 systemd 用户服务:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/sslocal.service
内容如下:
[Unit]
Description=Shadowsocks-Rust Client
After=network.target
[Service]
ExecStart=/usr/bin/sslocal -c /home/%u/.config/shadowsocks/config.json
Restart=on-failure
[Install]
WantedBy=default.target
启用并启动:
systemctl --user enable --now sslocal.service
查看状态:
systemctl --user status sslocal
🧱 七、服务端配置(如果你想自己架设)
在服务器端安装:
sudo pacman -S shadowsocks-rust
配置 /etc/shadowsocks-rust/server.json:
{
"server": "0.0.0.0",
"server_port": 8388,
"password": "your_password",
"method": "chacha20-ietf-poly1305",
"mode": "tcp_and_udp"
}
运行:
sudo ssserver -c /etc/shadowsocks-rust/server.json -v
或设置 systemd 服务:
sudo systemctl enable --now shadowsocks-rust@server.service
🧠 八、附加工具(可选)
- Privoxy — 将 SOCKS5 转为 HTTP 代理
- v2ray-plugin / obfs-plugin — 混淆或 TLS 加密插件
- Clash / Qv2ray / electron-ssr — 图形界面管理
🧪 九、验证流量是否走代理
curl ipinfo.io
如果显示的 IP 是你的远程服务器,就表示代理成功。
配置多个IP
在 shadowsocks-rust 的客户端配置文件 config.json 中,如果你希望 同时配置多个服务器(多 IP),可以使用数组形式的配置结构。
✅ 正确示例:配置多个服务器
{
"configs": [
{
"server": "1.2.3.4",
"server_port": 8388,
"password": "password1",
"method": "aes-256-gcm"
},
{
"server": "5.6.7.8",
"server_port": 8389,
"password": "password2",
"method": "chacha20-ietf-poly1305"
}
],
"local_address": "127.0.0.1",
"local_port": 1080,
"mode": "tcp_and_udp"
}
📘 说明:
configs:数组形式,可定义多个远程服务器。- 每个对象代表一个远程节点。
local_address与local_port:客户端监听地址与端口(统一入口)。mode:可以指定"tcp_and_udp"让 UDP 一并代理。
🚀 启动方式
sslocal -c ~/.config/shadowsocks/config.json -v
客户端会在多个服务器之间 自动选择可用节点(默认是随机或轮询),也可以通过 --server 参数强制选择:
sslocal -c ~/.config/shadowsocks/config.json --server 5.6.7.8
🌐 进阶:多端口 + 负载均衡(可选)
如果希望实现负载均衡或手动指定节点策略,可以使用:
{
"balancing": {
"strategy": "random" // 可选: "random", "roundrobin", "consistent_hash"
},
"configs": [
...
],
"local_port": 1080
}