Debian 11/12
cat > /etc/sysctl.conf << EOF
fs.file-max = 6815744
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_ecn=0
net.ipv4.tcp_frto=0
net.ipv4.tcp_mtu_probing=0
net.ipv4.tcp_rfc1337=0
net.ipv4.tcp_sack=1
net.ipv4.tcp_fack=1
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_adv_win_scale=1
net.ipv4.tcp_moderate_rcvbuf=1
net.core.rmem_max=33554432
net.core.wmem_max=33554432
net.ipv4.tcp_rmem=4096 87380 33554432
net.ipv4.tcp_wmem=4096 16384 33554432
net.ipv4.udp_rmem_min=8192
net.ipv4.udp_wmem_min=8192
net.ipv4.ip_forward=1
net.ipv4.conf.all.route_localnet=1
net.ipv4.conf.all.forwarding=1
net.ipv4.conf.default.forwarding=1
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.forwarding=1
EOF
sysctl -p && sysctl --system
CentOS8下
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
sysctl -n net.ipv4.tcp_congestion_control
验证是否开启成功
sysctl net.ipv4.tcp_available_congestion_control
#返回net.ipv4.tcp_available_congestion_control = reno cubic bbr则为成功开启
lsmod | grep bbr
#返回类似 tcp_bbr 20480 84 即为安装成功
复制、粘贴、回车即可。
如果用的是CentOS7系统,那么默认的内核版本会很低,可以下面的方法手动升级
#系统更新(已更新就跳过这步)
yum update -y
#查看系统版本
<code>cat /etc/redhat-release</code> #输出<code>CentOS Linux release 7.8.*** (Core)</code> (具体版本我忘了反正比之前高就是升级完了...)
#安装elrepo并升级内核
<code>rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org</code>
<code>yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm</code>
<code>yum --enablerepo=elrepo-kernel install kernel-ml -y</code>
#安装完成后可用以下命令查看系统内核版本
<code>awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg</code>
#输入上条命令后应返回
#0 : CentOS Linux (5.11.3-1.el7.elrepo.x86_64) 7 (Core)
#1 : CentOS Linux (3.10.0-1160.15.2.el7.x86_64) 7 (Core)
#2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
#3 : CentOS Linux (0-rescue-33a7b03d95984f5eb95faec45204893c) 7 (Core)
#将最高版本内核设为默认
<code>grub2-set-default 0</code>
#重启系统
reboot
#开启bbr并验证是否安装成功
参考文章开始部分