入ROOT模式:

sudo -i

1.安装相关依赖

centos系统下

yum -y install wget
yum update -y && yum install curl -y

ubuntu系统下

apt-get install wget
apt-get update -y && apt-get install curl -y

2.删除、关闭、打开各自系统的无用附件、防火墙、端口及规则

注意Centos系统下:
删除多余附件

systemctl stop oracle-cloud-agent
systemctl disable oracle-cloud-agent
systemctl stop oracle-cloud-agent-updater
systemctl disable oracle-cloud-agent-updater

停止firewall

systemctl stop firewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

注意Ubuntu系统下:
开放所有端口

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F

Ubuntu镜像默认设置了Iptable规则,关闭它

apt-get purge netfilter-persistent
reboot

或者强制删除

rm -rf /etc/iptables && reboot

3.启用自带BBR加速
ubuntu:

sudo bash -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf'
sudo bash -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
sysctl -p

查看bbr是否开启成功

lsmod | grep bbr

centnos8:

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

查看bbr是否开启成功

sysctl -n net.ipv4.tcp_congestion_control
lsmod | grep bbr

更新系统

#Ubuntu系统
apt update && apt upgrade -y
#Centos系统
yum update -y && yum upgrade -y

改为root密码登陆

BASH
echo root:密码 |chpasswd root
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
systemctl restart sshd

开启BBR

BASH
#修改系统变量
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

#保存生效
sysctl -p

#查看内核是否已开启BBR
lsmod | grep bbr

#显示如下,即成功
tcp_bbr 20480 2

放行全部端口(重启失效)

BASH
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
iptables-save

持续化规则(重启不失效)

BASH
#安装iptables-persistent
apt install iptables-persistent

#永久保存规则
netfilter-persistent save
netfilter-persistent reload
  • 对于关闭防火墙更暴力点的方法,可以选择如下两种
BASH
rm -rf /etc/iptables && reboot



rm -rf /etc/iptables/rules.v4
rm -rf /etc/iptables/rules.v6
reboot