CCNP-17 OSPF试验13

实验拓扑:

试验要求: 1 R1 R2 OSPF ,配置 R1 R2 接口明文验证;
          2 R1 R2 OSPF ,配置 R1 R2 接口密文验证;
          3 R1 R2 OSPF ,配置 R1 R2 区域明文验证;
          4 R1 R2 OSPF ,配置 R1 R2 区域密文验证;
试验目的:掌握 OSPF 不同验证方法的配置。

试验配置:
R1
R1(config)#int s1/0
R1(config-if)#ip add 199.99.1.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int loop0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#router ospf 100
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 199.99.1.0 0.0.0.255 area 0
R1(config-router)#exit

 

R2
R2(config)#int s1/0
R2(config-if)#ip add 199.99.1.2 255.255.255.0
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int loop0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 199.99.1.0 0.0.0.255 area 0
R2(config-router)#exit

 

配置好基本的 OSPF 后,接下来开始验证的配置:
一.   OSPF 接口明文验证:
R1(config)#int s1/0
R1(config-if)#ip ospf authentication-key cisco

R1(config-if)#ip ospf authentication

先配置好 R1 后,在 R1 clear ip ospf pj 后,邻居关系会消失, debug ip ospf adj 会发现以下问题:
R1#debug ip ospf adj
OSPF adjacency events debugging is on
*Mar  1 00:01:51.911: OSPF: Rcv pkt from 199.99.1.2, Serial1/0 : Mismatch Authentication type. Input packet specified type 0, we use type 1

 

同样在 R2 debug ip ospf adj
R2#debug ip ospf adj
OSPF adjacency events debugging is on
*Mar  1 00:02:11.979: OSPF: Rcv pkt from 199.99.1.1, Serial1/0 : Mismatch Authentication type. Input packet specified type 1, we use type 0

可以发现一条错误提示:验证类型不匹配。缺省情况下,无验证为类型 0 ,明文验证为 1 ,记住!

下面在 R2 接口上同样配置明文验证:

R2(config)#int s1/0

R2(config-if)#ip ospf authentication-key cisco

R2(config-if)#ip ospf authentication

这样配置完后,邻居关系就会马上建立起来,在 R1 上查看邻居关系:

R2#show ip ospf neighbor

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

1.1.1 .1           0   FULL/  -        00:00:31    199.99.1.1      Serial1/0

 

二. OSPF 接口密文验证:

首先用 no 语句去掉接口上的明文验证,然后输入如下命令:

R1(config)#int s1/0

R1(config-if)#ip ospf message-digest-key 1 md5 cisco

R1(config-if)#ip ospf authentication message-digest

R1(config-if)#end

同样是先在 R1 上配置好后 clear ip ospf p debug ip ospf adj 查看:

R1#debug ip ospf adj

OSPF adjacency events debugging is on

 

*Mar  1 00:03:47.139: OSPF: Send with youngest Key 1

*Mar  1 00:03:51.935: OSPF: Rcv pkt from 199.99.1.2, Serial1/0 : Mismatch Authentication type. Input packet specified type 0, we use type 2

R1 发送了 key-id 1 key ,但是 R2 上没有配置验证,所以会出现验证类型不匹配的错误提示,默认情况下密文验证为类型 2

然后查看 R2 debug 信息:

R2#debug ip ospf adj

OSPF adjacency events debugging is on

R2#

*Mar  1 00:04:07.083: OSPF: Rcv pkt from 199.99.1.1, Serial1/0 : Mismatch Authentication type. Input packet specified type 2, we use type 0

同样出现了类型不匹配的错误,下面在 R2 的接口上配置密文验证:

R2(config)#int s1/0

R2(config-if)#ip ospf message-digest-key 1 md5 cisco

R2(config-if)#ip ospf authentication message-digest

R2(config-if)#end

配置完成后,会发现邻居关系也会迅速的建立起来,再 R1 show ip ospf neighbor

R1#show ip ospf neighbor

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2 .2           0   FULL/  -        00:00:39    199.99.1.2      Serial1/0

下面我们把 R2 接口上配置的密文验证的 key-id 改成其他数字后,看看有什么效果:

R2(config-if)#no ip ospf message-digest-key 1

R2(config-if)#ip ospf message-digest-key 2 md5 cisco

注意,在这里我把 1 改成了 2 ,下面查看 R1 上的 debug 信息:

R1#debug ip ospf adj

OSPF adjacency events debugging is on

 

*Mar  1 00:05:14.111: OSPF: Rcv pkt from 199.99.1.2, Serial1/0 : Mismatch Authentication Key - No message digest key 2 on interface

可以看到错误提示 key-id 不匹配,所以无法建立邻居关系。

 

三. OSPF 区域明文验证:

首先 no 掉接口上的所有验证的配置,然后进行区域明文验证的配置:

R1(config)#router ospf 100

R1(config-router)#area 0 authentication

这样在 R1 上配置后,观察 debug 信息:

R1#debug ip ospf adj

OSPF adjacency events debugging is on

 

*Mar  1 00:07:04.103: OSPF: Rcv pkt from 199.99.1.2, Serial1/0 : Mismatch Authentication type. Input packet specified type 0, we use type 1

同样会发现验证类型不匹配的错误提示,只需在 R2 上做同样的配置即可解决这个问题:

R2(config)#router ospf 100

R2(config-router)#area 0 authentication

这样配置完成后就可以顺利建立邻居关系了。

 

四. OSPF 区域密文验证:

首先 no 掉关于 OSPF 区域明文的配置,然后进行 OSPF 区域密文验证:

R1(config)#router ospf 100

R1(config-router)#area 0 authentication message-digest

R1(config-router)#end

同样在 R1 上观察 debug 信息:

R1#debug ip ospf adj

OSPF adjacency events debugging is on

 

*Mar  1 00:08:04.103: OSPF: Rcv pkt from 199.99.1.2, Serial1/0 : Mismatch Authentication type. Input packet specified type 0, we use type 2

同样收到了验证类型不匹配的错误提示,然后在 R2 上进行同样的配置:

R2(config)#router ospf 100

R2(config-router)#area 0 authentication message-digest

配置完成后邻居关系就可以建立起来了。

 

实验总结: 以上为全部 OSPF 验证类型的配置,要熟练掌握每种验证类型的配置。