Last active
December 7, 2017 10:56
-
-
Save jimyang2008/61e3911fe3d010ff293e8fa1c458b82c to your computer and use it in GitHub Desktop.
Setup BBR for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
err() { | |
msg="$@" | |
echo "ERROR: $msg" >&2 | |
} | |
centos6() { | |
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org | |
rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm | |
yum --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel -y | |
sed -i 's:default=.*:default=0:g' /etc/grub.conf | |
} | |
centos7() { | |
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org | |
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm | |
yum --enablerepo=elrepo-kernel install kernel-ml -y | |
grub2-set-default 0 | |
reboot | |
} | |
ubuntu14() { | |
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.17/linux-image-4.10.17-041017-generic_4.10.17-041017.201705201051_amd64.deb | |
dpkg -i linux-image-4.*.deb | |
update-grub | |
} | |
check_kernel() { | |
kv=$(uname -r) | |
echo "Kernel is $kv" | |
test "${kv:0:1}" == "4" | |
} | |
upgrade_kernel() { | |
check_kernel && return 0 | |
if grep -qi ubuntu /etc/*release | |
then | |
ubuntu14 | |
elif grep -qi 'centos release 6' /etc/*release | |
then | |
centos6 | |
elif grep -qi 'centos linux release 7' /etc/*release | |
then | |
centos7 | |
else | |
err Unsupported OS | |
exit 1 | |
fi | |
check_kernel | |
} | |
setup_bbr() { | |
modprobe tcp_bbr | |
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf | |
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf | |
sysctl -p | |
} | |
#----------------- | |
# MAIN goes here | |
#----------------- | |
upgrade_kernel || exit 1 | |
setup_bbr || exit 1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment