Enable TCP BBR on Centos 7: Increase Network Speed

Posted on

Enable TCP BBR on Centos 7: Increase Network Speed

Enable TCP BBR on Centos 7: Increase Network Speed

This guide aims to teach you to Enable TCP BBR on Centos 7. BBR stands for TCP Bottleneck Bandwidth and Round-trip propagation time. TCP BBR is a congestion control algorithm developed by Google. It provides better network performance by managing congestion and optimizing throughput, resulting in improved user experience and faster data transfers.

Now you can follow the steps below to increase your Network speed by enabling TCP BBR on Centos 7.

Steps To Enable TCP BBR on Centos 7 To Help the Boosting Network Speed

Before you start to Enable TCP BBR on Centos 7, you must log in to your server as a non-root user with sudo privileges. For this purpose, you can check the Centos 7 Initial Setup Guide.

Then, follow the steps below to Enable TCP BBR on Centos 7.

Step 1 – Check the Current Congestion Algorithm on Centos 7

First, you need to update your local packages with the command below:

sudo yum update -y

Then, run the following command to Check the Current Congestion Algorithm on Centos 7:

sudo sysctl net.ipv4.tcp_congestion_control

Most of the Linux distros use Cubic and Reno algorithms. In your output, you should see something similar to this:

**Output**
net.ipv4.tcp_congestion_control = **cubic**

Also, you can use the commands below to check the available Congestion Algorithms on Centos 7:

sudo sysctl net.ipv4.tcp_available_congestion_control
**Output**
net.ipv4.tcp_available_congestion_control = **cubic reno**

As you can see, Cubic and Reno are available as the congestion algorithms. To add the TCP BBR, you can follow the steps below.

Step 2 – Install New Kernel on Centos 7

If you don’t install the new kernel, during the adding TCP BBR on Centos 7, you will get the following error:

**Error**
sysctl: setting key "net.ipv4.tcp_congestion_control": No such file or directory
net.ipv4.tcp_congestion_control = bbr

So you must use the following commands to install the Elrepo and get the latest kernel:

# sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# sudo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
# sudo yum --enablerepo=elrepo-kernel install kernel-ml

Then, edit file /etc/default/grub. Search for the line containing GRUB_DEFAULT and set it to 0.

GRUB_DEFAULT=0

Save and close the file.

Next, you need to create a new grub configuration file and reboot your Centos 7 to apply the changes:

# sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# sudo reboot

Step 3 – Add BBR As the Default Congestion Algorithm on Centos 7

At this point, you can add and enable TCP BBR as your default congestion algorithm. To do this, you need to open the sysctl.conf file with your desired text editor like Vi Editor or Nano Editor:

sudo vi /etc/sysctl.conf

Add the following content to the file to Enable TCP BBR on Centos 7:

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

Your file should look like this:

Add BBR As the Default Congestion Algorithm on Centos 7

When you are done, save and close the file.

Then, reload the configuration file with the command below:

sudo sysctl -p
**Output**
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

Step 4 – Verify TCP BBR is Enabled and Activated on Centos 7

At this point, you need to verify that BBR is enabled and active as the new TCP congestion control by using the following command on Centos 7:

sudo sysctl net.ipv4.tcp_congestion_control
**Output**
net.ipv4.tcp_congestion_control = bbr

Also, you can use the command below to verify it:

lsmod | grep bbr
**Output**
**tcp_bbr**                16384  5

Finally, list available TCP congestion controls on your server again:

sudo sysctl net.ipv4.tcp_available_congestion_control

You should see BBR in your list:

**Output**
net.ipv4.tcp_available_congestion_control = reno cubic **bbr**

That’s it. You have successfully added BBR to your Centos 7.

Conclusion

By following the guide steps, you can enable TCP BBR on CentOS 7, setting it as the default congestion algorithm, improving network performance, and optimizing throughput. Hope enjoy it. Also, you may like to read the following articles:

Python 3.12 Installation Tutorial for Centos 7

Install PHP 8.3 on Centos 7

Upgrade Linux Kernel on Centos 7

Alternative Solutions for Enabling TCP BBR on Centos 7

While the method described above is effective, here are two alternative solutions to achieve the same goal of enabling TCP BBR on Centos 7:

Alternative 1: Using a Pre-built Kernel with BBR Support (if available)

This approach avoids the manual kernel installation and configuration. Some repositories might offer pre-built kernels with BBR support already included. This simplifies the process, but relies on the availability and trustworthiness of the repository.

Explanation:

Instead of installing a generic kernel-ml package from ELRepo and manually configuring it, we would search for a kernel specifically built with BBR enabled. This would ideally involve a single installation command and potentially eliminate the need to edit /etc/default/grub.

Caveats:

  • Finding a reputable repository with a BBR-enabled kernel might be challenging.
  • The kernel version in the repository might not be the absolute latest.
  • Security updates for the kernel depend on the repository’s maintainers.

Hypothetical Example:

Let’s pretend there’s a hypothetical repository called "bbr-kernels". The process would look something like this:

# Add the hypothetical repository (replace with an actual repository if you find one)
sudo yum-config-manager --add-repo http://example.com/bbr-kernels.repo

# Install the BBR-enabled kernel (replace 'kernel-bbr' with the actual package name)
sudo yum install kernel-bbr

# Set the BBR kernel as the default in GRUB (may not be necessary if the package does it automatically)
# sudo grub2-set-default 0  # Assuming it's the first entry

# Reboot
sudo reboot

After rebooting, you’d still need to verify that BBR is enabled using the sysctl and lsmod commands from the original article.

Alternative 2: Using tuned Profiles

The tuned service is a system tuning daemon that dynamically adjusts system settings based on predefined profiles. We can create a custom tuned profile to enable TCP BBR without directly modifying system configuration files. This offers a more structured and manageable approach.

Explanation:

tuned profiles are stored in /etc/tuned. We’ll create a new profile that modifies the sysctl settings related to TCP congestion control. When this profile is activated, tuned will apply these settings automatically. This allows for easier switching between different tuning configurations.

Steps:

  1. Create a new tuned profile directory:

    sudo mkdir /etc/tuned/bbr
  2. Create a tuned.conf file within the directory:

    sudo nano /etc/tuned/bbr/tuned.conf

    Add the following content to tuned.conf:

    [main]
    include = latency-performance #Or other base profile
    
    [sysctl]
    net.core.default_qdisc = fq
    net.ipv4.tcp_congestion_control = bbr

    This profile inherits from the latency-performance profile (or another suitable base profile) and then overrides the TCP congestion control settings.

  3. Activate the new profile:

    sudo tuned-adm profile bbr
  4. Verify the changes:

    Use the sysctl and lsmod commands from the original article to confirm that BBR is enabled. You might need to reboot for the changes to fully take effect.

  5. Ensure tuned is enabled:

    sudo systemctl enable tuned
    sudo systemctl start tuned

Advantages:

  • More structured configuration compared to directly editing sysctl.conf.
  • Easier to switch between different performance profiles.
  • tuned can dynamically adjust settings based on system load.

Disadvantages:

  • Requires familiarity with the tuned service.
  • Might introduce additional overhead (though typically minimal).

By exploring these alternative solutions, you can choose the method that best suits your needs and level of expertise when enabling TCP BBR on Centos 7. Remember to always back up your configuration files before making any changes to your system.

Leave a Reply

Your email address will not be published. Required fields are marked *