linux做ntp服务器,CentOS Linux搭建NTP时间服务器

CentOS系统已经自带ntpd,不需要安装。

修改配置文件/etc/ntp.conf

时间同步服务器server 0.pool.ntp.org iburst

server 1.pool.ntp.org iburst

server 2.pool.ntp.org iburst

server 3.pool.ntp.org iburst

推荐使用iburst选项,如果第一次尝试无法建立连接,程序会发送一系列的包。burst选项则总是发送一系列的包,即使第一次也是这样。如果没有明确的允许的话不要使用 burst选项,有可能会被封禁。

如果建立一个NTP服务器,你需要添加本地时钟作为一个服务器,这样即便失去网络连接,也可以继续为网络提供服务;添加本地时钟作为一个stratum 10服务器(使用 fudge 命令)这样就只会在失去网络连接时使用本地时钟。server 127.127.1.0

fudge  127.127.1.0 stratum 10

定义规则允许客户端连接你的服务(localhost 也被认为是一个客户端),使用restrict参数restrict default kod nomodify notrap nopeer noquery

nomodify防止重新配置ntpd,noquery防止从nptd获取状态数据,noserve用于停止提供时间服务

如果你想要强制DNS解析到IPv6域名,在IP地址或域名前写上-6(-4则强制使用IPv4域名)restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

指定drift文件(它能时刻监控时间漂移)和log文件的位置driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntp.log

一份基础的配置文件是这样的server 0.pool.ntp.org iburst

server 1.pool.ntp.org iburst

server 2.pool.ntp.org iburst

server 3.pool.ntp.org iburst

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntp.log

查看同步的状态ntpq -p

delay、offset和jitter不应该为零,ntpd同步的服务器前有星号,ntpd可能等待很久才会进行同步,请等 17 分钟(1024秒)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值