1、安装python
apt-get update apt-get python
2、安装setuptools
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz tar zxvf setuptools-0.6c11.tar.gz cd setuptools-0.6c11 python setup.py build python setup.py install
若不安装,在安装pip时会报错:
ImportError: No module named setuptools 解决方案
3、pip安装
pip下载
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
pip解压并安装
tar -xzvf pip-1.5.4.tar.gz cd pip-1.5.4 python setup.py install
4、shadowsocks安装
pip install shadowsocks
5、shadowsocks配置
vi /etc/shadowsocks.json
{ "server": "0.0.0.0", "port_password": { "8381": "w3c_1", "8382": "w3c_2", "8383": "w3c_3", "8384": "w3c_3" }, "timeout": 300, "fast_open": true, "method": "aes-256-cfb" }
6、shadowsocks启动、停止
ssserver -c /etc/shadowsocks.json -d start[stop]
7、shadowsocks linux server优化
First of all, upgrade your Linux kernel to 3.5 or later.
Step 1, increase the maximum number of open file descriptors
To handle thousands of concurrent TCP connections, we should increase the limit of file descriptors opened.
Edit the limits.conf
vi /etc/security/limits.conf
Add these two lines
* soft nofile 51200 * hard nofile 51200
Then, before you start the shadowsocks server, set the ulimit first
ulimit -n 51200
Step 2, Tune the kernel parameters
The priciples of tuning parameters for shadowsocks are
Reuse ports and conections as soon as possible.
Enlarge the queues and buffers as large as possible.
Choose the TCP congestion algorithm for large latency and high throughput.
Here is an example /etc/sysctl.conf of our production servers:
fs.file-max = 51200 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.netdev_max_backlog = 250000 net.core.somaxconn = 4096 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 10000 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_fastopen = 3 net.ipv4.tcp_mem = 25600 51200 102400 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.ipv4.tcp_mtu_probing = 1 net.ipv4.tcp_congestion_control = hybla
Of course, remember to execute sysctl -p to reload the config at runtime.
执行sysctl -p报错:
rror: "net.bridge.bridge-nf-call-ip6tables" is an unknown key error: "net.bridge.bridge-nf-call-iptables" is an unknown key error: "net.bridge.bridge-nf-call-arptables" is an unknown key error: permission denied on key 'net.ipv4.tcp_max_syn_backlog' error: permission denied on key 'net.core.netdev_max_backlog' error: permission denied on key 'net.core.wmem_default' error: permission denied on key 'net.core.rmem_default' error: permission denied on key 'net.core.rmem_max' error: permission denied on key 'net.core.wmem_max' error: permission denied on key 'net.ipv4.tcp_timestamps' error: permission denied on key 'net.ipv4.tcp_synack_retries' error: permission denied on key 'net.ipv4.tcp_syn_retries' error: permission denied on key 'net.ipv4.tcp_tw_recycle' error: permission denied on key 'net.ipv4.tcp_tw_reuse' error: permission denied on key 'net.ipv4.tcp_mem' error: permission denied on key 'net.ipv4.tcp_max_orphans' error: permission denied on key 'net.ipv4.ip_local_port_range'
解决办法:
修复modprobe的:
rm -f /sbin/modprobe ln -s /bin/true /sbin/modprobe
修复sysctl的:
rm -f /sbin/sysctl ln -s /bin/true /sbin/sysctl
大功告成!
下载客户端,配置...一切OK.
相关链接:
官方wiki https://github.com/shadowsocks/shadowsocks/wiki
浅析PAC,教你动手修改你的PAC文件及user-rule文件实现自动代理 http://www.tuicool.com/articles/V77jyu
W3c0.com 提供的内容仅用于培训。我们不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。W3c0 简体中文版的所有内容仅供测试,对任何法律问题及风险不承担任何责任。 当使用本站时,代表您已接受了本站的使用条款和隐私条款。版权所有,保留一切权利。 鲁ICP备15022115号