您的位置:首页 > 编程语言 > PHP开发

NTP的服务配置总结

2013-12-26 00:39 309 查看
NTP:时间同步服务 基于服务器/客户端模式
1.server: ip地址:192.168.10.254/242.client: ip地址:192.168.10.10/243.实验的目的:客户端的时间有时候会不准,每回都需要管理员手动的区更新时间,非常的繁琐,不便 于管理,但是局域网中的一台叫server的服务器的时间是准确的。因此我们想要局域网中的这台主机能够自动的在时间不准的情况下能同步这台服务器上的时间,那么如何实现呢?4.实验具体的做法: 1.使用ntp这个服务:首先NTP默认情况下在Linux中是开启的,也就是它默认情况下是在后台运行的。所以不需要安装ntp软件包。2.对ntp的配置文件进行修改:/etc/ntpd.conf 3.vim /etc/ntp.conf restrict default kod nomodify notrap nopeer noqueryrestrict 192.168.10.0 mask 255.255.255.0 nomodify notrap 关键的一行server192.168.146.225
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
第一行restrict、default定义默认访问规则,nomodify禁止远程主机修改本地服务器置,notrap拒绝 特殊的ntpdq捕获消息,noquery拒绝btodq/ntpdc查询(这里的查询是服务器本身状态查询)。 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
这句是手动增加的,意思是从192.168.1.1-192.168.1.254的服务器都可以使用我们的NTP服务器来同步时间。server 192.168.146.225
这句也是手动增加的,指明局域网中作为NTP服务器的IP;配置文件的最后两行作用是当服务器与公用的时间服务器失去联系时以本地时间为客户端提供时间服务。
端口
ntp使用udp协议,记得开放其123端口。
启动NTPD为了使NTP服务可以在系统引导的时候自动启动,执行:
#chkconfig ntpd on
启动ntpd:
service ntpd start注意:ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server suitable for synchronization found”错误。
client需要做的事情: 1.确保能与服务器连同 2.确保ntp的服务是开启的 3.同步时间:ntpdate 192.168.10.254(服务器ip地址错误提示:zhe NTP socket is use,exting; 解析:这句话的意识就是说,当前系统中已经存在ntp运行了。解决方法:暂停ntp服务,然后重新开启即可1 service ntpd stop service ntpd restart2.如果不行的话就用绝对路径:/etc/rc.d、init.d/ntpd stop 然后再重新开启NTP服务即可。

estrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 restrict -6 ::1

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 192.168.146.225
server 0.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org

server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10estrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 restrict -6 ::1

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 192.168.146.225
server 0.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org

server 127.127.1.0 # local clock fudge 127.127.1添加一行:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: