3.8 RIPv2的认证机制 |
|
实验连接图 |
|
提要描述 |
Cisco 实现RIPv2的消息认证包括两种选择—简单的明文认知和MD5认证。
配置RIPv2认证的步骤如下:
1:定义一个带名的钥匙链
2:定义在钥匙链的钥匙
3:在接口上启动认证并指定使用的钥匙链
4:指定这个接口使用明文认证还是MD5认证
5:还有其它的可选配置钥匙管理
实验目标: 通过实验调试出两种认证的各种情况 |
RIPv1基本配置 |
R1的配置 |
R2的配置 |
!
hostname R1
!
interface Loopback1
ip address 1.1.1.1 255.255.255.0
!
interface Loopback2
ip address 1.1.2.1 255.255.255.0
!
interface Loopback3
ip address 1.1.3.1 255.255.255.0
!
interface Serial1/1
ip address 12.1.1.1 255.255.255.0
no shut
!
router rip
version 2
network 1.0.0.0
network 12.0.0.0
no auto-summary
! |
!
hostname R2
!
interface Loopback1
ip address 2.2.1.1 255.255.255.0
!
interface Loopback2
ip address 2.2.2.1 255.255.255.0
!
interface Loopback3
ip address 2.2.3.1 255.255.255.0
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
no shut
!
router rip
version 2
network 2.0.0.0
network 12.0.0.0
no auto-summary
! |
↓调试配置及监测步骤↓ |
完成以上基本配置常规情况下的路由表:
R1#show ip route
1.0.0.0/24 is subnetted, 3 subnets
C 1.1.1.0 is directly connected, Loopback1
C 1.1.2.0 is directly connected, Loopback2
C 1.1.3.0 is directly connected, Loopback3
2.0.0.0/24 is subnetted, 3 subnets
R 2.2.1.0 [120/1] via 12.1.1.2, 00:00:05, Serial1/1
R 2.2.2.0 [120/1] via 12.1.1.2, 00:00:05, Serial1/1
R 2.2.3.0 [120/1] via 12.1.1.2, 00:00:05, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/1
R2#show ip route
1.0.0.0/24 is subnetted, 3 subnets
R 1.1.1.0 [120/1] via 12.1.1.1, 00:00:11, Serial1/0
R 1.1.2.0 [120/1] via 12.1.1.1, 00:00:11, Serial1/0
R 1.1.3.0 [120/1] via 12.1.1.1, 00:00:11, Serial1/0
2.0.0.0/24 is subnetted, 3 subnets
C 2.2.1.0 is directly connected, Loopback1
C 2.2.2.0 is directly connected, Loopback2
C 2.2.3.0 is directly connected, Loopback3
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
(一)明文认证
在R1上的配置:
R1(config)#key chain sharkii #----配置钥匙链
R1(config-keychain)#key 1 #----配置一把钥匙
R1(config-keychain-key)#key-string sharkii labing #----配置钥匙的密码
R1(config)#int s1/1
R1(config-if)#ip rip authentication key sharkii #---在接口上启动认证并调用钥匙链
R1(config-if)#ip rip authentication mode text #----------配置认证模式为明文,默认认证模式就是明文,所以也可以不用指定
在R2上同样配置:
R2(config)#key chain sharkii
R2(config-keychain)#key 1
R2(config-keychain-key)#key-string sharkii labing
R2(config)#int s1/0
R2(config-if)#ip rip authentication key sharkii
R2(config-if)#ip rip authentication mode text
R1#show ip protocols
Interface Send Recv Triggered RIP Key-chain
Serial1/1 2 2 sharkii
R2#show ip protocols
Interface Send Recv Triggered RIP Key-chain
Serial1/0 2 2 sharkii
以上两行表明R1的S1/1和R2的S1/0接口都启用了认证
R1#debug ip rip
*Mar 23 04:12:03.799: RIP: received packet with text authentication sharkii labing #---收到密码为sharkii labing的明文认证数据包
*Mar 23 04:12:03.803: RIP: received v2 update from 12.1.1.2 on Serial1/1
*Mar 23 04:12:03.803: 2.2.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 04:12:03.807: 2.2.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 04:12:03.807: 2.2.3.0/24 via 0.0.0.0 in 1 hops
R2#debug ip rip
*Mar 23 04:11:59.035: RIP: received packet with text authentication sharkii labing
*Mar 23 04:11:59.035: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Mar 23 04:11:59.035: 1.1.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 04:11:59.039: 1.1.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 04:11:59.039: 1.1.3.0/24 via 0.0.0.0 in 1 hops
在接收的更新中带有“text authentication”的字样,再次证明接口S1/1 和S1/0都启用了明文认证。
看看用软件在R1的S1/1接口抓包情况:
如图所示!当使用简单的密码认证是,密码是以明文方式传输的,因此很容易通过嗅探更新数据包就可以读出密码。
(二)MD5认证
关于MD5 认证,(在明文配置的基础上)只需要在接口下声明认证模式为MD5 即可:
在R1、R2上的配置:
R1(config)#int s1/1
R1(config-if)#ip rip authentication mode md5
R2(config)#int s1/0
R2(config-if)#ip rip authentication mode md5
看看R1、R2的debug信息:
R1#debug ip rip
*Mar 23 05:11:38.383: RIP: received packet with MD5 authentication
*Mar 23 05:11:38.387: RIP: received v2 update from 12.1.1.2 on Serial1/1
*Mar 23 05:11:38.387: 2.2.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 05:11:38.391: 2.2.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 05:11:38.391: 2.2.3.0/24 via 0.0.0.0 in 1 hops
R2#debug ip rip
*Mar 23 05:11:36.483: RIP: received packet with MD5 authentication
*Mar 23 05:11:36.487: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Mar 23 05:11:36.487: 1.1.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 05:11:36.491: 1.1.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 05:11:36.491: 1.1.3.0/24 via 0.0.0.0 in 1 hops
在接收的更新中带有“MD5 authentication”的字样,已经看不到了被加密的密码。
再次看看用软件在R1的S1/1接口抓包情况:
如图所示!来自同样的更新,但使用是MD5认证,密码是以MD5加密传输的,因此看到的密码已经不是明文而是一大串经过128位hash的字符,这样就算通过嗅探包含更新的数据包也非常之难读出密码。因此明智的选择是用安全性能好得多的MD5认证。
总结:
钥匙链name只有本地有意义,两个路由器的key chain name可以不同,但宣告给对方的key-string必须相同,成功配置认证最明智的方法是:不要手动一条条配置,而是是写好脚本粘贴上路由器。
|
1: 明文认证的匹配原则是:
(1). 发送方发送最小Key ID的密钥(key-string)
(2). 不携带Key ID号码
(3). 接收方会和所有Key Chain 中的密钥(key-string)匹配,如果匹配成功,则通过认证。 |
【例如】
路由器R1 有一个Key ID,key1=sharkii01;
路由器R2 有两个Key ID,key1=sharkii02,key2=sharkii01
R1上的配置:
!
key chain sharkii01
key 1
key-string sharkii01
!
interface Serial1/1
ip rip authentication key-chain sharkii01
!
R2上的配置:
!
key chain sharkii02
key 1
key-string sharkii02
key 2
key-string sharkii01
!
interface Serial1/0
ip rip authentication key-chain sharkii02
!
R1#debug ip rip
*Mar 23 08:08:59.375: RIP: received packet with text authentication sharkii02
*Mar 23 08:08:59.379: RIP: ignored v2 packet from 12.1.1.2 (invalid authentication) #----接收来自R2的密钥(sharkii02)时认证失败。
R2#debug ip rip
*Mar 23 08:13:09.883: RIP: received packet with text authentication sharkii01
*Mar 23 08:13:09.887: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Mar 23 08:13:09.887: 1.1.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 08:13:09.887: 1.1.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 08:13:09.891: 1.1.3.0/24 via 0.0.0.0 in 1 hops
根据上面的原则,R1 认证失败,R2 认证成功可以学到来自R1的全部路由,所以在RIP v2认证中,会有可能出现单边路由的现象。
2: MD5 认证的匹配原则是:
(1). 发送方发送最小Key ID的密钥(key-string)
(2). 携带Key ID号码
(3). 接收方首先会查找是否有相同的Key ID,如果有,只匹配一次,就可决定认证是否成功。如果没有该Key ID,只向下查找下一个key ID(只检查该KEY ID号中的密钥),匹配,认证成功;不匹配,认证失败。 |
【例如】
路由器R1 有三个Key ID,key1=sharkii02,key3=sharkii,key4=sharkii ;
路由器R2 有一个Key ID,key2=sharkii02
根据上面的原则,R1 认证失败,R2 认证成功。
R1上的配置:
!
key chain sharkii01
key 1
key-string sharkii02
key 3
key-string sharkii01
key 4
key-string sharkii02
!
interface Serial1/1
ip rip authentication mode md5
ip rip authentication key-chain sharkii01
!
R2上的配置:
!
key chain sharkii02
key 2
key-string sharkii02
!
interface Serial1/0
ip rip authentication mode md5
ip rip authentication key-chain sharkii02
!
R1#debug ip rip
*Mar 23 08:30:41.655: RIP: received packet with MD5 authentication
*Mar 23 08:30:41.659: RIP: ignored v2 packet from 12.1.1.2 (invalid authentication) #----认证失败
R2#debug ip rip
*Mar 23 08:31:16.815: RIP: received packet with MD5 authentication
*Mar 23 08:31:16.819: RIP: received v2 update from 12.1.1.1 on Serial1/0
*Mar 23 08:31:16.819: 1.1.1.0/24 via 0.0.0.0 in 1 hops
*Mar 23 08:31:16.823: 1.1.2.0/24 via 0.0.0.0 in 1 hops
*Mar 23 08:31:16.823: 1.1.3.0/24 via 0.0.0.0 in 1 hops
根据上面的MD5认证匹配的原则,R1 认证失败,R2 认证成功可以学到来自R1的全部路由。