从此开始学会上网

版权声明:QQ:1009002494 https://blog.csdn.net/Doudou_Mylove/article/details/83215252

 

CentOS 下搭建 shadowsocks

一键脚本安装:

https://blog.csdn.net/langhong8/article/details/56009497/

 

http://ping.pe  

PingPe 是一个非常强大的免费站长工具,从全世界30 个节点检测网站Ping时间、MTR 和封包传输速度,站长们只要输入查询的IP或域名就能从全世界30个测试点来测试封包的传输时间、经过节点和掉包率等资讯也能测试网站能不能从中国大陆正常解析连线

以上说明国外这台服务器没有被封.

 

开始安装

cd /tmp

wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev.sh

chmod +x shadowsocks-libev.sh

yum -y install wget

./shadowsocks-libev.sh 2>&1 | tee shadowsocks-libev.log

设置密码:默认 teddysun.com

http://upload-images.jianshu.io/upload_images/1271031-3f08c94d70f8ba72.jpg-mark?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240

设置端口:默认 8989

http://upload-images.jianshu.io/upload_images/1271031-bdb5d61e6e07321a.jpg-mark?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240

然后按任意键开始安装,接下来就是等它安装完

安装完之后会看到这个界面

 

Congratulations, shadowsocks-libev install completed!

Your Server IP:your_server_ip

Your Server Port:your_server_port

Your Password:your_password

Your Local IP:127.0.0.1

Your Local Port:1080

Your Encryption Method:aes-256-cfb

 

Welcome to visit:https://teddysun.com/357.html

Enjoy it!

 

 

查看是否已经安装成功

ps -ef | grep ss-server | grep -v ps | grep -v grep

 

卸载命令

cd /tmp  # 进入 shadowsocks-libev.sh 所在目录

./shadowsocks-libev.sh uninstall

 

其他命令

启动:/etc/init.d/shadowsocks start

停止:/etc/init.d/shadowsocks stop

重启:/etc/init.d/shadowsocks restart

状态:/etc/init.d/shadowsocks status

 

 

如果以后你需要更改 shadowsock 的配置

vi  /etc/shadowsocks-libev/config.json

支持 IPv4 IPv6

{

    "server":["[::0]","0.0.0.0"],

    "server_port":your_server_port,

    "local_address":"127.0.0.1",

    "local_port":1080,

    "password":"your_password",

    "timeout":600,

    "method":"aes-256-cfb"

}

 

 

实际配置:

单端口:

 {

 "server":"0.0.0.0",            // 服务器IP,直接用0.0.0.0也可

 "server_port":8888,            // 端口*

 "local_address": "127.0.0.1",  // 本地地址,可省略

 "local_port":1080,             // 本地端口,可省略

 "password":"password",         // 密码*

 "timeout":300,                 // 超时时间,可省略

 "method":"aes-256-cfb",        // 加密策略,有多重策略,具体自查

}

多用户配置(一定要一个设备一个用户,这个坑我一个礼拜):

{

    "server":"0.0.0.0",

    "local_address":"127.0.0.1",

    "local_port":1080,

    "port_password":{           // 每个端口对应一个密码

        "1111":"password1",

        "1112":"password2",

        "1113":"password3"

    },

    "timeout":300,

    "method":"aes-256-cfb",

    "fast_open":false

}

 

如果想增加开启自动启动,执行:echo " nohup sslocal -c /etc/shadowsocks.json /dev/null 2>&1 &" /etc/rc.local

 

 

客户端安装

shadowsocks下载链接

https://shadowsocks.org/en/download/clients.html

win:

https://github.com/shadowsocks/shadowsocks-windows/releases

mac

https://github.com/shadowsocks/ShadowsocksX-NG/releases

Linux:

https://github.com/shadowsocks/shadowsocks-qt5/wiki/Installation

 

 

启动脚本

#! /bin/bash

# author lijunmin

# time 2018-04-14

 

#set -x

while true

do

#pkill ss-server

count=`ps -ef |grep ss-server |grep -v "grep"`

if (( $? != 0 ));then

    #/usr/bin/nohup /usr/local/sbin/openvpn --config /etc/openvpn/server.conf &

    /etc/init.d/shadowsocks start &

fi

sleep 30

#跳出第二次循坏

break 2

done

 

 

定时任务

crontab -e

*/1 * * * *  /bin/bash /root/shadow.sh > /dev/null 2>&1 &

 

 

dockcer

下面这个镜像是朋友做好的.

yum install -y docker-io

