Enhance your Linux system's network capabilities for improved speed and efficiency
Network performance is crucial for many Linux systems, whether they're used as servers, workstations, or embedded devices. This guide will walk you through various techniques and tools to optimize your Linux system's network performance.
Ensure you have the latest network drivers for your hardware:
sudo lshw -C network
Check for and install any available updates for your network hardware.
BBR can significantly improve network throughput and latency:
echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.confecho "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.confsudo sysctl -p
Increase the queue length for better performance under high load:
sudo ip link set dev eth0 txqueuelen 10000
Adjust the following sysctl parameters:
net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.tcp_rmem = 4096 87380 16777216net.ipv4.tcp_wmem = 4096 65536 16777216
Example (adjust based on your NIC capabilities):
sudo ethtool -K eth0 tso on gso on gro on
Distribute network interrupts across multiple CPU cores:
sudo apt install irqbalancesudo systemctl enable --now irqbalance
Enable TCP Fast Open for faster connection establishment:
echo 3 | sudo tee /proc/sys/net/ipv4/tcp_fastopen
For 10Gbps+ networks, consider increasing the following:
net.core.netdev_max_backlog = 30000net.core.somaxconn = 1024
Always test thoroughly after making changes. Network optimizations can have different effects depending on your specific hardware, workload, and network environment.
Use these tools to monitor and benchmark your network performance:
| Tool | Purpose | Example Command |
|---|---|---|
| iperf3 | Measure network throughput | iperf3 -c server_ip |
| nethogs | Monitor per-process network usage | sudo nethogs |
| nload | Monitor network traffic and bandwidth usage | nload |
| tcpdump | Analyze network traffic | sudo tcpdump -i eth0 |
While optimizing network performance, keep these security aspects in mind:
Network optimization is an ongoing process. Regularly review and adjust your settings as your network requirements and infrastructure change.