Linux系统下NTP协议的超级配置攻略
程序员文章站
2022-05-09 18:03:05
这篇文章主要介绍了Linux系统下NTP协议的配置,NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议,需要的朋友可以参考下... 15-10-20...
在linux系统中,为了避免主机时间因为在长时间运行下所导致的时间偏差,进行时间同步(synchronize)的工作是非常必要的。linux系统下,一般使用ntp服务来同步不同机器的时间。ntp 是网络时间协议(network time protocol)的简称,干嘛用的呢?就是通过网络协议使计算机之间的时间同步化。
安装ntp包
检查是否安装了ntp相关包。如果没有安装ntp相关包,使用rpm或yum安装,安装也非常简单方便。
[root@localhost ~]# rpm -qa | grep
ntpntpdate-4.2.6p5-1.el6.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntp-4.2.6p5-1.el6.x86_64
ntp的配置
a: 配置/etc/ntp.conf
ntp server的主要配置文件为/etc/ntp.conf ,没有修改过的ntp.conf文件内容如下所示,配置选项都有相关注释信息(linux 版本为red hat enterprise linux server release 6.6 )
[root@localhost ~]# more /etc/ntp.conf
# for more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# permit all access over the loopback interface. this could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# use public servers from the pool.ntp.org project.
# please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# specify the key identifiers which are trusted.
#trustedkey 4 8 42
# specify the key identifier to use with the ntpdc utility.
#requestkey 8
# specify the key identifier to use with the ntpq utility.
#controlkey 8
# enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
[root@localhost ~]# more /etc/ntp.conf
# for more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# permit all access over the loopback interface. this could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# use public servers from the pool.ntp.org project.
# please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# specify the key identifiers which are trusted.
#trustedkey 4 8 42
# specify the key identifier to use with the ntpdc utility.
#requestkey 8
# specify the key identifier to use with the ntpq utility.
#controlkey 8
# enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
各个选项信息:
#系统时间与bios事件的偏差记录
driftfile /etc/ntp/drift
restrict 控制相关权限。
语法为: restrict ip地址 mask 子网掩码 参数
其中ip地址也可以是default ,default 就是指所有的ip
参数有以下几个:
ignore :关闭所有的 ntp 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。
nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
kod : 访问违规时发送 kod 包。
restrict -6 表示ipv6地址的权限设置。
1:设定ntp主机来源(其中prefer表示优先主机),192.168.7.49是本地的ntp服务器,所以优先指定从该主机同步时间。
server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
2:限制你允许的这些服务器的访问类型,在这个例子中的服务器是不容许修改运行时配置或查询您的linux ntp服务器
restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap
在上例中,掩码地址扩展为255,因此从192.168.0.1-192.168.0.254的服务器都可以使用我们的ntp服务器来同步时间
#此时表示限制向从192.168.0.1-192.168.0.254这些ip段的服务器提供ntp服务。
restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap noquery
#设置默认策略为允许任何主机进行时间同步
restrict default ignore
3:确保localhost(这个常用的ip地址用来指linux服务器本身)有足够权限.使用没有任何限制关键词的语法:
restrict 127.0.0.1
restrict -6 ::1
b:配置/etc/ntp/stpe-tickers文件
修改/etc/ntp/stpe-tickers文件,内容如下(当ntpd服务启动时,会自动与该文件中记录的上层ntp服务进行时间校对)
[root@localhost ntp]# more /etc/ntp/step-tickers
# list of servers used for initial synchronization.
[root@localhost ntp]# vi /etc/ntp/step-tickers
# list of servers used for initial synchronization.
server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 3.rhel.pool.ntp.org
c:配置/etc/sysconfig/ntpd文件
ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 sync_hwclock=yes 这样,就可以让硬件时间与系统时间一起同步。
#允许bios与系统时间同步,也可以通过hwclock -w 命令
sync_hwclock=yes
iptables 配置
由于ntp服务需要使用到udp端口号123,所以当系统的防火墙(iptables)启动的情况下,必须开放udp端口号123。
[root@localhost ~]# /etc/init.d/iptables status
table: filter
chain input (policy accept)
num target prot opt source destination
1 accept all -- 0.0.0.0/0 0.0.0.0/0 state related,established
2 accept icmp -- 0.0.0.0/0 0.0.0.0/0
3 accept all -- 0.0.0.0/0 0.0.0.0/0
4 accept tcp -- 0.0.0.0/0 0.0.0.0/0 state new tcp dpt:22
5 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain forward (policy accept)
num target prot opt source destination
1 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain output (policy accept)
num target prot opt source destination
[root@localhost ~]# /sbin/iptables -i input -p udp --dport 123 -j accept
[root@localhost ~]# /etc/init.d/iptables status
table: filter
chain input (policy accept)
num target prot opt source destination
1 accept udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:123
2 accept all -- 0.0.0.0/0 0.0.0.0/0 state related,established
3 accept icmp -- 0.0.0.0/0 0.0.0.0/0
4 accept all -- 0.0.0.0/0 0.0.0.0/0
5 accept tcp -- 0.0.0.0/0 0.0.0.0/0 state new tcp dpt:22
6 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain forward (policy accept)
num target prot opt source destination
1 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain output (policy accept)
num target prot opt source destination
[root@localhost ~]#
如果防火墙没有开放udp端口号123,有可能出现下面情况。
[root@localhost ~]# /usr/sbin/ntpq -c rv | grep stratum
stratum=16, precision=-24, rootdelay=0.000, rootdisp=3.525, refid=init,
[root@localhost~]#
a stratum level of 16 indicates that ntp is not synchronizing correctly.if a stratum level of 16 is detected, wait 15 minutes and issue the command again. it may take this long for the ntp server to stabilize.if ntp continues to detect a stratum level of 16, verify that the ntp port (udp port 123) is open on all firewalls between the cluster and the remote machine you are attempting to synchronize to.
启动ntp服务
[root@localhost ~]# service ntpd status
ntpd is stopped
[root@localhost ~]# service ntpd start
starting ntpd: [ ok ]
[root@localhost ~]#
service ntpd status #查看ntpd服务状态
service ntpd start #启动ntpd服务
service ntpd stop #停止ntpd服务
service ntpd restart #重启ntpd服务
检查ntp服务是否开机启动,将其设置为开机启动。
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# runlevel
n 3
[root@localhost ~]# chkconfig ntpd on #在运行级别2、3、4、5上设置为自动运行
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]#
如果要设置在运行级别上自动运行,可以使用下面命令
chkconfig --level 345 ntpd on
可以用下面命令检测ntp服务是否运行
[root@localhost ~]# pgrep ntpd
2639
2641
[root@localhost ~]# netstat -tlunp | grep ntp #如果看到123端口,说明ntp服务成功启动。
udp 0 0 192.168.7.224:123 0.0.0.0:* 2639/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2639/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2639/ntpd
udp 0 0 fe80::250:56ff:feb3:b5:123 :::* 2639/ntpd
udp 0 0 ::1:123 :::* 2639/ntpd
udp 0 0 :::123 :::* 2639/ntpd
[root@localhost ~]#
查看ntp服务器有无和上层ntp连通
[root@localhost ~]# ntpstat
synchronised to ntp server (192.168.7.49) at stratum 6
time correct to within 440 ms
polling server every 128 s
[root@localhost ~]#
查看ntp服务器与上层ntp的状态
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
要查看 ntpd 进程的状态,请运行以下命令,按 ctrl+c 停止查看进程。
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
要查看 ntpd 进程的状态,请运行以下命令,按 ctrl+c 停止查看进程。
安装ntp包
检查是否安装了ntp相关包。如果没有安装ntp相关包,使用rpm或yum安装,安装也非常简单方便。
复制代码
代码如下:[root@localhost ~]# rpm -qa | grep
ntpntpdate-4.2.6p5-1.el6.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntp-4.2.6p5-1.el6.x86_64
ntp的配置
a: 配置/etc/ntp.conf
ntp server的主要配置文件为/etc/ntp.conf ,没有修改过的ntp.conf文件内容如下所示,配置选项都有相关注释信息(linux 版本为red hat enterprise linux server release 6.6 )
复制代码
代码如下:[root@localhost ~]# more /etc/ntp.conf
# for more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# permit all access over the loopback interface. this could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# use public servers from the pool.ntp.org project.
# please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# specify the key identifiers which are trusted.
#trustedkey 4 8 42
# specify the key identifier to use with the ntpdc utility.
#requestkey 8
# specify the key identifier to use with the ntpq utility.
#controlkey 8
# enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
[root@localhost ~]# more /etc/ntp.conf
# for more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# permit all access over the loopback interface. this could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# use public servers from the pool.ntp.org project.
# please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# specify the key identifiers which are trusted.
#trustedkey 4 8 42
# specify the key identifier to use with the ntpdc utility.
#requestkey 8
# specify the key identifier to use with the ntpq utility.
#controlkey 8
# enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
各个选项信息:
#系统时间与bios事件的偏差记录
driftfile /etc/ntp/drift
restrict 控制相关权限。
语法为: restrict ip地址 mask 子网掩码 参数
其中ip地址也可以是default ,default 就是指所有的ip
参数有以下几个:
ignore :关闭所有的 ntp 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。
nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
kod : 访问违规时发送 kod 包。
restrict -6 表示ipv6地址的权限设置。
1:设定ntp主机来源(其中prefer表示优先主机),192.168.7.49是本地的ntp服务器,所以优先指定从该主机同步时间。
复制代码
代码如下:server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
2:限制你允许的这些服务器的访问类型,在这个例子中的服务器是不容许修改运行时配置或查询您的linux ntp服务器
复制代码
代码如下:restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap
在上例中,掩码地址扩展为255,因此从192.168.0.1-192.168.0.254的服务器都可以使用我们的ntp服务器来同步时间
复制代码
代码如下:#此时表示限制向从192.168.0.1-192.168.0.254这些ip段的服务器提供ntp服务。
restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap noquery
#设置默认策略为允许任何主机进行时间同步
restrict default ignore
3:确保localhost(这个常用的ip地址用来指linux服务器本身)有足够权限.使用没有任何限制关键词的语法:
复制代码
代码如下:restrict 127.0.0.1
restrict -6 ::1
b:配置/etc/ntp/stpe-tickers文件
修改/etc/ntp/stpe-tickers文件,内容如下(当ntpd服务启动时,会自动与该文件中记录的上层ntp服务进行时间校对)
复制代码
代码如下:[root@localhost ntp]# more /etc/ntp/step-tickers
# list of servers used for initial synchronization.
[root@localhost ntp]# vi /etc/ntp/step-tickers
# list of servers used for initial synchronization.
server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 3.rhel.pool.ntp.org
c:配置/etc/sysconfig/ntpd文件
ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 sync_hwclock=yes 这样,就可以让硬件时间与系统时间一起同步。
复制代码
代码如下:#允许bios与系统时间同步,也可以通过hwclock -w 命令
sync_hwclock=yes
iptables 配置
由于ntp服务需要使用到udp端口号123,所以当系统的防火墙(iptables)启动的情况下,必须开放udp端口号123。
复制代码
代码如下:[root@localhost ~]# /etc/init.d/iptables status
table: filter
chain input (policy accept)
num target prot opt source destination
1 accept all -- 0.0.0.0/0 0.0.0.0/0 state related,established
2 accept icmp -- 0.0.0.0/0 0.0.0.0/0
3 accept all -- 0.0.0.0/0 0.0.0.0/0
4 accept tcp -- 0.0.0.0/0 0.0.0.0/0 state new tcp dpt:22
5 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain forward (policy accept)
num target prot opt source destination
1 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain output (policy accept)
num target prot opt source destination
[root@localhost ~]# /sbin/iptables -i input -p udp --dport 123 -j accept
[root@localhost ~]# /etc/init.d/iptables status
table: filter
chain input (policy accept)
num target prot opt source destination
1 accept udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:123
2 accept all -- 0.0.0.0/0 0.0.0.0/0 state related,established
3 accept icmp -- 0.0.0.0/0 0.0.0.0/0
4 accept all -- 0.0.0.0/0 0.0.0.0/0
5 accept tcp -- 0.0.0.0/0 0.0.0.0/0 state new tcp dpt:22
6 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain forward (policy accept)
num target prot opt source destination
1 reject all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
chain output (policy accept)
num target prot opt source destination
[root@localhost ~]#
如果防火墙没有开放udp端口号123,有可能出现下面情况。
复制代码
代码如下:[root@localhost ~]# /usr/sbin/ntpq -c rv | grep stratum
stratum=16, precision=-24, rootdelay=0.000, rootdisp=3.525, refid=init,
[root@localhost~]#
a stratum level of 16 indicates that ntp is not synchronizing correctly.if a stratum level of 16 is detected, wait 15 minutes and issue the command again. it may take this long for the ntp server to stabilize.if ntp continues to detect a stratum level of 16, verify that the ntp port (udp port 123) is open on all firewalls between the cluster and the remote machine you are attempting to synchronize to.
启动ntp服务
复制代码
代码如下:[root@localhost ~]# service ntpd status
ntpd is stopped
[root@localhost ~]# service ntpd start
starting ntpd: [ ok ]
[root@localhost ~]#
service ntpd status #查看ntpd服务状态
service ntpd start #启动ntpd服务
service ntpd stop #停止ntpd服务
service ntpd restart #重启ntpd服务
检查ntp服务是否开机启动,将其设置为开机启动。
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# runlevel
n 3
[root@localhost ~]# chkconfig ntpd on #在运行级别2、3、4、5上设置为自动运行
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]#
如果要设置在运行级别上自动运行,可以使用下面命令
复制代码
代码如下:chkconfig --level 345 ntpd on
可以用下面命令检测ntp服务是否运行
复制代码
代码如下:[root@localhost ~]# pgrep ntpd
2639
2641
[root@localhost ~]# netstat -tlunp | grep ntp #如果看到123端口,说明ntp服务成功启动。
udp 0 0 192.168.7.224:123 0.0.0.0:* 2639/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2639/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2639/ntpd
udp 0 0 fe80::250:56ff:feb3:b5:123 :::* 2639/ntpd
udp 0 0 ::1:123 :::* 2639/ntpd
udp 0 0 :::123 :::* 2639/ntpd
[root@localhost ~]#
查看ntp服务器有无和上层ntp连通
复制代码
代码如下:[root@localhost ~]# ntpstat
synchronised to ntp server (192.168.7.49) at stratum 6
time correct to within 440 ms
polling server every 128 s
[root@localhost ~]#
查看ntp服务器与上层ntp的状态
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
要查看 ntpd 进程的状态,请运行以下命令,按 ctrl+c 停止查看进程。
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过时间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
要查看 ntpd 进程的状态,请运行以下命令,按 ctrl+c 停止查看进程。
上一篇: 蔡文姬一生三嫁,她的命运充满坎坷
下一篇: Ubuntu 下安装和配置 FTP服务器