搭建vpn服务

##

Shadowsocks因为没有自带伪装,容易被墙,所以我们们使用ShadowsocksR来搭建自己的vpn,ShadowsocksR搭建过程中会自动做好伪装

搭建流程

1、下载shadowsocks-all.sh脚本

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

可能会报错找不到wget,需要安装wget

CentOS:yum -y install wget
Ubuntu/Debian:apt-get -y install wget

2、更改权限

chmod +x shadowsocks-all.sh

3、开始安装

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

4、选择参数

1、选择Shadowsocks版本,我们这里使用ShadowsocksR

[root@vm561080 ~]# ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log
Which Shadowsocks server you'd select:
1) Shadowsocks-Python
2) ShadowsocksR
3) Shadowsocks-Go
4) Shadowsocks-libev
Please enter a number (Default Shadowsocks-Python):2

You choose = ShadowsocksR

2、设置vpn的连接密码

Please enter password for ShadowsocksR
(Default password: teddysun.com): muyun******

password = muyun******

3、选择端口,可以选择一个自己喜欢的数字,也可以直接回车,会有一个默认端口,这个无所谓的,有的设备会有防火墙的问题,去控制中心把选择的端口加入安全组就可以了

Please enter a port for ShadowsocksR [1-65535]
(Default port: 9501):

port = 9501

我这边是专用来做vpn的服务器,就不费事了,直接把Linux的防火墙关掉!!!

systemctl stop firewalld.service  #关闭防火墙
systemctl disable firewalld.service  #关闭开机自启

4、选择加密方式,我这里选择的aes-256-cfb,也建议选择这个,之前使用的过程中好像安卓设备有些加密方式不支持,aes-256-cfb在win,mac,安卓,ios设备上都有很好的支持

Please select stream cipher for ShadowsocksR:
1) none
2) aes-256-cfb
3) aes-192-cfb
4) aes-128-cfb
5) aes-256-cfb8
6) aes-192-cfb8
7) aes-128-cfb8
8) aes-256-ctr
9) aes-192-ctr
10) aes-128-ctr
11) chacha20-ietf
12) chacha20
13) salsa20
14) xchacha20
15) xsalsa20
16) rc4-md5
Which cipher you'd select(Default: aes-256-cfb):2

cipher = aes-256-cfb

5、选择协议,建议选择auth_aes128_md5之后的几种,前面的不选,我这里就选择的auth_aes128_md5

Please select protocol for ShadowsocksR:
1) origin
2) verify_deflate
3) auth_sha1_v4
4) auth_sha1_v4_compatible
5) auth_aes128_md5
6) auth_aes128_sha1
7) auth_chain_a
8) auth_chain_b
9) auth_chain_c
10) auth_chain_d
11) auth_chain_e
12) auth_chain_f
Which protocol you'd select(Default: origin):5

protocol = auth_aes128_md5

6、选择混淆方式,一直都是用的2,其它的没用过,不知道会发生什么,事实上这个混淆我也从来没用过

Please select obfs for ShadowsocksR:
1) plain
2) http_simple
3) http_simple_compatible
4) http_post
5) http_post_compatible
6) tls1.2_ticket_auth
7) tls1.2_ticket_auth_compatible
8) tls1.2_ticket_fastauth
9) tls1.2_ticket_fastauth_compatible
Which obfs you'd select(Default: plain):2

obfs = http_simple

7、开始安装,按任意键开始安装

Press any key to start...or Press Ctrl+C to cancel

安装完成后,提示如下:

Starting ShadowsocksR success

Congratulations, ShadowsocksR server install completed!
Your Server IP        :  **:*:**:**
Your Server Port      :  ****
Your Password         :  muyun******
Your Protocol         :  auth_aes128_md5 
Your obfs             :  http_simple 
Your Encryption Method:  aes-256-cfb 

Your QR Code: (For ShadowsocksR Windows, Android clients only)
 ssr://NDUuODkuMjI4LjE0OTo5NTAxOmF1dGhfYWVzMTI4X21*********************************************************= 
Your QR Code has been saved as a PNG file path:
 /root/shadowsocks_r_qr.png 

Welcome to visit: https://teddysun.com/486.html
Enjoy it!

常用命令

启动:

/etc/init.d/shadowsocks-r start

退出:

/etc/init.d/shadowsocks-r stop

重启:

/etc/init.d/shadowsocks-r restart

查看状态:

/etc/init.d/shadowsocks-r status

卸载:

./shadowsocks-all.sh uninstall

报错处理

如果在安装时候出现内存不足导致yum疯狂被杀,请查看这篇文章:Linux设置swap