当前位置:文档之家› ntp配置步骤

ntp配置步骤

--------------------ntp-4.2.6 on centosx86_64--------------------

1.理论部分

关于权限设定部分; 权限的设定主要以 restrict 这个参数来设定
格式如下:
restrict IP地址 mask 子网掩码 参数;
参数如下:
ignore: 关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时
notrust: 客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery: 不提供客户端的时间查询

注意:如果参数没有设定,那就表示该 IP (或子网)没有任何限制


2.NTP安装:
[root@node01 ~]# rpm -qa|grep ntp
ntpdate-4.2.6p5-1.el6.centos.x86_64
ntp-4.2.6p5-1.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
[root@node01 ~]# cp /etc/ntp.conf /etc/ntp.confbak
[root@node01 ~]# ls /etc/ntp
crypto keys step-tickers
[root@node01 ~]#


3.NTP配置修改:
[root@node01 ~]# iptables -F
[root@node01 ~]# ntpdate 202.120.2.101 && hwclock -w

[root@node01 ~]# cat /etc/ntp.conf|more

默认拒绝NTP客户端所有的操作;并且打开了kod的功能

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

允许本地的所有操作
restrict 127.0.0.1
restrict -6 ::1

添加允许的网段以及子网掩码;这里需要注意两个参数;nomodiy表示客户端不能修改NTP服务器端的参数;notrap表示不提供trap远程登录这选项;noquery表示不提供NTP服务

restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap

配置的是同步服务器上一层的IP地址

server 202.120.2.101 #上海交大时间服务器

server https://www.doczj.com/doc/c216866884.html, iburst
server https://www.doczj.com/doc/c216866884.html, iburst
server https://www.doczj.com/doc/c216866884.html, iburst
server https://www.doczj.com/doc/c216866884.html, iburst

如果不能与上一层的NTP服务器通信的时候,就以本地的时间为准以及指定本地的NTP服务器的层
server 127.127.1.0
fudge 127.127.1.0 stratum 10

设置NTP服务器的日志路径
keys /etc/ntp/keys
logfile /var/log/ntp

[root@node01 ~]# vi /etc/ntp/step-tickers
202.120.2.101
127.127.1.0

[root@node01 ~]# cat /etc/sysconfig/ntpdate
# Options for ntpdate
OPTIONS="-U ntp -s -b"
# Number of retries before giving up
RETRIES=2
# Set to 'yes' to sync hw clock after successful ntpdate
SYNC_HWCLOCK=yes

[root@node01 ~]# service ntpd start


4.测试
[root@node01 ~]# ntpstat
synchronised to NTP server (202.112.31.197) at stratum 3
time correct to within 92 ms
polling server every 64 s
检查NTP服务器与上一层的关系: 1) 是进行校验的的NTP服务器 2) 是本地服务器与上一层服务的时间差 3) 是下次服务器的同步时间

[root@node01 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
https://www.doczj.com/doc/c216866884.html, 202.11

8.1.130 3 u 51 64 377 34.925 37.423 6.175
+https://www.doczj.com/doc/c216866884.html,. 202.118.1.46 2 u 227 64 250 50.426 17.700 134.976
+https://www.doczj.com/doc/c216866884.html, 236.43.203.76 2 u 25 64 377 50.825 37.453 13.889
*https://www.doczj.com/doc/c216866884.html,. 202.118.1.46 2 u 19 64 377 48.017 31.192 6.703
LOCAL(0) .LOCL. 10 l 767 64 0 0.000 0.000 0.000
[root@node01 ~]#

rmote是本地连接和上次对应的关系;refid是上层的服务器;St是NTP的级别;reach是上下的时间差;Jitter是时间的统计值。


5. 问题检查(客户机上): ntpdate –d 10.0.61.240 来检查看是什么错误提示。我们需要注意的是NTP服务器的端口是123

[root@node01 ~]# ntpdate -d 10.0.61.240
28 Jul 14:43:51 ntpdate[1551]: ntpdate 4.2.6p5@1.2349-o Sat Nov 23 18:21:48 UTC 2013 (1)
Looking for host 10.0.61.240 and service ntp
host found : 10.0.61.240
transmit(10.0.61.240)
receive(10.0.61.240)
transmit(10.0.61.240)
receive(10.0.61.240)
transmit(10.0.61.240)
receive(10.0.61.240)
transmit(10.0.61.240)
receive(10.0.61.240)
server 10.0.61.240, port 123
stratum 3, precision -23, leap 00, trust 000
refid [10.0.61.240], delay 0.02565, dispersion 0.00000
transmitted 4, in filter 4
reference time: d961a1c5.f684f73e Tue, Jul 28 2015 14:37:57.962
originate timestamp: d961a327.26067708 Tue, Jul 28 2015 14:43:51.148
transmit timestamp: d961a327.2603cb15 Tue, Jul 28 2015 14:43:51.148
filter delay: 0.02573 0.02567 0.02565 0.02565
0.00000 0.00000 0.00000 0.00000
filter offset: 0.000007 -0.00001 -0.00001 -0.00001
0.000000 0.000000 0.000000 0.000000
delay 0.02565, dispersion 0.00000
offset -0.000011

28 Jul 14:43:51 ntpdate[1551]: adjust time server 10.0.61.240 offset -0.000011 sec



[root@node02 ~]# date -s 20150101
Thu Jan 1 00:00:00 CST 2015

[root@node02 ~]# ntpdate 10.0.61.240 && hwclock -w
28 Jul 14:52:57 ntpdate[2064]: step time server 10.0.61.240 offset 18024748.443505 sec

相关主题
文本预览
相关文档 最新文档