The client provides you with an intranet clock address, requesting that “the server time must match it exactly!” Don’t panic, this step-by-step tutorial will help you synchronize with the client’s clock with zero error in just 5 minutes.
1. First, clarify: What did the client provide?
The address provided by the client, similar to <span>10.x.x.x</span>, is aself-built NTP server (intranet segment). Our task is to keep the Linux system timeautomatically, continuously, and accurately synchronized with it.
2. Choose the right solution: chrony vs systemd-timesyncd
| Scenario | Recommendation |
|---|---|
| Production servers, physical machines, virtual machines | chrony (can gradually correct even when offline, high precision) |
| Minimal containers, edge nodes | systemd-timesyncd (sufficient) |
The following 90% of the steps will use chrony as an example, just copy and use.
3. 5-Minute Practical Steps (chrony version)
1️⃣ Installation
# CentOS/RHEL/Alma/Rocky
sudo yum install -y chrony
# Debian/Ubuntu
sudo apt update && sudo apt install -y chrony
2️⃣ Add the client’s clock to the configuration
Note: Replace <span><client NTP IP></span> with the actual address provided by the client with one command to append:
sudo tee -a /etc/chrony.conf &<<EOF
# Client Intranet NTP
server &<client NTP IP&> iburst
EOF
3️⃣ Restart & Enable on Boot
sudo systemctl restart chronyd
sudo systemctl enable chronyd
4️⃣ Verify if synchronization was successful
chronyc sources -v
In the output, you should see:
^* &<client NTP IP&> ...
“^*” indicates synchronization is successful, done!
5️⃣ Write back to the hardware clock (to prevent BIOS time drift)
sudo hwclock --systohc
4. Emergency/Debug: Force Synchronization Once
# Stop existing service
sudo systemctl stop chronyd
# Force synchronization (remember to replace IP)
sudo chronyd -q 'server &<client NTP IP&> iburst'
# Immediately write back to BIOS
sudo hwclock --systohc
5. Don’t forget to allow 123/udp in the firewall
# firewalld example
sudo firewall-cmd --permanent --add-port=123/udp
sudo firewall-cmd --reload
6. One-click inspection command (save this)
timedatectl # Check timezone, NTP status
chronyc tracking # Check offset (Last offset < 10ms is excellent)
chronyc sources -v # Check source list
hwclock -r # Read hardware clock
7. Common pitfalls reminder
- 1. Virtual Machines: Remember to enable the “Time Synchronization” feature on the host machine, otherwise the guest will always drift.
- 2. Containers: Docker directly inherits the host machine’s clock, the clock inside the container cannot be changed; syncing at the host level is sufficient.
- 3. Dual Boot Systems: Windows treats RTC as local time, while Linux defaults to UTC; for dual boot systems, you need to run
<span>timedatectl set-local-rtc 1</span>. - 4. Permissions: All commands require root or sudo, do not run them without privileges.
8. Conclusion
The client says “the time must be consistent,” you just need to do three steps:
- 1. Install chrony
- 2. Write
<span>server <client NTP IP> iburst</span> - 3. Restart and verify
In 5 minutes, with zero scripting, just copy and paste to go live. Align the time, and the project will pass acceptance in one go!
Share this with your operations brother who is being urged by the client!