0%

VPS 配置

vps 配置

安装 shadowsocks

安装编译依赖

1
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y

clone 代码

1
git clone https://github.com/shadowsocks/shadowsocks-libev.git

编译安装

1
2
3
4
cd shadowsocks-libev/
it submodule update --init
./autogen.sh && ./configure && make
make install

配置文件

1
2
3
4
5
6
7
8
{
"server": "0.0.0.0",
"server_port": port,
"local_port": 1086,
"password": "password",
"timeout": 300,
"method": "chacha20-ietf-poly1305"
}

优化

编辑文件
/etc/sysctl.conf

1
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
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

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.conf.all.rp_filter=0
net.ipv4.conf.eth0.rp_filter=0
net.ipv4.conf.eth1.rp_filter=0
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv4.tcp_fastopen=3

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 = bbr

使生效
sysctl -p

编辑文件
/etc/security/limits.conf

1
2
* soft nofile 51200
* hard nofile 51200

ulimit -n 51200

防火墙设置

需要加入 shadowsocks, ssh 的端口

1
2
3
4
systemctl enable firewalld --now
firewall-cmd --add-port=shadowsocks-port/tcp --permanent
firewall-cmd --add-port=ssh-port/tcp --permanent
systemctl restart firewalld

autossh 反向代理

编辑文件
/etc/ssh/sshd_config

1
GatewayPorts yes

防火墙设置

firewall-cmd --add-port=autossh-port/tcp --permanent

内网机器启动反向代理

autossh -p vps-ssh-ip -M monitor-ip -o "PasswordAuthentication=no" -NfR map-ip:127.0.0.1:22 root@vps-ip