使用虚拟机Linux系统搭建NTP服务器,时间同步失败,请求指导!
目前使用宿主机(WIN7系统)与虚拟机的NTP服务器同步时间,提示windows在与10.2.2.199进行同步时出错,无法连接到对等机。
下面开始描述环境和配置:
宿主机ip:10.2.1.20/21,
虚拟机ip:10.2.2.199/21(单网卡,桥接),
网关10.2.1.1
相互可以ping通。
NTP版本:
[root@localhost ~]# rpm -qa | grep ntp ntpdate-4.2.4p8-2.el6.centos.i686 fontpackages-filesystem-1.41-1.1.el6.noarch ntp-4.2.4p8-2.el6.centos.i686
ntp.conf的配置 (虚拟机不能直接连接公网)
[root@localhost ~]# cat /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 default nomodify #restrict -6 default kod nomodify notrap nopeer noquery #restrict 10.2.0.0 mask 255.255.0.0 nomodify restrict default nomodify notrap noquery restrict 10.2.0.0 mask 255.255.0.0 notrust nomodify notrap # 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.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org server pool.ntp.org #server 127.0.0.1 #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 # Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 # 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 logfile /var/log/ntp/ntp.log
执行ntpstat结果
[root@localhost ~]# ntpstat synchronised to local net at stratum 11 time correct to within 11 ms polling server every 1024 s
执行ntpq -p结果
[root@localhost ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *LOCAL(0) .LOCL. 10 l 25 64 377 0.000 0.000 0.000
解决方案:
首先 你的虚拟机要与宿主机同步时间的话,最重要的一条配置 没有配 server 10.2.1.20
配置后重启ntp服务,10分钟后查看ntpq -p 结果中 10.2.1.20有无*号
其次,有一点可能我也不太清楚,接触过的环境一般ntp server 和ntp client 都是linux
没有设置过 ntp server 是windows的情况,不知道windows通过什么提供ntp服务
谢谢赞赏
(微信扫一扫或长按识别)