因為要去大陸出差,需要一個翻牆服務,所以寫了這篇來紀錄安裝過程
1. 安裝好 Ubuntu Server 18.04.1 LTS
2. 加入 Universe repository
sudo add-apt-repository universe
3. 先把更新跑一遍(強迫症)
sudo apt -y update sudo apt -y upgrade
4. 啟用 BBR 加速 & TCP fast open
sudo vim /etc/sysctl.conf 在最後加入這三行
net.core.default_qdisc=fq net.ipv4.tcp_congestion_control=bbr net.ipv4.tcp_fastopen=3
套用設定
sudo sysctl -p
檢查是否都有 bbr & 啟用 TCP fast open
sysctl net.ipv4.tcp_available_congestion_control sysctl net.ipv4.tcp_congestion_control lsmod | grep bbr sysctl net.ipv4.tcp_fastopen
5. 安裝 Shadowsocks
sudo apt -y install shadowsocks
(如果只有一個使用者可以改選擇安裝 shadowsocks-libev 比較輕量)
6. 設置 shadowsocks config ( /etc/shadowsocks/config.json or /etc/shadowsocks-libev/config.json )
註: TCP fast open 選擇啟用(有網友說開啟 tcp fast open 容易被牆)
{ "server":"0.0.0.0", "server_port":8388, "local_address": "127.0.0.1", "local_port":1080, "password":"mypassword", "timeout":300, "method":"chacha20-ietf-poly1305", "fast_open": false, "workers": 1, "prefer_ipv6": false }
建議使用 AEAD 算法的加密協議:
- AES-128-GCM (aes-128-gcm)
- AES-192-GCM (aes-192-gcm)
- AES-256-GCM (aes-256-gcm)
- ChaCha20-IETF-Poly1305 (chacha20-ietf-poly1305)
- XChaCha20-IETF-Poly1305 (xchacha20-ietf-poly1305)
7. 測試服務 ssserver -c /etc/shadowsocks/config.json
8. 安裝成系統自啟動服務
方法一:使用 systemctl 以服務方式啟動
1. 測試
sudo systemctl start shadowsocks
sudo systemctl status shadowsocks
2. 啟用服務
sudo systemctl enable shadowsocks
方法二:使用 init.d 以 script 方式啟動
在 /etc/init.d 下新增一個 shadowsocks
sudo vim /etc/init.d/shadowsocks
#!/bin/bash
/usr/local/bin/ssserver -c /etc/shadowsocks/config.json
註:請用 which ssserver 尋找 ssserver 實際路徑取代 /usr/local/bin/ssserver (可能會不同)
9. 執行 sudo reboot 確認重啟後 shadowsocks 正常啟動!
其他說明:
1. Shadowsocks 另外可以搭配 KCPtun 加速連線 (經測試透過 KCPtun 也容易被牆)
sudo apt install python-pip pip install setuptools==33.1.1 wget https://bootstrap.pypa.io/ez_setup.py sudo python ez_setup.py wget https://github.com/kuoruan/shell-scripts/raw/master/kcptun/kcptun.sh && chmod a+x ./kcptun.sh && sudo ./kcptun.sh
2. 建議透過 ubuntu 的 ufw 設定防火牆提高安全性
# 允許 Shadowsocks tcp&udp port (依照需求修改) sudo ufw allow in 8388 # 允許 SSH 登入管理 (看實際需求增加) sudo ufw allow in 22/tcp # 拒絕從遠端連進來的電腦存取內網 sudo ufw deny out to 192.168.1.0/24 # 允許從 Gateway 出去(搭配上一條使用,不然無法上網) sudo ufw allow outto 192.168.1.1
用戶端:
Windows: https://github.com/shadowsocks/shadowsocks-windows/releases
MacOS: https://github.com/shadowsocks/ShadowsocksX-NG/releases
Linux: https://github.com/shadowsocks/shadowsocks-qt5/wiki/Installation
Android:
shadowsocks: Github or Play Store
iOS:
ShadowRocket
Quantumult
Outline
Potatso Lite
參考:
https://www.jianshu.com/p/47187e7b528c
https://zinc357.github.io/2017/03/01/%E4%BD%BF%E7%94%A8kcptun%E5%8A%A0%E9%80%9Fshadowsocks/
https://github.com/shadowsocks/kcptun-android
留言列表