首页 > 编程知识 正文

ntp服务器搭建,内网ntp服务器搭建

时间:2023-05-05 13:58:24 阅读:235707 作者:245

ntp服务器服务端配置文件和客户端配置文件都为 /etc/ntp.conf

1、配置服务端

vim /etc/ntp.conf

#选择自己为默认的时间源

restrict default nomodify

#选择自己的本地接口

restrict 127.0.0.1

#主板提供时间的晶震芯片

server 127.127.1.0

#晶振提供时间的精度,数字越大越不精确

fudge 127.127.1.0 stratum 10

#偏移记录

driftfile /var/lib/ntp/drift

#时间延迟

broadcastdelay 0.008

2、开启ntpd服务

service ntpd restart

查看时间是否同步,通常需要等待5分钟后在Local前面出现*才说明时间同步完成

ntpq

ntpq>peer

3、设置客户端同步

停止时间服务

service ntpd stop

向指定的服务器同步时间

ntpdate -b 192.168.261.102

写入任务计划

crontab -e

*/5 * * * * /usr/sbin/ntpdate 192.168.216.102

如果客户端提示 no server suitable for synchronization found

可以在服务器上将stratum 10删除

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。