├── README.md ├── bbr.sh ├── scalable-re.conf ├── scalable-re.sh └── sysctl.conf /README.md: -------------------------------------------------------------------------------- 1 | # YankeeBBR 2 | 来自Loc大佬Yankee魔改的BBR的Debian一键安装包 3 | 4 | ## 安装命令 5 | ```bash 6 | wget -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/YankeeBBR/master/bbr.sh && bash bbr.sh install 7 | ``` 8 | 9 | 然后根据提示重启系统。 10 | 11 | 重启完成后,运行 12 | 13 | ```bash 14 | bash bbr.sh start 15 | ``` 16 | 17 | 启动魔改版BBR 18 | 19 | ## 查看魔改BBR状态 20 | ```bash 21 | sysctl net.ipv4.tcp_available_congestion_control 22 | ``` 23 | 如果看到有 **tsunami** 就表示开启成功! 24 | -------------------------------------------------------------------------------- /bbr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | #================================================= 6 | # System Required: Debian/Ubuntu 7 | # Description: 魔改版BBR 8 | # Version: 1.0 9 | # Author: 雨落无声 10 | # Blog: https://www.zhujiboke.com 11 | # From https://doub.io 12 | #================================================= 13 | 14 | #Check Root 15 | [ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; } 16 | 17 | #Check OS 18 | if [[ -f /etc/redhat-release ]]; then 19 | release="centos" 20 | elif cat /etc/issue | grep -q -E -i "debian"; then 21 | release="debian" 22 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 23 | release="ubuntu" 24 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 25 | release="centos" 26 | elif cat /proc/version | grep -q -E -i "debian"; then 27 | release="debian" 28 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 29 | release="ubuntu" 30 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 31 | release="centos" 32 | fi 33 | bit=`uname -m` 34 | dir=`pwd` 35 | installbbr(){ 36 | #Install GCC 37 | apt-get update 38 | apt-get install build-essential -y 39 | apt-get install make gcc-4.9 -y 40 | 41 | 42 | #Download Kernel V4.10 43 | wget -O headers-all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015_4.10.15-041015.201705080411_all.deb 44 | dpkg -i headers-all.deb 45 | 46 | if [[ ${bit} == "i386" ]]; then 47 | wget --no-check-certificate -O headers.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015-generic_4.10.15-041015.201705080411_i386.deb 48 | wget --no-check-certificate -O image.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_i386.deb 49 | elif [[ ${bit} == "x86_64" ]]; then 50 | wget --no-check-certificate -O headers.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb 51 | wget --no-check-certificate -O image.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb 52 | else 53 | echo -e "不支持 ${bit} !" && exit 1 54 | fi 55 | 56 | dpkg -i headers.deb 57 | dpkg -i image.deb 58 | rm -rf headers-all.deb 59 | rm -rf headers.deb image.deb 60 | 61 | #Uninstall Other Kernel 62 | deb_total=`dpkg -l | grep linux-image | awk '{print $2}' | grep -v "4.10.15" | wc -l` 63 | if [ "${deb_total}" > "1" ]; then 64 | echo -e "检测到 ${deb_total} 个其余内核,开始卸载..." 65 | for((integer = 1; integer <= ${deb_total}; integer++)) 66 | do 67 | deb_del=`dpkg -l|grep linux-image | awk '{print $2}' | grep -v "4.10.15" | head -${integer}` 68 | echo -e "开始卸载 ${deb_del} 内核..." 69 | apt-get purge -y ${deb_del} 70 | echo -e "卸载 ${deb_del} 内核卸载完成,继续..." 71 | done 72 | deb_total=`dpkg -l|grep linux-image | awk '{print $2}' | grep -v "4.10.15" | wc -l` 73 | if [ "${deb_total}" = "0" ]; then 74 | echo -e "内核卸载完毕,继续..." 75 | else 76 | echo -e " 内核卸载异常,请检查 !" && exit 1 77 | fi 78 | else 79 | echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1 80 | fi 81 | 82 | #Finish Install 83 | update-grub 84 | echo -e "\033[42;37m[注意]\033[0m 重启VPS后,请重新运行脚本开启魔改BBR \033[42;37m bash bbr.sh start \033[0m" 85 | stty erase '^H' && read -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn 86 | [ -z "${yn}" ] && yn="y" 87 | if [[ $yn == [Yy] ]]; then 88 | echo -e "\033[41;37m[信息]\033[0m VPS 重启中..." 89 | reboot 90 | fi 91 | } 92 | 93 | 94 | startbbr(){ 95 | mkdir -p $dir/tsunami && cd $dir/tsunami 96 | wget --no-check-certificate -O ./tcp_tsunami.c https://raw.githubusercontent.com/ILLKX/BBR-Mod-backup/master/tcp_tsunami.c 97 | echo "obj-m:=tcp_tsunami.o" > Makefile 98 | make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc-4.9 99 | insmod tcp_tsunami.ko 100 | cp -rf ./tcp_tsunami.ko /lib/modules/$(uname -r)/kernel/net/ipv4 101 | depmod -a 102 | modprobe tcp_tsunami 103 | rm -rf /etc/sysctl.conf 104 | wget -O /etc/sysctl.conf -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/YankeeBBR/master/sysctl.conf 105 | sysctl -p 106 | cd .. && rm -rf $dir/tsunami 107 | echo "魔改版BBR启动成功!" 108 | } 109 | 110 | 111 | action=$1 112 | [ -z $1 ] && action=install 113 | case "$action" in 114 | install|start) 115 | ${action}bbr 116 | ;; 117 | *) 118 | echo "输入错误 !" 119 | echo "用法: { install | start }" 120 | ;; 121 | esac 122 | -------------------------------------------------------------------------------- /scalable-re.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/sysctl.conf - Configuration file for setting system variables 3 | # See /etc/sysctl.d/ for additional system variables. 4 | # See sysctl.conf (5) for information. 5 | # 6 | 7 | #kernel.domainname = example.com 8 | 9 | # Uncomment the following to stop low-level messages on console 10 | #kernel.printk = 3 4 1 3 11 | 12 | ##############################################################3 13 | # Functions previously found in netbase 14 | # 15 | 16 | # Uncomment the next two lines to enable Spoof protection (reverse-path filter) 17 | # Turn on Source Address Verification in all interfaces to 18 | # prevent some spoofing attacks 19 | #net.ipv4.conf.default.rp_filter=1 20 | #net.ipv4.conf.all.rp_filter=1 21 | 22 | # Uncomment the next line to enable TCP/IP SYN cookies 23 | # See http://lwn.net/Articles/277146/ 24 | # Note: This may impact IPv6 TCP sessions too 25 | #net.ipv4.tcp_syncookies=1 26 | 27 | # Uncomment the next line to enable packet forwarding for IPv4 28 | net.ipv4.ip_forward=1 29 | 30 | # Uncomment the next line to enable packet forwarding for IPv6 31 | # Enabling this option disables Stateless Address Autoconfiguration 32 | # based on Router Advertisements for this host 33 | #net.ipv6.conf.all.forwarding=1 34 | 35 | 36 | ################################################################### 37 | # Additional settings - these settings can improve the network 38 | # security of the host and prevent against some network attacks 39 | # including spoofing attacks and man in the middle attacks through 40 | # redirection. Some network environments, however, require that these 41 | # settings are disabled so review and enable them as needed. 42 | # 43 | # Do not accept ICMP redirects (prevent MITM attacks) 44 | #net.ipv4.conf.all.accept_redirects = 0 45 | #net.ipv6.conf.all.accept_redirects = 0 46 | # _or_ 47 | # Accept ICMP redirects only for gateways listed in our default 48 | # gateway list (enabled by default) 49 | # net.ipv4.conf.all.secure_redirects = 1 50 | # 51 | # Do not send ICMP redirects (we are not a router) 52 | #net.ipv4.conf.all.send_redirects = 0 53 | # 54 | # Do not accept IP source route packets (we are not a router) 55 | #net.ipv4.conf.all.accept_source_route = 0 56 | #net.ipv6.conf.all.accept_source_route = 0 57 | # 58 | # Log Martian Packets 59 | #net.ipv4.conf.all.log_martians = 1 60 | # 61 | fs.file-max = 51200 62 | 63 | net.core.rmem_max = 67108864 64 | 65 | net.core.wmem_max = 67108864 66 | 67 | net.core.netdev_max_backlog = 250000 68 | 69 | net.core.somaxconn = 4096 70 | 71 | net.ipv4.tcp_syncookies = 1 72 | 73 | net.ipv4.tcp_tw_reuse = 1 74 | 75 | net.ipv4.tcp_tw_recycle = 0 76 | 77 | net.ipv4.tcp_fin_timeout = 30 78 | 79 | net.ipv4.tcp_keepalive_time = 1200 80 | 81 | net.ipv4.ip_local_port_range = 10000 65000 82 | 83 | net.ipv4.tcp_max_syn_backlog = 8192 84 | 85 | net.ipv4.tcp_max_tw_buckets = 5000 86 | 87 | net.ipv4.tcp_fastopen = 3 88 | 89 | net.ipv4.tcp_rmem = 4096 87380 67108864 90 | 91 | net.ipv4.tcp_wmem = 4096 65536 67108864 92 | 93 | net.ipv4.tcp_mtu_probing = 1 94 | 95 | net.core.default_qdisc=fq 96 | 97 | net.ipv4.tcp_congestion_control=scalable-re 98 | -------------------------------------------------------------------------------- /scalable-re.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | #================================================= 6 | # System Required: Debian/Ubuntu 7 | # Description: scalable-re 8 | # Version: 1.0 9 | # Author: 雨落无声 10 | # Blog: https://www.zhujiboke.com 11 | # From https://doub.io 12 | #================================================= 13 | 14 | #Check Root 15 | [ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; } 16 | 17 | #Check OS 18 | if [[ -f /etc/redhat-release ]]; then 19 | release="centos" 20 | elif cat /etc/issue | grep -q -E -i "debian"; then 21 | release="debian" 22 | elif cat /etc/issue | grep -q -E -i "ubuntu"; then 23 | release="ubuntu" 24 | elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then 25 | release="centos" 26 | elif cat /proc/version | grep -q -E -i "debian"; then 27 | release="debian" 28 | elif cat /proc/version | grep -q -E -i "ubuntu"; then 29 | release="ubuntu" 30 | elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then 31 | release="centos" 32 | fi 33 | bit=`uname -m` 34 | dir=`pwd` 35 | installscalable-re(){ 36 | #Install GCC 37 | apt-get update 38 | apt-get install build-essential -y 39 | apt-get install make gcc-4.9 -y 40 | 41 | 42 | #Download Kernel V4.10 43 | wget -O headers-all.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015_4.10.15-041015.201705080411_all.deb 44 | dpkg -i headers-all.deb 45 | 46 | if [[ ${bit} == "i386" ]]; then 47 | wget -O headers.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015-generic_4.10.15-041015.201705080411_i386.deb 48 | wget -O image.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_i386.deb 49 | elif [[ ${bit} == "x86_64" ]]; then 50 | wget -O headers.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-headers-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb 51 | wget -O image.deb http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.15/linux-image-4.10.15-041015-generic_4.10.15-041015.201705080411_amd64.deb 52 | else 53 | echo -e "不支持 ${bit} !" && exit 1 54 | fi 55 | 56 | dpkg -i headers.deb 57 | dpkg -i image.deb 58 | rm -rf headers-all.deb 59 | rm -rf headers.deb image.deb 60 | 61 | #Uninstall Other Kernel 62 | deb_total=`dpkg -l | grep linux-image | awk '{print $2}' | grep -v "4.10.15" | wc -l` 63 | if [ "${deb_total}" > "1" ]; then 64 | echo -e "检测到 ${deb_total} 个其余内核,开始卸载..." 65 | for((integer = 1; integer <= ${deb_total}; integer++)) 66 | do 67 | deb_del=`dpkg -l|grep linux-image | awk '{print $2}' | grep -v "4.10.15" | head -${integer}` 68 | echo -e "开始卸载 ${deb_del} 内核..." 69 | apt-get purge -y ${deb_del} 70 | echo -e "卸载 ${deb_del} 内核卸载完成,继续..." 71 | done 72 | deb_total=`dpkg -l|grep linux-image | awk '{print $2}' | grep -v "4.10.15" | wc -l` 73 | if [ "${deb_total}" = "0" ]; then 74 | echo -e "内核卸载完毕,继续..." 75 | else 76 | echo -e " 内核卸载异常,请检查 !" && exit 1 77 | fi 78 | else 79 | echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1 80 | fi 81 | 82 | #Finish Install 83 | update-grub 84 | echo -e "\033[42;37m[注意]\033[0m 重启VPS后,请重新运行脚本开启scalable-re \033[42;37m bash scalable-re.sh start \033[0m" 85 | stty erase '^H' && read -p "需要重启VPS后,才能开启scalable-re,是否现在重启 ? [Y/n] :" yn 86 | [ -z "${yn}" ] && yn="y" 87 | if [[ $yn == [Yy] ]]; then 88 | echo -e "\033[41;37m[信息]\033[0m VPS 重启中..." 89 | reboot 90 | fi 91 | } 92 | 93 | 94 | startscalable-re(){ 95 | mkdir -p $dir/scalable_re && cd $dir/scalable_re 96 | wget -O ./tcp_scalable_re.c https://gist.github.com/anonymous/b156f89dab8aeaad6c98d981a026e283/raw/33187bad9651e65bce803ab7656eff8cf1e496be/tcp_scalable_re.c 97 | echo "obj-m:=tcp_scalable_re.o" > Makefile 98 | make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc-4.9 99 | insmod tcp_scalable_re.ko 100 | cp -rf ./tcp_scalable_re.ko /lib/modules/$(uname -r)/kernel/net/ipv4 101 | depmod -a 102 | modprobe tcp_scalable_re 103 | rm -rf /etc/sysctl.conf 104 | wget -O /etc/sysctl.conf -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/YankeeBBR/master/scalable-re.conf 105 | sysctl -p 106 | cd .. && rm -rf $dir/scalable_re 107 | echo "魔改版scalable-re启动成功!" 108 | } 109 | 110 | 111 | action=$1 112 | [ -z $1 ] && action=install 113 | case "$action" in 114 | install|start) 115 | ${action}scalable-re 116 | ;; 117 | *) 118 | echo "输入错误 !" 119 | echo "用法: { install | start }" 120 | ;; 121 | esac 122 | -------------------------------------------------------------------------------- /sysctl.conf: -------------------------------------------------------------------------------- 1 | # 2 | # /etc/sysctl.conf - Configuration file for setting system variables 3 | # See /etc/sysctl.d/ for additional system variables. 4 | # See sysctl.conf (5) for information. 5 | # 6 | 7 | #kernel.domainname = example.com 8 | 9 | # Uncomment the following to stop low-level messages on console 10 | #kernel.printk = 3 4 1 3 11 | 12 | ##############################################################3 13 | # Functions previously found in netbase 14 | # 15 | 16 | # Uncomment the next two lines to enable Spoof protection (reverse-path filter) 17 | # Turn on Source Address Verification in all interfaces to 18 | # prevent some spoofing attacks 19 | #net.ipv4.conf.default.rp_filter=1 20 | #net.ipv4.conf.all.rp_filter=1 21 | 22 | # Uncomment the next line to enable TCP/IP SYN cookies 23 | # See http://lwn.net/Articles/277146/ 24 | # Note: This may impact IPv6 TCP sessions too 25 | #net.ipv4.tcp_syncookies=1 26 | 27 | # Uncomment the next line to enable packet forwarding for IPv4 28 | net.ipv4.ip_forward=1 29 | 30 | # Uncomment the next line to enable packet forwarding for IPv6 31 | # Enabling this option disables Stateless Address Autoconfiguration 32 | # based on Router Advertisements for this host 33 | #net.ipv6.conf.all.forwarding=1 34 | 35 | 36 | ################################################################### 37 | # Additional settings - these settings can improve the network 38 | # security of the host and prevent against some network attacks 39 | # including spoofing attacks and man in the middle attacks through 40 | # redirection. Some network environments, however, require that these 41 | # settings are disabled so review and enable them as needed. 42 | # 43 | # Do not accept ICMP redirects (prevent MITM attacks) 44 | #net.ipv4.conf.all.accept_redirects = 0 45 | #net.ipv6.conf.all.accept_redirects = 0 46 | # _or_ 47 | # Accept ICMP redirects only for gateways listed in our default 48 | # gateway list (enabled by default) 49 | # net.ipv4.conf.all.secure_redirects = 1 50 | # 51 | # Do not send ICMP redirects (we are not a router) 52 | #net.ipv4.conf.all.send_redirects = 0 53 | # 54 | # Do not accept IP source route packets (we are not a router) 55 | #net.ipv4.conf.all.accept_source_route = 0 56 | #net.ipv6.conf.all.accept_source_route = 0 57 | # 58 | # Log Martian Packets 59 | #net.ipv4.conf.all.log_martians = 1 60 | # 61 | fs.file-max = 51200 62 | 63 | net.core.rmem_max = 67108864 64 | 65 | net.core.wmem_max = 67108864 66 | 67 | net.core.netdev_max_backlog = 250000 68 | 69 | net.core.somaxconn = 4096 70 | 71 | net.ipv4.tcp_syncookies = 1 72 | 73 | net.ipv4.tcp_tw_reuse = 1 74 | 75 | net.ipv4.tcp_tw_recycle = 0 76 | 77 | net.ipv4.tcp_fin_timeout = 30 78 | 79 | net.ipv4.tcp_keepalive_time = 1200 80 | 81 | net.ipv4.ip_local_port_range = 10000 65000 82 | 83 | net.ipv4.tcp_max_syn_backlog = 8192 84 | 85 | net.ipv4.tcp_max_tw_buckets = 5000 86 | 87 | net.ipv4.tcp_fastopen = 3 88 | 89 | net.ipv4.tcp_rmem = 4096 87380 67108864 90 | 91 | net.ipv4.tcp_wmem = 4096 65536 67108864 92 | 93 | net.ipv4.tcp_mtu_probing = 1 94 | 95 | net.core.default_qdisc=fq 96 | 97 | net.ipv4.tcp_congestion_control=tsunami 98 | --------------------------------------------------------------------------------