NTP 是网络时间协议(Network Time Protocol),它用来同步网络设备的时间的协议。
配置时间服务器
配置文件为/etc/ntp.conf,使用编辑器工具打开后,修改server字段。
# This is the most basic ntp configuration file
# The driftfile must remain in a place specific to this
# machine - it records the machine specific clock error
driftfile /var/lib/ntp/drift
# This should be a server that is close (in IP terms)
# to the machine. Add other servers as required.
# Unless you un-comment the line below ntpd will sync
# only against the local system clock.
#
# server time.server.example.com
#
# Using local hardware clock as fallback
# Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself
server cn.ntp.org.cn
server 127.127.1.0
fudge 127.127.1.0 stratum 14
# Defining a default security setting
restrict -4 default notrap nomodify nopeer noquery
restrict -6 default notrap nomodify nopeer noquery
restrict 127.0.0.1 # allow local host
restrict ::1 # allow local host
第14行是增加的时间服务器,可以填写域名或IP地址。
修改后,启动NTP服务
systemctl start ntpd
启用开机自动启动服务
systemctl enable ntpd
作者:SteveChen 创建时间:2024-09-17 14:54
最后编辑:SteveChen 更新时间:2024-09-17 15:25
最后编辑:SteveChen 更新时间:2024-09-17 15:25