/etc/init.d/docker start

docker load < ss-alpine.tar

docker images

docker run  --name ss --restart=always -p 3443:3443  -d 89.208.243.231:5000/ss-alpine -s 0.0.0.0 -p 3443 -k Benngcc0223 -m aes-256-cfb

docker ps

 

如果不用docker就/etc/init.d/docker stop先停掉

然后把自己的程序起来:

/etc/init.d/shadowsocks start

如果还用docker就/etc/init.d/docker start

再docker start ID就起來了

 

 

 

安装Privoxy(这个还未测试)

上述安好了shadowsocks,但它是socks5代理,我门在shell里执行的命令,发起的网络请求现在还不支持socks5代理,只支持http/https代理。为了我门需要安装privoxy代理,它能把电脑上所有http请求转发给shadowsocks。
访问官网http://www.privoxy.org/获得Privoxy的最新源码:privoxy-3.0.24-stable-src.tar.gz,执行tar -zxvf privoxy-3.0.24-stable-src.tar.gz解压,然后cd privoxy-3.0.24-stable进去。
安装前需要执行useradd privoxy创建一个用户privoxy,然后依次执行如下三条命令:

autoheader && autoconf

./configure

make && make install

 

 

注意:此处不要用ping命令来检测

如果不能访问,请重启机器,依次打开shadowsocksprivoxy再测试.

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

privoxy --user privoxy /usr/local/etc/privoxy/config

 

 

备注:如果不需要用代理了,记得把bash里的配置注释上,免得把流量跑完了。

 

 

安卓手机安装

 

手机客户端下载链接

https://github.com/shadowsocks/shadowsocks-android/releases

 

非脚本安装

环境安装与更新

操作系统:centos7

yum -y install epel-release

yum update

yum install python-setuptools && easy_install pip

pip install shadowsocks

 

2.文件配置

接下来需要编辑/etc/shadowsocks.json文件,这个文件默认没有:

vi /etc/shadowsocks.json

{

"server":"0.0.0.0",

"port_password":{

"7890":"cjk1",

"7891":"cjk2"

},

"timeout":300,

"method":"aes-256-cfb",

"fast_open":false,

"workers": 1

}

 

接下来需要编辑一下/etc/supervisord.conf文件,命令如下:

vi /etc/supervisord.conf把下面的内容粘贴到文件尾部的空行处,然后保存:

[program:shadowsocks]

command=ssserver -c /etc/shadowsocks.json

autostart=true

autorestart=true

user=root

log_stderr=true

logfile=/var/log/shadowsocks.log

 

接下来需要编辑一下/etc/rc.local文件,请执行以下命令:

vi /etc/rc.local    #把以下内容粘贴到文件中部的空白处,然后保存

service supervisord start

最后执行reboot命令,重启服务器。

 

 

如何在阿里云ECS(香港)Centos7服务器搭建shadowsocks

 

准备环境

服务器: centos7 (我使用的是centos7.2 64位), 假定服务器公网IP是: 47.51.152.123
客户端: window/Mac系统 (我使用的是Mac os),ss(shadowsocks)或ssr客户端软件,推荐使用ssr

1 安装Shadowsocks服务端

连接服务器

首先 ssh连接服务器,在终端输入ssh [email protected] 。root(是用户名), 接着输入密码登录服务器
登录成功后执行以下命令安装

1.1 更新包

yum update

1.2 安装pie

yum install python-setuptools && easy_install pip

1.3 安装Shadowsocks

pip install shadowsocks

2 配置Shadowsocks

此文件默认不存在,需要创建:

vim /etc/shadowsocks.json

编辑文件为以下内容:

{

"server":"47.51.152.123",

"server_port":41491,

"password":"yourpassword",

"timeout":300,

"method":"aes-256-cfb",

"fast_open":false,

"workers": 1

}

以下是内容的说明:

{

"server":"服务器 IP地址 (IPv4/IPv6)",

"server_port":"服务器监听的端口,注意不要设为使用中的端口",

"password":"设置连接ss的密码",

"timeout":"超时的时间",

"method":"加密的方式 可选择 “aes-256-cfb”, “rc4-md5”等等",

"fast_open":"true 或 false。如果你的服务器 Linux 内核在3.7+,可以开启 fast_open 以降低延迟",

"workers": "workers数量,默认为 1"

}

如何要配置多个用户分享给朋友用:

