cisco路由器ntp服务器配置方法哪个晓得

cisco路由器ntp服务器配置方法哪个晓得,第1张

NTP(Network Time Protocol,网络时间协议)是基于RFC1305的协议,是一个跨越广域网或局域网的复杂的同步时间协议。一般情况下建议配置在路由器上,当然配置在其它设备上都是可以的。接下来我们根据下面的拓扑图来看一下在路由器上配置NTP服务器的方法以及交换机、windows服务器、Linux服务器如何设置NTP客户端。拓扑如下:
路由器NTPserver上配置如下:
R1>en
R1#conf t
Enter configuration commands, one per line End with CNTL/Z
R1(config)#hostname NTPserver
NTPserver(config)#no ip do lo
NTPserver(config)#line con 0
NTPserver(config-line)#exec-t 0 0
NTPserver(config-line)#logg syn
NTPserver(config-line)#exit
NTPserver(config)#int e0/1
NTPserver(config-if)#int e0/0
NTPserver(config-if)#exi
NTPserver(config)#int e0/0
NTPserver(config-if)#ip ad 19216811 2552552550
NTPserver(config-if)#no shut
NTPserver(config-if)#
Mar 1 00:02:39959: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
Mar 1 00:02:40959: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
NTPserver(config-if)#clock time
NTPserver(config-if)#do wr
Building configuration
[OK]
NTPserver(config-if)#exit
NTPserver(config)#cloc
NTPserver(config)#clock time
NTPserver(config)#clock timezone peking +8
NTPserver(config)#
Mar 1 00:03:27019: %SYS-6-CLOCKUPDATE: System clock has been updated from 00:03:27 UTC Fri Mar 1 2002 to 08:03:27 peking Fri Mar 1 2002, configured from console by console
NTPserver(config)#exit
NTPserver#
Mar 1 00:04:02975: %SYS-5-CONFIG_I: Configured from console by console
NTPserver#cloc
NTPserver#clock set 12:02:20 6 Aug 2012
NTPserver#
Aug 6 04:02:20003: %SYS-6-CLOCKUPDATE: System clock has been updated from 08:04:45 peking Fri Mar 1 2002 to 12:02:20 peking Mon Aug 6 2012, configured from console by console
NTPserver#conf t
Enter configuration commands, one per line End with CNTL/Z
NTPserver(config)#ntp master

一、搭建时间服务器
1、在一台linux服务器安装ntp server
tar zxvf ntp-426targz
cd ntp-426
/configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
2、修改ntpconf配置文件
vi /etc/ntpconf
# 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 default nomodify
(允许任何IP的客户机都可以进行时间同步,如果是只允许某个网段的客户机进行时间同步可以这样写
restrict 1058260 mask 2552552550 nomodify)
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 127001
restrict -6 ::1
# Hosts on local network are less restricted
#restrict 19216810 mask 2552552550 nomodify notrap
# Use public servers from the poolntporg project
# Please consider joining the pool
#server 0rhelpoolntporg(默认时间服务器)
#server 1rhelpoolntporg(默认时间服务器)
#server 2rhelpoolntporg(默认时间服务器)
server 101281425 (手工设置的时间服务器)
(如果是可以直连外网,可以使用LINUX默认提供的三组标准时间服务器,否则可以自己指定一个同步时间源)
#broadcast 1921681255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224011 key 42 # multicast server
#multicastclient 224011 # multicast client
#manycastserver 239255254254 # manycast server
#manycastclient 239255254254 key 42 # manycast client
# Undisciplined Local Clock This is a fake driver intended for backup
# and when no outside source of synchronized time is available
server 12712710 # local clock
fudge 12712710 stratum 10
3、以守护进程启动ntpd
#/etc/rcd/initd/ntpd -c /etc/ntpconf -p /tmp/ntpdpid
#/etc/rcd/initd/ntpd start
#ps -ef|grep ntpd
4、在ntp server上启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令进行同步时会产生no server suitable for synchronization found的错误。
下面命令可以知道何时ntp server完成了和自身同步的过程
在ntp server上使用命令:
# watch ntpq -p
注意LOCAL的这个就是与自身同步的ntp server。
注意reach这个值,在启动ntp server服务后,这个值就从0开始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒5=320秒的时间。
二、配置时间同步客户机
vi /var/spool/cron/root(或crontab -e)
增加一行,在每天的1点10分、9点10分、17点10分与时间同步服务器进行同步并写入BIOS
10 1 ,9,17 root /usr/sbin/ntpdate 101281425; /sbin/hwclock -w
如果同步不正常,可以加输出日志或看系统日志
输出日志的方法:
10 1 ,9,17 root /usr/sbin/ntpdate 101281425>>/tmp/1txt; /sbin/hwclock -w
在1txt中可查看时间同步时的输出结果。
或者看/var/mail/root系统日志
Subject: Cron <root@tyzssq8> /usr/sbin/ntpdate 101281425;/sbin/hwclock -w
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20121127103001076FF2090E@tyzssq8site>
Date: Tue, 27 Nov 2012 18:30:01 +0800 (CST)
27 Nov 18:29:59 ntpdate[6917]: step time server 101281425 offset -1361968 sec
可以看到同步成功了,如果未成功会报出错误。
三、无法同步的问题
检查ntp server主机的防火墙。可能是ntp server的防火墙屏蔽了upd 123端口。
可以用命令
#service iptables stop

NTP时间同步服务器是针对计算机、自动化装置等进行校时而研发的高科技产品。NTP时间同步服务器从GPS卫星上获取标准的时间信号,将这些信号通过各种接口传输给自动化系统中需要时间信息的设备。

NTP服务工作模式为三种,即客户/服务器模式、广播模式和对称模块。在客户端/服务器模式下,客户端以周期性地发送NTP数据包,根据标记直观查看工作状态、事件结果等并及时反馈。

NTP时钟同步服务器利用卫星通信功能,可以构建中心主站系统对各厂站时间同步系统的集中监测和远程维护,提高设备的运行可靠性。NTP时钟同步服务器采用SMT表面贴装技术生产,以高速芯片进行控制,无硬盘和风扇设计,精度高、稳定性好、功能强、无积累误差、不受地域气候等环境条件限制、性价比高、 *** 作简单、全自动智能化运行,免 *** 作维护,适合无人值守。

redhat版本不同ntp的版本可能也会有所变化,在安装之前需要查找ntp服务,看下是否存在:
yum search ntp
2
查找到ntpx86_64,使用yum进行安装。安装时x64_64可以不输入。
yum install -y ntp
-y:不提示,直接安装
3
进入ntp配置目录:
vi /etc/ntpconf
4
进入ntpconf配置文件,注释以server开头的配置,并添加内容:server 12712711
添加完成保存退出。
5
重启ntp服务器,并查看状态是否running。
systemctl restart ntpdservice #重启服务
systemctl status ntpdservice #查看状态
6
查看ntp服务是否能够被同步,显示为“LOCAL”,表示成功。如果没有任何显示,客户端将无法同步。
END
步骤2(Client):
1
服务器已经配置完成,现在是Client配置,测试Client能否与Server相连。
2
在Clientt上使用ntpdate来同步:ntpdate 1921681162
同步后反馈是是成功同步的。
END
注意事项
时间上不能相差过远


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/13485201.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-16
下一篇 2023-08-16

发表评论

登录后才能评论

评论列表(0条)

保存