-
Notifications
You must be signed in to change notification settings - Fork 2
安装配置 shadowsocks libev
SgrAlpha edited this page Apr 11, 2020
·
2 revisions
sudo apt install shadowsocks-libev -y
其中 CONFFILE 的值不对也没关系,稍后会覆盖掉。
sudo bash -c 'cat << EOF > /etc/default/shadowsocks-libev # Defaults for shadowsocks initscript # sourced by /etc/init.d/shadowsocks-libev # installed at /etc/default/shadowsocks-libev by the maintainer scripts # Enable during startup? START=yes # Configuration file CONFFILE="/etc/shadowsocks-libev/config.json" # Extra command line arguments DAEMON_ARGS="-u -b 0.0.0.0 --reuse-port" # User and group to run the server as USER=nobody GROUP=nobody # Number of maximum file descriptors MAXFD=65535 EOF'
ss-redir的用途就是将发往某个本地端口的请求转发到服务器端,这里需要根据实际情况替换成你的服务器的配置,给你服务器起一个别名,例如hk-1,然后把下面的<name>替换成这个别名,这样方便以后区分不同用途的配置文件。另外这里的端口号1081就是ss-redir的监听端口,记住,后面会用到。
sudo bash -c 'cat << EOF > /etc/shadowsocks-libev/redir-<name>.json { "server":"<你的ss服务器ip>", "server_port":<你的ss服务器端口>, "local_port":1081, "password":"<你的ss服务接入密码>", "timeout":60, "method":"<加密方式>", "mode":"tcp_and_udp" } EOF'
sudo vi /lib/systemd/system/shadowsocks-libev-redir@.service
将内容换成如下:
# This file is part of shadowsocks-libev. # # Shadowsocks-libev is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This is a template unit file. Users may copy and rename the file into # config directories to make new service instances. See systemd.unit(5) # for details. [Unit] Description=Shadowsocks-Libev Custom Client Service Redir Mode for %I Documentation=man:ss-redir(1) After=network.target [Service] Type=simple EnvironmentFile=/etc/default/shadowsocks-libev CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE User=nobody Group=nogroup LimitNOFILE=32768 ExecStart=/usr/bin/ss-redir -c /etc/shadowsocks-libev/redir-%i.json --fast-open $DAEMON_ARGS [Install] WantedBy=multi-user.target
其中的 /etc/shadowsocks-libev/redir-%i.json 在服务启动的过程中会被替换成实际用的配置文件
sudo systemctl enable shadowsocks-libev-redir@<name>.service
注意这里的<name>就是刚刚我们提到的别名
sudo systemctl start shadowsocks-libev-redir@<name>.service sudo systemctl status shadowsocks-libev-redir@<name>.service
这里的<name>也是刚刚我们提到的别名