Linux Server (Network Related)

📢 This article was translated by gemini-2.5-flash

This article was written by Hiyoung .

Background Knowledge:

Linux Clock Overview A Linux system has two clocks: a hardware clock (BIOS time) and a system clock (Linux Kernel time). Programs on Linux systems always read the system’s Kernel time. Every time Linux boots, the Kernel first reads the hardware clock settings (though the hardware time might not be accurate then). After that, the system clock runs independently of the hardware clock. So, to permanently change Linux time and keep it accurate, you need to permanently update the hardware clock. Otherwise, upon reboot, the system time will revert to the old hardware time. Linux Clock Commands For the system (Kernel) clock, use timedatectl or date. For the hardware (BIOS) clock, use hwclock or clock.

1. Check current Linux system time by typing date in the Linux CLI

1
data

Check hardware time with hwclock --show

1
hwclock --show

2. Calibrate Linux System Time (requires network for NTP service)

  • Here’s how to install and configure NTP on CentOS:
1
2
# Install the NTP service package
sudo yum install ntp
1
2
# Set NTP service to start on boot
sudo chkconfig ntp on
1
2
# Modify startup parameters: add -g -x to allow NTP to function even with large system time discrepancies.
sudo vi /etc/sysconfig/ntpd
1
2
# Start the NTP service
sudo service ntpd restart
  • Here’s how to install and configure NTP on Ubuntu/Debian:
1
2
# Install the NTP service package
sudo apt-get install ntp
1
2
# Modify startup parameters: add -g -x to allow NTP to function even with large system time discrepancies.
sudo vi /etc/default/ntp
1
2
# Start the NTP service
sudo service ntp restart
  • Sync hardware clock with system clock
1
hwclock --systohc --localtime (This one seems more effective)

Or

1
timedatectl set-local-rtc 1   
  • Finally, write date to CMOS for permanent effect
1
clock -w

Or

1
hwclock -w

3. Enable Google BBR Acceleration

This guide requires Debian 9 or newer. Compatibility with other OSes is unknown.

Note: These configurations don’t just enable Google BBR; they also include various network parameter optimizations. Just copy and run them.

Enabling Google BBR for your VPS is simple. SSH into your VPS, then execute these two commands (select, right-click to copy, paste after the root user’s #, then hit Enter).

Command 1

1
wget https://raw.githubusercontent.com/bannedbook/fanqiang/master/v2ss/server-cfg/sysctl.conf -O /etc/sysctl.conf

If you get a wget: command not found error, wget isn’t installed. You’ll need to install it first: <strong>apt-get install -y wget</strong>

Command 2

1
sysctl -p

After successful execution, you’ll see output similar to this (may vary):
fs.file-max = 51200
net.ipv4.conf.lo.accept_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_rmem = 32768 436600 873200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_tw_buckets = 9000
net.ipv4.tcp_max_syn_backlog = 65536
net.ipv4.tcp_mem = 94500000 91500000 92700000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_wmem = 8192 436600 873200
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.tcp_congestion_control = bbr

This post is licensed under CC BY-NC-SA 4.0 by the author.