Skip to content

emadtoranji/NetworkOptimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ One-Line Installation (Network Optimizer Script)

Just run this in your terminal (works on root or non-root):

bash <(curl -fsSL https://raw.githubusercontent.com/emadtoranji/NetworkOptimizer/main/optimize.sh)

✨ Features

  • βœ… Enables Google's BBR congestion control (tcp_bbr) β€” BBRv2 if using a patched kernel, otherwise defaults to BBRv1
  • βœ… Configures fq queueing discipline for optimal performance
  • βœ… Enables TCP Fast Open, MTU probing, and aggressive memory windows
  • βœ… Safe for production environments
  • βœ… Writes clean configurations to /etc/sysctl.d/
  • βœ… No external dependencies or systemd required
  • βœ… Easy to install and uninstall
  • ⚠️ BBRv2 is not enabled by default in Linux. It requires a patched kernel such as BBRv2 backports.

πŸ”§ Requirements

  • 🐧 Linux Kernel 5.4 or higher (recommended: 5.10+ for full BBRv2 support)
  • πŸ” Root or sudo access
  • πŸ’‘ bash shell (pre-installed on all major Linux distributions)

To check your kernel version:

uname -r

πŸ” Verify BBR Activation (BBRv1 or v2, depending on kernel)

After running the script, confirm BBR is active (usually BBRv1 unless you use a custom kernel with BBRv2 patches):

  1. Check TCP congestion control:

    sysctl net.ipv4.tcp_congestion_control

    Expected output:

    net.ipv4.tcp_congestion_control = bbr
    
  2. Verify BBR module:

    lsmod | grep bbr

    Expected output:

    tcp_bbr                20480  1
    
  3. Inspect active TCP sessions:

    ss -tin

    Look for bbr in the congestion control field.


🧠 How It Works

While this script enables BBR (tcp_bbr), Linux does not currently offer a user-selectable distinction between BBRv1 and BBRv2. Most systems will run BBRv1 unless a custom kernel with BBRv2 support is used.

The script performs the following:

  • Loads the tcp_bbr kernel module
  • Configures module auto-loading on boot
  • Creates /etc/sysctl.d/99-bbrv2.conf with optimized settings:
    net.core.default_qdisc=fq
    net.ipv4.tcp_congestion_control=bbr
    net.ipv4.tcp_notsent_lowat=16384
    net.ipv4.tcp_fastopen=3
    net.ipv4.tcp_mtu_probing=1
    net.ipv4.tcp_slow_start_after_idle=0
    net.ipv4.tcp_window_scaling=1
    net.ipv4.tcp_rmem=4096 87380 67108864
    net.ipv4.tcp_wmem=4096 65536 67108864
  • Applies changes instantly with sysctl --system

🧹 Uninstallation

To revert changes:

sudo rm -f /etc/sysctl.d/99-network-optimizer.conf
sudo rm -f /etc/modules-load.d/bbrv2.conf
sudo sysctl --system
sudo reboot

πŸ§ͺ Tested Environments

Distribution Kernel Status
Ubuntu 20.04 5.15.x βœ…
Ubuntu 22.04 5.19+ βœ…
Debian 11 5.10.x βœ…
Debian 12 6.1.x βœ…
AlmaLinux 9 5.14.x βœ…
Oracle Linux 8 5.15+ (UEK) βœ…
Alpine Edge 6.1+ βœ…

πŸ“ˆ Performance Benefits (with BBR enabled)

After enabling BBR (v1 or v2, depending on your kernel), you can expect:

  • 🌍 Faster CDN/Cloudflare traffic
  • πŸ›°οΈ Reduced SSH/RDP latency
  • πŸ“¦ Improved TCP-based download speeds (HTTP, Git, APT/YUM, etc.)
  • πŸ“‘ Enhanced stability for VPNs (WireGuard, OpenVPN, Shadowsocks)

⚠️ Troubleshooting

  • BBR not active: Ensure your kernel supports tcp_bbr (5.4+). BBRv2 requires experimental kernel patches and is not enabled by default in mainline kernels. Upgrade your kernel if needed:
    sudo apt update && sudo apt install linux-generic-hwe-22.04
  • Permission denied: Run the script with sudo.
  • Module not found: Verify the tcp_bbr module is available:
    modprobe tcp_bbr

πŸ“œ License

This project is licensed under the MIT License. Feel free to use, fork, modify, and share!


🀝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add YourFeature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a Pull Request.

Please ensure your changes are well-tested and include a description of the changes.

About

πŸš€ Enable the best possible TCP performance with zero bloat.

Topics

Resources

License

Stars

Watchers

Forks

Languages