Shadowsocks

如何在Centos6.X安装shadowsocks客户端

安装epel源、安装pip包管理

yum -y install epel-release yum -y install python-pip

安装Shadowsocks客户端

pip install shadowsocks

配置Shadowsocks连接,配置文件默认不存在

mkdir /etc/shadowsocks vim /etc/shadowsocks/shadowsocks.json

# 单用户配置:
{
    "server":"x.x.x.x",  # Shadowsocks服务器地址
    "server_port":10000,  # Shadowsocks服务器端口
    "local_address": "127.0.0.1", # 本地IP
    "local_port":1080,  # 本地端口
    "password":"password", # Shadowsocks连接密码
    "timeout":300,  # 等待超时时间
    "method":"aes-256-cfb",  # 加密方式
    "fast_open": false,  # true或false。开启fast_open以降低延迟,但要求Linux内核在3.7+
    "workers": 1  #工作线程数 
}
# Shadowsocks服务端多用户配置
{
    "server":"0.0.0.0",  
    "local_address": "127.0.0.1",
    "local_port":1080,
    "port_password": {
        "10001": "passwd_1",    #端口号,密码
        "10002": "passwd_2",
        "10003": "passwd_3",
        "10004": "passwd_4"
    },
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open": false
}

初步启动验证

sslocal -c /etc/shadowsocks/shadowsocks.json
# 放后台运行:

nohup sslocal -c /etc/shadowsocks/shadowsocks.json /dev/null 2>&1 &

# 开机自启动:

echo "nohup sslocal -c /etc/shadowsocks/shadowsocks.json /dev/null 2>&1 &"  >>/etc/rc.local 

# 获取当前出口IP

curl --socks5 127.0.0.1:1080 http://httpbin.org/ip

# 返回信息看是否为 shadowsocks 服务端的IP:
{
  "origin": "x.x.x.x"       #你的Shadowsock服务器IP
}

如启动不了报错为缺少libsodium*

//if you has install libsodium by yum,you should remove it first.

wget https://github.com/jedisct1/libsodium/releases/download/1.0.10/libsodium-1.0.10.tar.gz
tar zxvf libsodium-1.0.10.tar.gz
cd libsodium-1.0.10
./configure && make && make install
echo /usr/local/lib > /etc/ld.so.conf.d/libsodium.conf
ldconfig

再启动试试 sslocal -c /etc/shadowsocks/shadowsocks.json
curl --socks5 127.0.0.1:1080 http://httpbin.org/ip

安装配置 privoxy 代理

yum -y install privoxy
service privoxy start
vim /etc/privoxy/config

listen-address 127.0.0.1:8118 # 8118 是默认端口,不用改
forward-socks5t / 127.0.0.1:1080 . #转发到本地端口,注意最后有个点

设置http、https代理

vim /etc/profile # 在最后添加如下信息

PROXY_HOST=127.0.0.1
export all_proxy=http://$PROXY_HOST:8118
export ftp_proxy=http://$PROXY_HOST:8118
export http_proxy=http://$PROXY_HOST:8118
export https_proxy=http://$PROXY_HOST:8118
export no_proxy=localhost,172.16.0.0/16,192.168.0.0/16.,127.0.0.1,10.10.0.0/16

# 重载环境变量 source /etc/profile

测试代理

elinks www.google.com
elinks www.facebook.com
elinks www.youtube.com

comments powered by Disqus