NTP Server
https://mp.weixin.qq.com/s/LQnLSt85etWm1G4-aH_jug
https://mp.weixin.qq.com/s/psuY8B26lsgOnhQHMtOiGQ
# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
# pool pool.ntp.org iburst
server ntp.aliyun.com iburst
server time1.cloud.tencent.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
allow 10.23.0.0/16
allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
local stratum 10
# Require authentication (nts or key option) for all NTP sources.
#authselectmode require
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony
# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew
# Get TAI-UTC offset and leap seconds from the system tz database.
#leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
yxbinghe
cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
# pool pool.ntp.org iburst
server ntp.aliyun.com iburst
server time1.cloud.tencent.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
allow 10.23.0.0/16
allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
local stratum 10
# Require authentication (nts or key option) for all NTP sources.
#authselectmode require
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony
# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew
# Get TAI-UTC offset and leap seconds from the system tz database.
#leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
[root@en_58 ~]# ssh root@10.23.120.124
Last login: Sat Dec 27 15:40:52 2025 from 10.23.116.60
[root@120124 ~]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 10.23.116.58 iburst prefer
server 10.23.116.60 iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
yxbinghe@yxbinghe
server 10.23.116.58 iburst prefer
server 10.23.116.60 iburst
# =========================
# 上游:唯一权威时间源
# =========================
server 192.168.1.58 iburst prefer
# =========================
# 本机作为 NTP Server
# =========================
allow 192.168.101.0/24
# 本地时钟兜底(防止上游短暂不可达)
local stratum 10
# 稳定性优化(非常重要)
makestep 1.0 3
maxupdateskew 100.0
# 日志
logdir /var/log/chrony
prefer:避免选错源
makestep:允许步进,适合 Android
local stratum:防止服务挂死
yxbinghe@yxbinghe
二级服务器
yxbinghe@yxbinghe
server 10.23.116.58 iburst
local stratum 10
allow 本子网
yxbinghe
server 127.127.1.0 mode 10 # 127.127.1.0 是一个特殊的地址,代表本地串行端口
fudge 127.127.1.0 stratum 0 # 将其设为最高优先级(Stratum 0)
system-view
sysname H3C-Switch
# 基础配置
clock timezone Beijing add 08:00:00
ntp-service enable
# 配置NTP服务器
ntp-service unicast-server ntp.aliyun.com
ntp-service unicast-server 120.25.115.20
ntp-service unicast-server 203.107.6.88
#同步时间
clock protocol ntp
# 配置认证(如果需要)
ntp-service authentication enable
ntp-service authentication-keyid 42 md5 YourPassword123
ntp-service reliable authentication-keyid 42
# 配置本地时钟备用
ntp-service refclock-master 8
# 保存配置
save force
yxbinghe@yxbinghe
sysname Core-Center
#
clock timezone Beijing add 08:00:00
clock protocol ntp
#
ntp-service enable
ntp-service server acl 2000
ntp-service peer acl 2000
ntp-service synchronization acl 2000
ntp-service refclock-master 4
ntp-service unicast-server 172.20.42.118 priority
#
acl number 2000
rule 0 permit source 172.20.0.0 0.0.255.255
#
yxbinghe@yxbinghe
system-view
# 开启NTP服务(默认已开启)
ntp-service enable
# 设置时区(中国标准时间)
clock timezone Beijing add 08:00:00
# 配置主NTP服务器
ntp-service unicast-server 192.168.1.100 # 示例IP,替换为实际NTP服务器
ntp-service unicast-server 120.25.115.20 # 阿里云NTP服务器
ntp-service unicast-server ntp.aliyun.com # 域名方式
# 配置备选NTP服务器
ntp-service unicast-server 203.107.6.88 # 阿里云备用NTP
ntp-service unicast-server cn.pool.ntp.org # NTP池服务器
# 可选
# 启用NTP认证
ntp-service authentication enable
## 实例
system-view
sysname H3C-Switch
# 基础配置
clock timezone Beijing add 08:00:00
ntp-service enable
# 配置NTP服务器
ntp-service unicast-server ntp.aliyun.com
ntp-service unicast-server 120.25.115.20
ntp-service unicast-server 203.107.6.88
# 配置认证(如果需要)
ntp-service authentication enable
ntp-service authentication-keyid 42 md5 YourPassword123
ntp-service reliable authentication-keyid 42
# 配置本地时钟备用
ntp-service refclock-master 8
# 保存配置
save force
# 配置密钥
ntp-service authentication-keyid 42 md5 Hello123
# 配置可信密钥
ntp-service reliable authentication-keyid 42
# 为服务器配置认证
ntp-service unicast-server 192.168.1.100 authentication-keyid 42
yxbinghe@yxbinghe
# 查看NTP服务状态
display ntp-service status
# 查看NTP会话
display ntp-service sessions
# 查看NTP服务器列表
display ntp-service peers
# 查看NTP统计信息
display ntp-service statistics
# 查看当前时间
display clock
# 查看NTP详细状态
display ntp-service status verbose
# 查看NTP关联状态
display ntp-service associations
yxbinghe
// 设置中国时区
adb shell setprop persist.sys.timezone Asia/Shanghai
// 设置 NTP 服务器
adb shell settings put global ntp_server 10.23.116.58
//时间同步不生效的话可以先删去原来的ntp服务器
adb shell settings delete global ntp_server
yxbinghe@yxbinghe
am broadcast -a com.android.server.action.NTP_TIME_SYNC –ez force true
或:
settings put global ntp_server 边缘NTPIP
settings put global auto_time 1