你需要一个机器
推荐腾讯云,使用centos7.4,带宽有多少米给我上多少,没钱就去买搬瓦工把,便宜活好。
配置防火墙
- 放开防火墙端口firewall-cmd –zone=public –add-port=443/tcp –permanent
- 同样放开ssh的端口
- 重启防火强firewall-cmd –reload
关闭ssh的密码验证,防止暴力破解
- 创建密钥
ssh-keygen -t rsa -b 2048 -f ./id_rsa - 推送公钥
ssh-copy-id -p xxxx root@xxx.xxx.xx.xx - 修改sshd配置文件
/etc/ssh/sshd_config将PasswordAuthentication修改成no
关闭icmp
一定程度上在互联网上隐藏自己防止一些批量扫描软件探测主机
操作是修改/etc/sysct.conf增加如下内容1
net.ipv4.icmp_echo_ignore_all=1
临时要打开icmp的话就执行如下命令:1
sysctl net.ipv4.icmp_echo_ignore_all=0
给你翅膀
git clone https://github.com/shadowsocks/shadowsocks-libev- 安装EPEL软件包
yum install -y epel-release - 更新缓存
yum-config-manager --enable epel - 安装依赖库
yum install -y gettext gcc autoconf libtool automake make asciidoc xmlto c-ares-devel libev-devel libpcre3 libsodium libmbedtls mbedtls-devel libsodium libsodium-devel libsodium-static pcre pcre-devel cd shadowsocks-libevgit reset --hard origin/mastergit pullgit submodule init && git submodule updateldconfig./autogen.sh && ./configure && makemake install- 这里会出55-server,这里不用使用python来安装,因为他使用不了plugin obfs
编辑配置文件 /etc/55.conf
1
2
3
4
5
6
7
8{
"server":"0.0.0.0",
"server_port":8388,
"password":"*********",
"local_port":1080,
"timeout":600,
"method":"aes-256-cfb"
}ss-server -c /etc/55.conf- 下载一个客户端
windows
shadowsocks-windows
mac
ios
使用PotatsoLite,用的比较方便,支持功能也够
android
- 然后飞起来把
可靠性?
机器重启了?服务crash了?要坠机了?
用supervisord提一把哈
前提是用py2.7哈,高级没有这玩意,或者自己手写shell,参考我的别的文章
yum install -y python2-pippip install supervisorecho_supervisord_conf > /etc/supervisord.conf- 配置/etc/supervisord.conf
追加如下内容
1
2
3
4
5
6
7[program:saybyetogwf]
command=ss-server -c /etc/55.conf
autostart=true
autorestart=true
user=root
log_stderr=true
logfile=/var/log/55.log编辑
/usr/lib/systemd/system/supervisord.service内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
ExecReload=/usr/bin/supervisorctl reload
ExecStop=/usr/bin/supervisorctl shutdown
User=root
[Install]
WantedBy=multi-user.targetsystemctl enable supervisord.servicesystemctl start supervisord.service
安心了~
装上新引擎
what? 不够快?带宽买不起?你需要带上
安装bbr,bbr,全名Google BBR就是谷歌公司提出的一个开源TCP拥塞控制的算法。在最新的linux 4.9及以上的内核版本中已被采用,任何低于4.9的linux内核版本都需要升级到4.9及以上才能使用,故若VPS本身内核版本较低的话,只有KVM架构的VPS才能使用本教程升级内核并使用,openvz的VPS用户若内核版本较低则无法使用!
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpmyum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel- 通过
uname -a检核内核版本是否升级带上elrepo的字眼 - 检查模块是否启动
lsmod | grep bbr如果返回tcp_bbr表示已经启动了 修改内核参数或者直接修改文件/etc/sysctl.conf
1
2sysctl net.ipv4.tcp_congestion_control = bbr
sysctl net.core.default_qdisc=fq通过
sysctl -p检查是否存在配置完成- 通过
sysctl net.ipv4.tcp_available_congestion_control检查是否存在bbr功能 - 重启机器
要看下飞的多快
可以python的插件speedtest-cli来测试
- 安装
pip install speedtest-cli - 测试速度
speedtest-cli缺省是找离他最近的服务器来测试上传下载速度 通常我们需要测试服务器离我们实际访问地点的速度,可以先到speedtest城市列表 找到对应的id,例如我找到深圳如下
1
<server url="http://speedtest3.gd.chinamobile.com:8080/speedtest/upload.php" lat="22.5333" lon="114.1333" name="Shenzhen" country="China" cc="CN" sponsor="China Mobile,Guangdong" id="4515" url2="http://speedtestsz2.gd.chinamobile.com/speedtest/upload.php" host="speedtest3.gd.chinamobile.com:8080" />
speedtest-cli --server <id>就可以查到指定运营商、地点跟vps之间的速度跟延迟了
飞太多引起注意?担心被特征了吗?
使用http伪装起来
首先serve要改造下
git clone https://github.com/shadowsocks/simple-obfs.gitcd simple-obfsgit submodule init && git submodule update./autogen.sh && ./configure && makemake install修改/etc/55.json,增加如下,同时
1
2"plugin": "obfs-server",
"plugin_opts":"obfs=tls"重启ss-server服务,
supervisorctl restart ss,这个是我们刚才配置supervisor的客户端查看下进程会发现ss-sever跟obfs都拉起了
1
2root 17758 13089 0 00:28 ? 00:00:00 ss-server -c /etc/ss.conf
root 17759 17758 0 00:28 ? 00:00:00 obfs-server如果用命令行启动的话,可以直接这么配置
ss-server -c config.json --plugin obfs-server --plugin-opts "obfs=tls"
客户端:接着下载obfs-local,解压把里面的东西放到55相同的目录里,把 插件程序 和 插件选项 两个空位置,填写如下配置:
- 插件程序:obfs-local
- 插件选项:obfs=tls;obfs-host=www.baidu.com
- 如果用命令行启动的话,可以直接这么配置
ss-local -c config.json --plugin obfs-local --plugin-opts "obfs=tls;obfs-host=www.bing.com"
继续带上黑墨镜,金链,抽雪茄把
使用TFO TCP FAST OPEN
由于tfo需要服务器跟客户端同时这么使用,目前不支持windows
- 需要修改内核参数
net.ipv4.tcp_fastopen为3 修改server的启动配置为如下:
1
"fast_open":true
修改client段的配置为如下,增加fast-open标识
1
obfs=tls;obfs-host=www.baidu.com;fast-open
调整内核参数(可做可不做)
编辑/etc/sysctl.conf1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68net.core.default_qdisc=fq
net.ipv4.tcp_fastopen=3
net.ipv4.neigh.default.base_reachable_time_ms = 600000
net.ipv4.neigh.default.mcast_solicit = 20
net.ipv4.neigh.default.retrans_time_ms = 250
net.ipv4.tcp_congestion_control = bbr
net.core.rmem_max = 12582912
#设置内核接收Socket的最大长度(bytes)
net.core.wmem_max = 12582912
#设置内核发送Socket的最大长度(bytes)
net.ipv4.tcp_rmem = 10240 87380 12582912
#设置TCP Socket接收长度的最小值,预留值,最大值(bytes)
net.ipv4.tcp_rmem = 10240 87380 12582912
#设置TCP Socket发送长度的最小值,预留值,最大值(bytes)
net.ipv4.ip_forward = 1
#开启所有网络设备的IPv4流量转发,用于支持IPv4的正常访问
net.ipv4.tcp_syncookies = 1
#开启SYN Cookie,用于防范SYN队列溢出后可能收到的攻击
net.ipv4.tcp_tw_reuse = 1
#允许将等待中的Socket重新用于新的TCP连接,提高TCP性能
net.ipv4.tcp_tw_recycle = 0
#禁止将等待中的Socket快速回收,提高TCP的稳定性
net.ipv4.tcp_fin_timeout = 30
#设置客户端断开Sockets连接后TCP在FIN等待状态的实际(s),保证性能
net.ipv4.tcp_keepalive_time = 1200
#设置TCP发送keepalive数据包的频率,影响TCP链接保留时间(s),保证性能
net.ipv4.tcp_mtu_probing = 1
#开启TCP层的MTU主动探测,提高网络速度
net.ipv4.conf.all.accept_source_route = 1
net.ipv4.conf.default.accept_source_route = 1
#允许接收IPv4环境下带有路由信息的数据包,保证安全性
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
#拒绝接收来自IPv4的ICMP重定向消息,保证安全性
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
#禁止发送在IPv4下的ICMP重定向消息,保证安全性
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
#关闭反向路径回溯进行源地址验证(RFC1812),提高性能
net.ipv4.icmp_echo_ignore_broadcasts = 1
#忽略所有ICMP ECHO请求的广播,保证安全性
net.ipv4.icmp_ignore_bogus_error_responses = 1
#忽略违背RFC1122标准的伪造广播帧,保证安全性
net.ipv6.conf.all.accept_source_route = 1
net.ipv6.conf.default.accept_source_route = 1
#允许接收IPv6环境下带有路由信息的数据包,保证安全性
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
#禁止接收来自IPv6下的ICMPv6重定向消息,保证安全性
net.ipv6.conf.all.autoconf = 1
#开启自动设定本地连接地址,用于支持IPv6地址的正常分配
net.ipv6.conf.all.forwarding = 1
#开启所有网络设备的IPv6流量转发,用于支持IPv6的正常访问
fs.file-max = 1024000
#系统所有进程一共可以打开的句柄数(bytes)
kernel.msgmnb = 65536
#进程通讯消息队列的最大字节数(bytes)
kernel.msgmax = 65536
#进程通讯消息队列单条数据最大的长度(bytes)
kernel.shmmax = 68719476736
#内核允许的最大共享内存大小(bytes)
kernel.shmall = 4294967296
#任意时间内系统可以使用的共享内存总量(bytes)
编辑/etc/security/limits.conf1
2
3
4* soft nofile 512000
#用户档案警告体积大小(bytes)
* hard nofile 1024000
#用户档案最大体积大小(bytes)
重启系统