搭建ntp服务器

Posted 头痛不头痛

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了搭建ntp服务器相关的知识,希望对你有一定的参考价值。

1.同步网络时间

  先关闭掉ntp服务,使用ntpd同步网络时间。

/etc/init.d/ntpd stop

ntpdate 2.hk.pool.ntp.org

网络时间可以从http://www.pool.ntp.org中获取离自己最近的区域,我这里选的香港

2. 配置/etc/ntp.conf

 更改server

server 2.hk.pool.ntp.org
server 0.asia.pool.ntp.org
server 3.asia.pool.ntp.org

 设置权限:

参数有以下几个:

ignore  :关闭所有的 NTP 联机服务

nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。

notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网

noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器

notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。

 

restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict 192.168.0.0 mask 255.255.255.0 nomodify
3. 开放端口123
iptables -A INPUT -p udp --dport 123 -j ACCEPT
/etc/init.d/iptables save
 
4. 客户端设施 

我们在客户机上同步刚才搭建的时间服务器了,192.168.0.80就是我刚搭建的。

server 192.168.0.80 prefer
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst

 查看效果

 

 

 

 

以上是关于搭建ntp服务器的主要内容,如果未能解决你的问题,请参考以下文章

ntp 服务器搭建

CentOS搭建NTP服务器

如何在CentOS中搭建NTP服务器

002.NTP服务端搭建

搭建NTP服务器

NTP服务器的搭建和时间同步