DigitalOcean 科学上网配置

Shadowsocks

服务器端

安装

1
2
apt-get install python-pip
pip install shadowsocks

配置

Create a config file /etc/shadowsocks.json

1
2
3
4
5
6
7
8
9
10
{
"server":"server_ip",
"server_port":433,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"mypassword",
"timeout":300,
"method":"rc4-md5",
"fast_open": true
}

启用 shasa20 加密

1
2
3
4
5
6
7
8
apt-get install python-m2crypto

wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.1.tar.gz
tar zxvf libsodium-1.0.1.tar.gz
cd libsodium-1.0.1
./configure
make && make check
make install

It is said that we need to fix association, though I have no idea what it means.

1
2
3
# 修复关联
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

开启与关闭

1
2
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop

优化

事实上,由于国内网络连 DO 主机的速度,根本谈不上优化。。。

解决 DO CSS 被墙

/etc/hosts 添加

1
199.27.79.249 cloud-cdn-digitalocean-com.global.ssl.fastly.net

客户端

  • 下载后端

后端有好几个,选了 shadowsocks-libev

1
2
3
sudo apt-get install build-essential autoconf libtool libssl-dev
./configure && make
sudo make install
  • 下载前端
1
2
3
sudo add-apt-repository ppa:hzwhuang/ss-qt5
sudo apt-get update
sudo apt-get install shadowsocks-qt5

PPTP

1
2
apt-get update
apt-get install pptpd

注销 /etc/pptpd.conf 的下面两行以分配 IP

1
2
localip 192.168.0.1 
remoteip 192.168.0.234-238,192.168.0.245

编辑 /etc/ppp/chap-secrets 添加登录账户(别忘了最后的 * 号)

1
[username] pptpd [password] *

编辑 /etc/ppp/pptpd-options 设置 DNS 解析

1
2
3
4
5
6
# OpenDNS
ms-dns 208.67.222.222
ms-dns 208.67.220.220
# google DNS
ms-dns 8.8.8.8
ms-dns 8.8.4.4

配置 /etc/sysctl.conf 以允许转发

1
net.ipv4.ip_forward=1

重启服务

1
2
sysctl -p
/etc/init.d/pptpd restart

配置防火墙 iptables

1
/sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

保存并配置重启后的 iptables

1
iptables-save > /etc/iptables-rules

修改 /etc/network/interfaces,在 eth0 下添加:

1
pre-up iptables-restore < /etc/iptables-rules

最后清理 nash-hotplug,修改 /etc/rc.local 文件,在 exit 0 之前添加此命令: pkill -9 nash

dnsmasq

Dnsmasq 用于引导对 DNS 服务器的访问,比如说访问国内地址,就去查 114 DNS 服务器,如果访问国外地址,就去查 8.8.8.8 服务器。