diff --git a/README-zh.md b/README-zh.md index d01be3f..c7ba060 100644 --- a/README-zh.md +++ b/README-zh.md @@ -202,7 +202,7 @@ wget https://git.io/vpnupgrade -O vpnup.sh && sudo sh vpnup.sh - [VPN 分流](docs/advanced-usage-zh.md#vpn-分流) - [访问 VPN 服务器的网段](docs/advanced-usage-zh.md#访问-vpn-服务器的网段) - [更改 IPTables 规则](docs/advanced-usage-zh.md#更改-iptables-规则) -- [部署Google BBR拥塞控制算法](docs/advanced-usage-zh.md#部署google-bbr拥塞控制算法) +- [部署 Google BBR 拥塞控制算法](docs/advanced-usage-zh.md#部署-google-bbr-拥塞控制算法) ## 问题和反馈 diff --git a/README.md b/README.md index 84a50f5..820aa6f 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ See [Advanced usage](docs/advanced-usage.md). - [Split tunneling](docs/advanced-usage.md#split-tunneling) - [Access VPN server's subnet](docs/advanced-usage.md#access-vpn-servers-subnet) - [Modify IPTables rules](docs/advanced-usage.md#modify-iptables-rules) +- [Deploy Google BBR congestion control algorithm](docs/advanced-usage.md#deploy-google-bbr-congestion-control-algorithm) ## Bugs & Questions diff --git a/docs/advanced-usage-zh.md b/docs/advanced-usage-zh.md index f854a87..043da8d 100644 --- a/docs/advanced-usage-zh.md +++ b/docs/advanced-usage-zh.md @@ -10,7 +10,7 @@ * [VPN 分流](#vpn-分流) * [访问 VPN 服务器的网段](#访问-vpn-服务器的网段) * [更改 IPTables 规则](#更改-iptables-规则) -* [部署Google BBR拥塞控制算法](#部署google-bbr拥塞控制算法) +* [部署 Google BBR 拥塞控制算法](#部署-google-bbr-拥塞控制算法) ## 使用其他的 DNS 服务器 @@ -280,11 +280,11 @@ iptables -t nat -I POSTROUTING -s 192.168.42.0/24 -o "$netif" -j MASQUERADE **注:** 如果使用 Rocky Linux, AlmaLinux 或者 CentOS/RHEL 8 并且在安装 VPN 时 firewalld 正在运行,则可能已配置 nftables。在这种情况下,编辑 `/etc/sysconfig/nftables.conf` 而不是 `/etc/sysconfig/iptables`。 -## 部署Google BBR拥塞控制算法 +## 部署 Google BBR 拥塞控制算法 -VPN服务器搭建完成后,可以通过部署Google BBR拥塞控制算法提升性能。 +VPN 服务器搭建完成后,可以通过部署 Google BBR 拥塞控制算法提升性能。 -这通常只需要在配置文件 `/etc/sysctl.conf` 中插入设定即可完成。但是部分Linux发行版可能需要额外更新Linux Kernel。 +这通常只需要在配置文件 `/etc/sysctl.conf` 中插入设定即可完成。但是部分 Linux 发行版可能需要额外更新 Linux 内核。 详细的部署方法,可以参考[这篇文档](bbr-zh.md)。 diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 71d5568..089eb2a 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -10,6 +10,7 @@ * [Split tunneling](#split-tunneling) * [Access VPN server's subnet](#access-vpn-servers-subnet) * [Modify IPTables rules](#modify-iptables-rules) +* [Deploy Google BBR congestion control algorithm](#deploy-google-bbr-congestion-control-algorithm) ## Use alternative DNS servers @@ -280,6 +281,14 @@ If you want to modify the IPTables rules after install, edit `/etc/iptables.rule **Note:** If using Rocky Linux, AlmaLinux or CentOS/RHEL 8 and firewalld was active during VPN setup, nftables may be configured. In this case, edit `/etc/sysconfig/nftables.conf` instead of `/etc/sysconfig/iptables`. +## Deploy Google BBR congestion control algorithm + +After the VPN server is set up, the performance can be improved by deploying the Google BBR congestion control algorithm. + +This is usually done by modifying the configuration file `/etc/sysctl.conf`. However, some Linux distributions may additionally require updates to the Linux kernel. + +For detailed deployment methods, please refer to [this document](bbr.md). + ## License Copyright (C) 2021-2022 [Lin Song](https://github.com/hwdsl2) [![View my profile on LinkedIn](https://static.licdn.com/scds/common/u/img/webpromo/btn_viewmy_160x25.png)](https://www.linkedin.com/in/linsongui) diff --git a/docs/bbr-zh.md b/docs/bbr-zh.md index bac70af..3298538 100644 --- a/docs/bbr-zh.md +++ b/docs/bbr-zh.md @@ -1,20 +1,22 @@ -# Google BBR +# 高级用法:部署 Google BBR 拥塞控制算法 -Google BBR是一种由Google开发的拥塞控制算法,它能够显著提升服务器吞吐率并降低延迟。 +*其他语言版本: [English](bbr.md), [简体中文](bbr-zh.md)。* -Google BBR已经被内置于Linux Kernel 4.9及更高版本中,但是需要手动开启。 +Google BBR是一种拥塞控制算法,它能够显著提升服务器吞吐率并降低延迟。 + +Google BBR已经被内置于Linux内核4.9及更高版本中,但是需要手动开启。 关于Google BBR算法,可以在这篇[官方博客](https://cloud.google.com/blog/products/networking/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster)或者这个[官方库](https://github.com/google/bbr)中找到更多信息。 ## 准备 -可以通过命令 `uname -r` 来查看当前Linux Kernel版本。版本大于等于4.9时,可以直接参照[下方的说明](#部署google-bbr)部署BBR。 +可以通过命令 `uname -r` 来查看当前Linux内核版本。版本大于等于4.9时,可以直接参照[下方的说明](#部署-google-bbr)部署BBR。 通常而言,Ubuntu 18.04+, Debian 10+,CentOS 8+及RHEL 8+的内核版本都大于4.9。但是对于CentOS 7或者Amazon Linux 2,需要通过以下的方式更新内核之后才能部署Google BBR。 ### Amazon Linux 2 -Amazon Linux 2提供过经过验证的新版Linux Kernel,并可以通过启用预置的Extras库安装。 +Amazon Linux 2提供过经过验证的新版Linux内核,并可以通过启用预置的Extras库安装。 1. 启用 `kernel-ng` Extras 库 ```bash @@ -28,53 +30,53 @@ Amazon Linux 2提供过经过验证的新版Linux Kernel,并可以通过启用 ```bash sudo reboot ``` -4. 检查Linux Kernel版本 +4. 检查Linux内核版本 ```bash uname -r ``` ### CentOS 7 -当使用CentOS 7时,需要安装由ELRepo Project提供的新版Linux Kernel。可以在[这个页面](http://elrepo.org/tiki/kernel-ml)找到有关ELRepo Project提供的Linux Kernel的更多信息。 +当使用CentOS 7时,需要安装由ELRepo Project提供的新版Linux内核。可以在[这个页面](http://elrepo.org/tiki/kernel-ml)找到有关ELRepo Project提供的Linux内核的更多信息。 -以下的安装说明,因为缺少可供参考的中文文档,暂仅提供英文版。 +参见下面的安装说明。 -1. Import ELRepo Project's public key. +1. 导入ELRepo Project的公钥。 ```bash sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org ``` -2. Install ELRepo for RHEL-7, SL-7 or CentOS-7. +2. 为 RHEL-7、SL-7 或 CentOS-7 安装 ELRepo。 ```bash sudo yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm ``` -3. Install `kernel-ml`. +3. 安装 `kernel-ml`。 ```bash sudo yum --enablerepo=elrepo-kernel install kernel-ml ``` -4. Confirm the result. +4. 确认结果。 ```bash rpm -qa | grep kernel ``` - You should see `kernel-ml-xxx` in output. -5. Show all entries in the grub2 menu and setup `kernel-ml`. + 你应该在输出中看到 `kernel-ml-xxx`。 +5. 显示 grub2 菜单中的所有条目并设置 `kernel-ml`。 ```bash sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \' ``` - **Indexing starts at `0`.** - For example, when the `kernel-ml` is located at `1`, use the command below to activate `kernel-ml`. + **索引从 `0` 开始。** + 例如,当 `kernel-ml` 位于 `1` 时,使用下面的命令来激活 `kernel-ml`。 ```bash sudo grub2-set-default 1 ``` -6. Reboot. +6. 重启。 ```bash sudo reboot ``` -7. Check Linux kernel version. +7. 检查 Linux 内核版本。 ```bash uname -r ``` -## 部署Google BBR +## 部署 Google BBR 在这个部分,我们将通过修改配置文件启动Google BBR。 @@ -82,7 +84,7 @@ Amazon Linux 2提供过经过验证的新版Linux Kernel,并可以通过启用 ```bash sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup ``` -2. 修改`/etc/sysctl.conf` +2. 修改 `/etc/sysctl.conf` ```bash sudo vim /etc/sysctl.conf ``` @@ -103,4 +105,8 @@ Amazon Linux 2提供过经过验证的新版Linux Kernel,并可以通过启用 # bbr lsmod | grep bbr # tcp_bbr 16384 0 - ``` \ No newline at end of file + ``` + +## 作者 + +版权所有 (C) 2022 [Leo Liu](https://github.com/optimusleobear) diff --git a/docs/bbr.md b/docs/bbr.md new file mode 100644 index 0000000..15d2147 --- /dev/null +++ b/docs/bbr.md @@ -0,0 +1,113 @@ +# Advanced usage: Deploy Google BBR congestion control algorithm + +*Read this in other languages: [English](bbr.md), [简体中文](bbr-zh.md).* + +Google BBR is a congestion control algorithm that could significantly increase server throughput and reduce latency. + +Google BBR has been built into Linux kernel 4.9 and higher, but needs to be manually turned on. + +To learn more about the Google BBR algorithm, see this [official blog](https://cloud.google.com/blog/products/networking/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster) or this [official repository](https://github.com/google/bbr). + +## Prepare + +You can check the current Linux kernel version with the command `uname -r`. When the version is greater than or equal to 4.9, you can deploy BBR directly by referring to the [instructions below](#deploy-google-bbr). + +Generally speaking, the kernel versions of Ubuntu 18.04+, Debian 10+, CentOS 8+ and RHEL 8+ are greater than 4.9. But for CentOS 7 or Amazon Linux 2, you need to update the kernel in the following ways before deploying Google BBR. + +### Amazon Linux 2 + +Amazon Linux 2 provides newer versions of the verified Linux kernel, which can be installed by enabling the "Extras" repository. + +1. Enable the `kernel-ng` Extras repository + ```bash + sudo amazon-linux-extras install kernel-ng + ``` +2. Update packages + ```bash + sudo yum update + ``` +3. Restart the system + ```bash + sudo reboot + ``` +4. Check the Linux kernel version + ```bash + uname -r + ``` + +### CentOS 7 + +When using CentOS 7, a newer Linux kernel provided by the ELRepo Project needs to be installed. More information about the Linux kernels provided by the ELRepo Project can be found at [this page](http://elrepo.org/tiki/kernel-ml). + +Refer to the installation instructions below. + +1. Import ELRepo Project's public key. + ```bash + sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org + ``` +2. Install ELRepo for RHEL-7, SL-7 or CentOS-7. + ```bash + sudo yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm + ``` +3. Install `kernel-ml`. + ```bash + sudo yum --enablerepo=elrepo-kernel install kernel-ml + ``` +4. Confirm the result. + ```bash + rpm -qa | grep kernel + ``` + You should see `kernel-ml-xxx` in output. +5. Show all entries in the grub2 menu and setup `kernel-ml`. + ```bash + sudo egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \' + ``` + **Indexing starts at `0`.** + For example, when the `kernel-ml` is located at `1`, use the command below to activate `kernel-ml`. + ```bash + sudo grub2-set-default 1 + ``` +6. Reboot. + ```bash + sudo reboot + ``` +7. Check Linux kernel version. + ```bash + uname -r + ``` + +## Deploy Google BBR + +In this section, we will start Google BBR by modifying the configuration file. + +1. Backup `/etc/sysctl.conf` + ```bash + sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup + ``` +2. Modify `/etc/sysctl.conf` + ```bash + sudo vim /etc/sysctl.conf + ``` + Add the following lines to the file + ``` + net.core.default_qdisc = fq + net.ipv4.tcp_congestion_control = bbr + ``` +3. Enable Google BBR + ```bash + sudo sysctl -p + ``` +4. Check Google BBR status + ```bash + sudo sysctl net.ipv4.tcp_available_congestion_control + # net.ipv4.tcp_available_congestion_control = reno cubic bbr + sudo sysctl -n net.ipv4.tcp_congestion_control + # bbr + lsmod | grep bbr + # tcp_bbr 16384 0 + ``` + +## Author + +Copyright (C) 2022 [Leo Liu](https://github.com/optimusleobear) +Translated by [Lin Song](https://github.com/hwdsl2)