【原创】Linux中配置NTP时间服务器
1、配置 /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).
#记录上次的NTP server与上层NTP server联接所花费的时间
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 #允许192.168.1.0/254子网内主机时间同步
restrict default nomodify notrap #设置默认策略为允许任何主机进行时间同步
#restrict 192.168.0.207 mask 255.255.255.0 nomodify notrap #只允许192.168.0.207主机时间同步
#设置此服务器同上层服务器做时间同步的IP地址
# 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
#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 8
# 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
2、NTP server的维护
❤ 添加为服务
chkconfig --level 345 ntpd on
❤ 启动
service ntpd start
或
/etc/rc.d/init.d/ntpd start
❤ 停止
service ntpd stop
或
/etc/rc.d/init.d/ntpd stop
❤ 管理命令
ntpq –p #查看本机和上层服务器的时间同步结果
ntptrace #可以用來追踪某台时间服务器的时间对应关系
ntpdate IP #客户端要和NTP server进行时钟同步
cat /var/log/ntp/ntp.log #查看ntp日志

转载请注明:文章转载自:桐星豆 [https://txdou.com]
本文标题:【原创】Linux中配置NTP时间服务器
本文地址:http://txdou.com/article93


- 注意:“桐星豆”只会以“回复”的身份出现,不会以“咨询”的身份出现在留言或评论中,凡是以“咨询”的身份出现的留言或评论均为他人盗用!
- 本站用以回复网友评论的唯一名称是“桐星豆”,除此外均无效,网友不得用此名进行相应文章的评论或回复!
- 用户言论只代表其个人观点,不代表桐星豆的观点或立场!
- 非诚勿扰,请友好如实的评论,杜绝谩骂、人格攻击等一切伤人言论,请严格遵循中华人民共和国法律法规!
- 桐星豆拥有最终解释权,如有网友违规,本站将有权删除或屏蔽违规评论,情节严重者账户加入黑名单、永久封IP并报司法部门严惩!
- 您一旦参与评论本站则默认为您已经同意以上条款,否则“非诚勿扰”,谢谢合作!