使用 NTP,身份验证由请求者控制。NTP 服务器不能强制对 NTP 客户端进行身份验证;很高兴向客户发送未经身份验证的 NTP。客户端必须请求 NTP 身份验证,如果它已请求身份验证,它将拒绝未经身份验证的 NTP。
ntp master当 NTP 源不可用时,该命令告诉设备作为主时钟。这是一个经常被误解的命令,很少需要。
该ntp authentication-key命令仅设置身份验证密钥是什么。请注意,您在服务器上设置了密钥。如果该命令需要身份验证,那么 NTP 服务器也需要对其 NTP 服务器进行身份验证(NTP 是分层的)。
该ntp authenticate命令表示 NTP 客户端将需要来自其 NTP 服务器的身份验证。
该ntp trusted-key命令告诉客户端要使用哪些已配置的密钥。
该ntp server命令告诉客户端使用哪个 NTP 服务器。
根据您的评论进行编辑:
我最初回答了你的问题:
有什么ntp authenticate不同ntp trusted-key 22?在什么情况下我会应用一个命令而不应用另一个?
但这似乎并不是你的问题。
如果您要使用不同的身份验证密钥配置多个 NTP 服务器,它可能如下所示:
NTP 服务器 1:
R1(config)#ntp source Loopback1
R1(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY-1
NTP 服务器 2:
R2(config)#ntp source Loopback1
R2(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY-2
NTP 服务器 3:
R3(config)#ntp source Loopback1
R3(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY-3
NTP客户端:
R4(config)#ntp authenticate
R4(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY-1
R4(config)#ntp authentication-key 2 md5 SECRET-NTP-KEY-2
R4(config)#ntp authentication-key 3 md5 SECRET-NTP-KEY-3
R4(config)#ntp server 10.11.12.1 key 1
R4(config)#ntp server 10.11.12.2 key 2
R4(config)#ntp server 10.11.12.3 key 3
如果您打算使用相同的身份验证密钥配置多个 NTP 服务器,它可能如下所示:
NTP 服务器 1:
R1(config)#ntp source Loopback1
R1(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY
NTP 服务器 2:
R2(config)#ntp source Loopback1
R2(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY
NTP 服务器 3:
R3(config)#ntp source Loopback1
R3(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY
NTP客户端:
R4(config)#ntp source Loopback1
R4(config)#ntp authenticate
R4(config)#ntp authentication-key 1 md5 SECRET-NTP-KEY
R4(config)#ntp trusted-key 1
R4(config)#ntp server 10.11.12.1
R4(config)#ntp server 10.11.12.2
R4(config)#ntp server 10.11.12.3
拥有基于环回的 NTP 源是一个好主意。如果一个链接出现故障,并且流量可以通过不同的路径进出服务器,那么 NTP 仍然可以更新。
该ntp trusted-key <key number命令将用于您不使用key <key number>任何ntp server <server address> orntp peer 命令的可选项的命令。
该ntp source <interface>命令将用于您不使用source <interface>任何ntp server <server address> orntp peer 命令的可选项的命令。
编辑2:
来自实验室测试的 NTP 配置(不是由我执行,而是由一组测试所有网络硬件/软件功能的组执行),用于通过 IOS 15.x 的路由器(密码和地址已更改以进行保护):
ntp authentication-key 1 md5 123456789 7
ntp authenticate
ntp trusted-key 1
ntp source Loopback0
ntp update-calendar
ntp server 10.11.12.13
ntp server 10.12.13.14 prefer
请注意,在命令中key <key number>未使用可选项,ntp server <server address>因为服务器配置了相同的身份验证密钥。