book
归档: GUIDE 
flag
mode_edit

技术性探讨。

安装

能找到的最方便的方法是使用以下指令从官方安装(会自动编译安装所有依赖包,并同时安装 simple-obfs plugin):

mkdir ./build-area
cd build-area
wget https://github.com/shadowsocks/shadowsocks-libev/raw/master/scripts/build_deb.sh
chmod +x build_deb.sh
./build_deb.sh all

配置

文件位于 /etc/shadowsocks-libev/config.json

{
	"server":"example.com or X.X.X.X", // 这一行可以不填
	"server_port":443, // 或 8443
	"password":"password",
	"method":"aes-128-gcm", // 或 aes-256-gcm, chacha20-ietf-poly1305, xchacha20-ietf-poly1305
	"timeout":60, // 适当更改
	"plugin":"/usr/bin/obfs-server",
	"plugin_opts":"obfs=tls;failover=<域名或 IP>" // failover 在非正常请求下会跳转到你设置的域名/IP
}

客户端请下载 obfs-local 并将文件置于客户端根目录下,填写参数如下:

选项 参数
插件程序 obfs-local.exe
插件选项 obfs=tls;obfs-host=<域名或 IP>

你请求的网址会被伪装成所设置的域名。

防火墙

执行如下指令:

ufw default allow outgoing
ufw default deny incoming
ufw allow 22 # 如果你更改了 SSH 端口,这里就填对应的 SSH 端口
ufw allow 443
ufw enable

补充可能会出现的意外情形: 重启之后,443(8443) 端口被封闭,需要使用ufw reload才会打开。查看 ufw 的 log 发现 ufw 的确 BLOCK 了对应端口的连接,但是ufw status查看显示一切正常。我也很奇怪。同时我也发现了 ufw deny 80 端口这条指令并不管用,各种探测方法都显示 80 端口打开,我也很奇怪。

查了很多教程,直接解决的方法并不管用。一种曲线救国的方式是在 /etc/rc.local 加入一行 /etc/init.d/ufw restart ,你就不用每次重启都要输入 ufw reload 了。

自动重启

键入命令:crontab -e,随便选择一种编辑器( nano 就好),然后在最下加入一行:

0 4 * * * /sbin/reboot

在每天凌晨四点主机便会重启。

nano 的保存方式是 Ctrl+O + EnterCtrl+X 即可。

引用

https://cokebar.info/archives/767

https://linux.cn/article-8087-1.html

https://stackoverflow.com/questions/41319291/ufw-blocks-most-ports-until-disabled-and-re-enabled-after-reboot

https://www.linuxquestions.org/questions/linux-networking-3/need-to-reload-ufw-after-each-restart-to-apply-rules-4175629240/