{

"server":"47.51.152.123",

"port_password":{

     "8381":"pass1",

     "8382":"pass2",

     "8383":"pass3",

     "8384":"pass4"

     },

"timeout":60,

"method":"aes-256-cfb",

"fast_open":false,

"workers":1

}

3 启动Shadowsocks

ssserver -c /etc/shadowsocks.json -d start

配置文件修改后重启

ssserver -c /etc/shadowsocks.json -d restart

启动成功后如下

4 开机自启SS

修改下面文件

vim  /etc/rc.d/rc.local

加入下面内容 /usr/bin/ssserver -c /etc/shadowsocks.json -d start
保存并推出 vim, CentOS 7正打算抛弃/etc/rc.d/rc.local,重启前需要运行以下命令获得权限,否则rc.local不会执行

chmod +x /etc/rc.d/rc.local

5 使用SS/SSR客户端科学上网

shadowsocks 和 shadowsocksr客户端软件下载与安装自行搞好。

输入ssr客户端信息

可以测速看延迟,如本文的第一张图,数值越小就是越快吧,failed表示连接失败。
window系统客户端配置基本上一样,就不另外截图了
现在你可以打开www.google.com进行科学上网了

6 【注意】阿里服务器注意事项

6.1 更改 server ip,换成私有ip

如果服务器是专有网络,/etc/shadowsocks.json 中的server ip 是私有ip,而非公网ip。如下图

6.2 开放端口

/etc/shadowsocks.json 中开放的端口需要 运行命令开放

iptables -A INPUT -p tcp --dport 41491 -j ACCEPT

6.3 添加安全组规则

服务器实例的安全组规则需要增加 自定义 TCP 在 相关端口(41491) 的访问 ,(允许所有ip访问,设置为0.0.0.0/0),如下图:

最后用telnet 47.51.152.123 41491验证, 只有telnet能访问端口了,才能正常使用shadowsocks!

 

 

 

 

安全组与iptables

 

腾讯云Iptbles不需要配置,只要把后台安全组相应的端口打开就OK.

 

 

VPS实例

环境:CentOs7.5

服务器:VPS

 

开始搭建:

 

1.1 更新包

yum update

1.2 安装pie

yum install python-setuptools && easy_install pip

1.3 安装Shadowsocks

pip install shadowsocks

2 配置Shadowsocks

此文件默认不存在,需要创建:

vim /etc/shadowsocks.json

编辑文件为以下内容:

{

"server":"0.0.0.0",

"port_password":{

     "8381":"pass1",

     "8383":"pass3"

     },

"timeout":60,

"method":"aes-256-cfb",

"fast_open":false,

"workers":1

}

 

 

 

ShadowsocksSS)客户端设置教程-苹果电脑macOS

点击这里获取Shadowsocks

系统要求

在安装之前,请始终确保您的系统满足最低系统要求。

您需要具备 MacOS 10.11 或更高版本才能运行 ShadowsocksX-NG。如果您的操作系统版本较旧, 则请先升级到 MacOS 10.11 或更高版本。

下载安装 ShadowsocksX-NG

按照下面的说明在 MacOS 上下载并安装 ShadowsocksX-NG

1. 下载客户端

访问 Shadowsocks 下载页面 点击最新版本的 ShadowsocksX-NG.x.x.x.zip 进行下载 (x.x.x为版本号)

2. 安装客户端

双击解压 ShadowsocksX-NG.x.x.x.zip , 获取 ShadowsocksX-NG。并将将 “ShadowsocksX-NG” 拖移到  “应用程序

https://www.freeluffy.com/wp-content/uploads/2018/09/mac-shadowsocksDrag.gif

应用程序中双击 “ShadowsocksX-NG” > 选择打开

https://www.freeluffy.com/wp-content/uploads/2018/09/mac-NGprompt.png

配置 Shadowsocks 账号

在您的电脑上, 执行下列操作:

  • 点击屏幕顶部菜单栏的  > “服务器” > “服务器设置

  • 点击窗口上的 “+” > 填写地址” > 填写服务端口” > 选择加密方法
  • 填写密码“ > 填写备注为可选项。
  • 点击打开Shadowsocks”
  • 当显示 Shadowsocks: On时,表示系统代理已经打开。

配置系统代理模式

  • 点击屏幕右上方菜单栏的   > “PAC自动模式

PAC模式-表示可以实现自动代理, 意思就是本来可以访问的网站不会经过代理。全局模式-表示计算机内大多数流量都会经过代理。

 

 

猜你喜欢

转载自blog.csdn.net/Doudou_Mylove/article/details/83215252
今日推荐