NTP 服务器搭建

本博客基于centos7

NTP 服务唯一的config file /etc/ntp.conf
要关注的一些配置项如下:
driftfile /var/lib/ntp/drift
该文件记录上游NTP server和本地的时间偏差。

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
该配置说明192.168.1.0网段机器可以访问该服务
nomodify client不可以更改server时间

server 127.127.1.0
fudge 127.127.1.0 stratum 10
server 后面跟主机名或者ip。定义上游NTP服务器地址。 要注意如果想用localhost作为上游服务器,需使用127.127.1.0 不能用127.0.0.1

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.          10 l   26   64  377    0.000    0.000   0.000
上面的命令查询该server与上层服务器通信状况。
when 为 -表示没有通信



ntpdate 192.168.1.99
上面的命令是ntp client访问192.168.1.99这个ntp服务器 来更新自己的时间。




date命令可以更改系统时间
hwclock可以把更改后的系统时间同步到BIOS

原文地址:https://www.cnblogs.com/kramer/p/4310383.html