CentOS中NTP服务器的搭建
|
4.手工校正当前时间 当系统时间与标准时间相差太大时,NTP 通常无法正常同步时间,因此我们一般要手工先对当前时间进行调整 两个对时服务器都可以用,随便挑一个就行 # ntpdate 2.cn.pool.ntp.org 31 Oct 09:14:18 ntpdate[22563]: step time server 218.75.4.130 offset -1.830097 sec 调整好后,用 date 命令检查一下,时间是否正确了 # date Thu Oct 31 09:14:50 CST 2013 如果时间还是不对,建议用 date 命令手工调整一下,我在实验过程中没有遇到过,但有的网友说会说现这种情况 设置 NTP 的配置文件 NTP 服务器说白了,就是起一个承上启下的作用,寻找上层服务器获取正确的时间,同时为下层服务器提供网络对时服务,所以对它的设置,也主要由两方面组成 1.指定上层对时服务器 加#号注释掉centos默认的对时服务器,如果主机可以访问外网,这一步最好做一下. 添加我们刚才测试的国家对时服务器. prefer 表示优先使用 # vim /etc/ntp.conf # 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 server 1.cn.pool.ntp.org server 2.cn.pool.ntp.org prefer 2.设置对内网主机提供NTP服务 在我的实验环境中,内网使用 192.168.80.0/24 网段 # 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 restrict 192.168.80.0 mask 255.255.255.0 nomodify notrap 几点说明: restrict default kod nomodify notrap nopeer noquery kod kod技术可以阻止 "Kiss of Death"包(一种DOS攻击)对服务器的破坏 nomodify 用户端不能更改NTP服务端的时间参数,但可以通过NTP服务端进行时间校对 notrap 不提供trap 远程事件登录功能 nopeer 不与其它同一层的NTP服务器进行时间同步 noquery 不提供NTP服务 restrict 还可以使用的其它参数 ignore 关闭所有NTP服务 notrust 拒绝没有通过认证的客户端 restrict 127.0.0.1默认对本机无限制 restrict 192.168.80.0 mask 255.255.255.0 nomodify notrap这是我添加的,允许192.168.80.0/24 网段的主机来进行时间校对,但不允许客户端来修改,登录我的NTP服务器 (编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

