简介
本文档介绍如何对Cisco DNA Center (DNAC)上的网络时间协议(NTP)问题进行故障排除。
先决条件
要求
使用的组件
本文档中的信息基于以下软件版本:
- 思科DNA Center 2.3.3
- 思科DNA Center 2.3.5
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
背景信息
时间同步对于数据准确性和协调多主机群集中的处理至关重要。在生产环境中部署设备之前,请确保设备系统时钟上的时间为当前时间,并且您指定的NTP服务器保留准确时间。如果计划将设备与ISE集成,还必须确保ISE与设备相同的NTP服务器进行同步。
对于生产部署,建议至少配置三台NTP服务器。
NTP版本4使用UDP端口123与DNAC进行双向通信。
在CIMC上验证到NTP
第1步-使用您在启用对Cisco集成管理控制器的浏览器访问中设置的思科IMC IP地址、用户ID和密码登录设备思科IMC。
第2步-将设备硬件与用于管理网络的网络时间协议(NTP)服务器同步,如下所示:
- 从思科IMC GUI的左上角,点击切换导航图标。
- 从思科IMC菜单中,选择 > ,然后选择设置选项卡。
- 确保选中NTP Enabled复选框,并在编号的服务器字段中输入最多四个NTP服务器主机名或地址。
- 思科IMC验证您的条目,然后开始将设备硬件上的时间与NTP服务器上的时间同步。
CIMC NTP配置页面
查看DNAC上的NTP配置
- 检查DNAC中配置的NTP服务,确认NTP有服务器的*信息
maglev@maglev-master:~$ ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp.server.local .GNSS. 2 u 823 1024 0 0.263 0.144 0.000
10.81.254.131 .GNSS. 1 u 835 1024 377 72.324 0.382 0.087
- 使用timedatetctl命令确认System clock synchronized是否同步。
maglev@maglev-master:~$ timedatectl status
Local time: Thu 2023-09-28 20:27:13 UTC
Universal time: Thu 2023-09-28 20:27:13 UTC
RTC time: Thu 2023-09-28 20:27:13
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
systemd-timesyncd.service active: no
RTC in local TZ: no
- 检查ntp.conf文件上的NTP服务器配置是否正确。
maglev@maglev-master:~$ cat /etc/ntp.conf
#---------------------------------------------------------------------
# Modified by Maglev: Mon, 25 Sep 2023 21:04:04 UTC
# maglev-config 68913
#---------------------------------------------------------------------
tinker panic 0
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 10.81.254.131 iburst
server ntp.server.local iburst
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1
interface ignore 0.0.0.0
interface listen enterprise
interface listen management
interface listen internet
interface listen cluster
验证DNAC上的NTP
- 使用FQDN配置NTP时,请验证DNAC可以解析A和PTR记录。
maglev@maglev-master:~$ nslookup
>set type=A
> ntp.server.local
Server: 10.0.0.53
Address: 10.0.0.53#53
Non-authoritative answer:
Name: ntp.server.local
Address: 10.81.254.202
>set type=PTR
> 10.81.254.202
Server: 10.0.0.53
Address: 10.0.0.53#53
10.254.81.10.in-addr.arpa name = ntp.server.local.
maglev@maglev-master:~$ ping ntp.server.local
PING ntp.server.local (10.81.254.202) 56(84) bytes of data.
64 bytes from ntp.server.local (10.81.254.202): icmp_seq=1 ttl=53 time=72.8 ms
64 bytes from ntp.server.local (10.81.254.202): icmp_seq=2 ttl=53 time=71.9 ms
64 bytes from ntp.server.local (10.81.254.202): icmp_seq=3 ttl=53 time=72.0 ms
^C
--- ntp.server.local ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 72.506/72.634/72.853/0.269 m
maglev@maglev-master:~$ nc -zvu ntp.server.local 123
Connection to ntp.server.local 123 port [udp/ntp] succeeded!
- 捕获数据包,并确认NTP通信使用相同版本的NTPv4。
maglev@maglev-master:~$ sudo tcpdump -i any host ntp.server.local and port 123 --immediate-mode
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
20:19:23.967314 IP flink-web.ndp.svc.cluster.local.ntp > ntp.server.local.ntp: NTPv4, Client, length 48
20:19:23.967329 IP flink-web.ndp.svc.cluster.local.ntp > ntp.server.local.ntp: NTPv4, Client, length 48
20:19:24.040064 IP ntp.server.local.ntp > flink-web.ndp.svc.cluster.local.ntp: NTPv4, Server, length 48
20:19:24.040064 IP ntp.server.local.ntp > flink-web.ndp.svc.cluster.local.ntp: NTPv4, Server, length 48
maglev@maglev-master:~$ systemctl status ntp
* ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-09-28 20:19:20 UTC; 22min ago
Docs: man:ntpd(8)
Process: 31746 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
Main PID: 31781 (ntpd)
Tasks: 2 (limit: 13516)
CGroup: /system.slice/ntp.service
`-31781 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 107:111
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: restrict ::: KOD does nothing without LIMITED.
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen and drop on 0 v6wildcard [::]:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 1 lo 127.0.0.1:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 2 management 10.88.244.151:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 3 enterprise 192.168.31.2:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 4 lo [::1]:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 5 management [fe80::be26:c7ff:fe0c:82e6%5447]:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 6 enterprise [fe80::b28b:cfff:fe6a:9e1c%5449]:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listen normally on 7 cluster [fe80::b28b:cfff:fe6a:9e1d%5450]:123
Sep 28 20:19:20 maglev-master-10-88-244-151 ntpd[31781]: Listening on routing socket on fd #24 for interface updates
注意:如果需要,您可以使用命令sudo systemctl restart ntp重新启动NTP服务。 这没有任何影响。
排除DNAC上的NTP故障
- 查看maglev_config_wizard.log文件。
- 下一节节显示DNAC与NTP服务器进行通信和同步。
maglev@maglev-master:~$ cat /var/log/maglev_config_wizard.log | grep -i ntp
| 2023-09-28 00:47:32,790 | DEBUG | 25344 | MainThread | 140017254479680 | root | ansible.py:495 | changed: [localhost] => {"changed": true, "cmd": "/opt/maglev/bin/check_ntp.sh 500 299", "delta": "0:00:00.018699", "end": "2023-09-28 00:47:32.764617", "rc": 0, "start": "2023-09-28 00:47:32.745918", "stderr": "", "stderr_lines": [], "stdout": "PASSED", "stdout_lines": ["PASSED"]}
| 2023-09-28 00:47:33,068 | DEBUG | 25344 | MainThread | 140017254479680 | root | ansible.py:495 | ok: [localhost] => {"ansible_facts": {"ntp_sync_check": "PASSED"}, "changed": false}
"msg": "Check NTP limit PASSED"
changed: [localhost] => {"changed": true, "cmd": "/opt/maglev/bin/check_ntp.sh 500 299", "delta": "0:00:00.018699", "end": "2023-09-28 00:47:32.764617", "rc": 0, "start": "2023-09-28 00:47:32.745918", "stderr": "", "stderr_lines": [], "stdout": "PASSED", "stdout_lines": ["PASSED"]}
ok: [localhost] => {"ansible_facts": {"ntp_sync_check": "PASSED"}, "changed": false}
"msg": "Check NTP limit PASSED"
- 以下节选显示了NTP不同步或有通信问题时出现的错误。
maglev@maglev-master:~$ cat /var/log/maglev_config_wizard.log | grep -i ntp
| 2023-07-19 02:36:41,396 | INFO | 76230 | MainThread | 140599082059584 | root | certs.py:142 | renew_certs : Check NTP limits |
| 2023-07-19 02:36:41,703 | DEBUG | 76230 | MainThread | 140599082059584 | root | ansible.py:495 | changed: [localhost] => {"changed": true, "cmd": "/opt/maglev/bin/check_ntp.sh 500 299", "delta": "0:00:00.014850", "end": "2023-07-19 02:36:41.679386", "rc": 0, "start": "2023-07-19 02:36:41.664536", "stderr": "", "stderr_lines": [], "stdout": "WARNING: Could not get Offset or Jitter from ntp peer", "stdout_lines": ["WARNING: Could not get Offset or Jitter from ntp peer"]}
| 2023-07-19 02:36:41,960 | DEBUG | 76230 | MainThread | 140599082059584 | root | ansible.py:495 | ok: [localhost] => {"ansible_facts": {"ntp_sync_check": "WARNING: Could not get Offset or Jitter from ntp peer"}, "changed": false}
"msg": "Check NTP limit WARNING: Could not get Offset or Jitter from ntp peer"
| 2023-07-19 02:36:42,635 | INFO | 76230 | MainThread | 140599082059584 | root | certs.py:142 | renew_certs : Fail if NTP not synched |
TASK [renew_certs : Check NTP limits] ******************************************
maglev@maglev-master:~$ cat /var/log/maglev_config_wizard.log | grep -i ntp
| 2023-09-12 18:21:29,564 | ERROR | 82110 | MainThread | 139737866331968 | maglev_config_wizard.managers.ntp.NtpManager | ntp.py:52 | Unable to sync with time server 10.88.14.200 |
| 2023-09-12 18:21:34,569 | ERROR | 82110 | MainThread | 139737866331968 | maglev_config_wizard.managers.ntp.NtpManager | ntp.py:164 | Unable to configure NTP after 2 attempts |
- 如果您需要更改NTP服务器,请使用命令sudo maglev-config update。
相关信息