Debian 12 Initialization Guide: Network Configuration and BBR Optimization
Debian is the first choice for many server administrators due to its extremely high stability and low resource consumption. This article will introduce the standard initialization process after a fresh installation of Debian 12 (Bookworm), focusing on network configuration and network performance optimization.
1. System Update and Basic Tool Installation
Before performing any configuration, first ensure that the system software is up to date.
# Update package list and upgrade the system
apt update && apt upgrade -y
# Install common network and system tools
# curl/wget: Download tools
# vim/nano: Editors
# git: Version control
# net-tools: Contains old tools like ifconfig (optional)
# dnsutils: Contains DNS tools like dig/nslookup
apt install -y curl wget vim git net-tools dnsutils
2. Configure Static IP Address
Debian uses the /etc/network/interfaces file to manage network configurations by default. Although Netplan is popular in Ubuntu, Debian still recommends using the traditional ifupdown method.
View Current Network Interface
First, use ip addr to view the network card name (usually eth0 or ens18, etc.).
ip addr show
Modify Configuration File
Backup the original file and edit:
cp /etc/network/interfaces /etc/network/interfaces.bak
vim /etc/network/interfaces
Change the content to the following format (please modify the IP according to your actual network environment):
# Local loopback interface
auto lo
iface lo inet loopback
# Main network interface (assuming the card name is eth0)
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.100/24 # IP address and subnet mask (CIDR format)
gateway 192.168.1.1 # Gateway address
# dns-nameservers 8.8.8.8 1.1.1.1 # Optional: specify DNS directly here
After modification, restart the network service:
systemctl restart networking
# Or restart the system
reboot
3. Configure DNS Resolution
If DNS is not specified in /etc/network/interfaces, the system will use the configuration in /etc/resolv.conf.
Edit the file:
vim /etc/resolv.conf
Add recommended public DNS servers:
# Google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
# Cloudflare DNS
nameserver 1.1.1.1
Note: Some VPS providers will automatically reset this file after a reboot. If this happens, you can install the resolvconf service to persist the configuration, or set dns-nameservers in the network card configuration file.
4. Enable TCP BBR Congestion Control
BBR (Bottleneck Bandwidth and Round-trip propagation time) is a TCP congestion control algorithm developed by Google that can significantly improve network throughput and reduce latency, especially in network environments with some packet loss.
Check Current Algorithm
sysctl net.ipv4.tcp_congestion_control
# Output is usually: cubic or reno
Enable BBR
Debian 10+ kernels (4.9+) have already compiled the BBR module by default. Just modify the kernel parameters directly:
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
Apply and Verify
# Apply configuration
sysctl -p
# Verify again
sysctl net.ipv4.tcp_congestion_control
# Output should be: bbr
# Check if BBR module is loaded
lsmod | grep bbr
# Output should contain tcp_bbr
5. Other Common Initialization Settings
Set Hostname
hostnamectl set-hostname debian-server
Set Timezone
Set the timezone to Shanghai time (CST):
timedatectl set-timezone Asia/Shanghai
# Verify
timedatectl
Configure SSH Security (Optional)
Edit /etc/ssh/sshd_config to prohibit root password login (it is recommended to use keys):
PermitRootLogin prohibit-password
PasswordAuthentication no
Restart the SSH service:
systemctl restart ssh
After completing the above steps, your Debian server will have a stable network environment and good basic performance configuration.