起因 作为一个开发者,不能上 google 是有多难受,吃灰的树莓派刚好派上了用场
安装 准备工具
开始动手 安装开发环境 1 sudo apt-get install git build-essential cmake -y
一般的 ubuntu 和 debian 系统都可以做到,但是我之前用的 ubuntu mate 会报错,找不到 build-essential,那么使用 aptitude 来解决依赖项
1 2 sudo apt-get install aptitude -y sudo aptitude install build-essential -y
安装依赖项
1 sudo apt-get install -y libsodium-dev libpcre3 libpcre3-dev libssl-dev
开始编译 ssr 1 2 3 4 5 6 cd git clone https://github.com/shadowsocksr-backup/shadowsocksr-libev.git cd shadowsocksr-libevsudo ./configure --prefix=/usr/local/shadowsocksR --disable-documentation sudo make -j4 sudo make install
使用 ssr 1 2 sudo mkdir /usr/local/shadowsocksR/conf sudo vi config.json
1 2 3 4 5 6 7 8 9 10 11 12 13 { "server" : "your server address here" , "server_port" : 1234 , "local_port" : 1080 , "password" : "your password here" , "timeout" : 600 , "method" : "chacha20" , "protocol" : "auth_aes128_md5" , "obfs" : "tls1.2_ticket_auth" , "obfsparam" : "" , "group" : "any you like" , "local_address" : "0.0.0.0" , }
1 2 3 4 5 6 7 8 9 10 11 /usr/local/shadowsocksR/bin/ss-local -c /usr/local/shadowsocksR/conf/config.json pi@raspberrypi:~ $ /usr/local/shadowsocksR/bin/ss-local -c /usr/local/shadowsocksR/conf/sg.json 2017-08-24 04:44:55 INFO: protocol auth_aes128_md5 2017-08-24 04:44:55 INFO: protocol_param (null) 2017-08-24 04:44:55 INFO: method chacha20 2017-08-24 04:44:55 INFO: obfs tls1.2_ticket_auth 2017-08-24 04:44:55 INFO: obfs_param (null) 2017-08-24 04:44:56 INFO: initializing ciphers... chacha20 2017-08-24 04:44:56 INFO: tcp port reuse enabled 2017-08-24 04:44:56 INFO: listening at 0.0.0.0:1080
测试
完善
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 cd curl -sL http://f.ip.cn/rt/chnroutes.txt | egrep -v '^$|^#' > chnroutes sudo apt-get -y install ipset sudo ipset -N chnroutes hash :net for i in `cat chnroutes`; do echo ipset -A chnroutes $i >> ipset.sh; done chmod +x ipset.sh && ./ipset.shsudo ipset save chnroutes > ~/chnroutes.ipset sudo ipset destroy chnroutes sudo ipset restore < ~/chnroutes.ipset sudo iptables -t nat -N shadowsocks sudo iptables -t nat -A shadowsocks -d 0.0.0.0/8 -j RETURN sudo iptables -t nat -A shadowsocks -d 10.0.0.0/8 -j RETURN sudo iptables -t nat -A shadowsocks -d 127.0.0.0/8 -j RETURN sudo iptables -t nat -A shadowsocks -d 169.254.0.0/16 -j RETURN sudo iptables -t nat -A shadowsocks -d 172.16.0.0/12 -j RETURN sudo iptables -t nat -A shadowsocks -d 192.168.0.0/16 -j RETURN sudo iptables -t nat -A shadowsocks -d 224.0.0.0/4 -j RETURN sudo iptables -t nat -A shadowsocks -d 240.0.0.0/4 -j RETURN sudo iptables -t nat -A shadowsocks -p tcp --dport 1234 -j RETURN sudo iptables -t nat -A shadowsocks -d your_server -j RETURN sudo iptables -t nat -A shadowsocks -m set --match-set chnroutes dst -j RETURN sudo iptables -t nat -A shadowsocks -p tcp -j REDIRECT --to-ports 1080 sudo iptables -t nat -A OUTPUT -p tcp -j shadowsocks sudo iptables -t nat -I PREROUTING -p tcp -j shadowsocks sudo iptables-save > ~/iptables.shadowsocks sudo iptables-restore < ~/iptables.shadowsocks