路由器配置:
routerA:
interface Serial1/0
ip address 192.1.1.1 255.255.255.0
serial restart-delay 0
no fair-queue
!
router ospf 10
log-adjacency-changes
network 192.1.1.0 0.0.0.255 area 1
routerB:
interface Serial1/0
ip address 192.1.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
ip address 193.1.1.2 255.255.255.0
serial restart-delay 0
!
router ospf 10
log-adjacency-changes
network 192.1.1.0 0.0.0.255 area 1
network 193.1.1.0 0.0.0.255 area 0
routerC:
interface Serial0/2
ip address 193.1.1.3 255.255.255.0
serial restart-delay 0
!
router ospf 10
log-adjacency-changes
network 193.1.1.0 0.0.0.255 area 0
看一下现在路由器邻接状态都是FULL的
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
193.1.1.3 0 FULL/ - 00:00:35 193.1.1.3 Serial1/2
192.1.1.1 0 FULL/ - 00:00:31 192.1.1.1 Serial1/0
在路由器A上配置明文认证
routerA(config)#router ospf 10
routerA(config-router)#area 1 authentication
routerA(config)#interface s1/0
routerA(config-if)#ip ospf authentication-key cisco
看一下路由器的邻接状态已经没有路由器A了
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
193.1.1.3 0 FULL/ - 00:00:35 193.1.1.3 Serial1/2
在路由器B上配置认证
routerB(config)#router ospf 10
routerB(config-router)#area 1 authentication
routerB(config)#interface s1/0
routerB(config-if)#ip ospf authentication-key cisco
路由器A和B又恢复邻接关系了
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
193.1.1.3 0 FULL/ - 00:00:35 193.1.1.3 Serial1/2
192.1.1.1 0 FULL/ - 00:00:31 192.1.1.1 Serial1/0
接下来配置路由器B的MD5认证
routerB(config)#router ospf 10
routerB(config-router)#area 0 authentication message-digest
routerB(config)#interface s1/2
routerB(config-if)#ip ospf message-digest-key 1 md5 cisco
现在路由器C和它的连接已经down掉了
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.1.1.1 0 FULL/ - 00:00:31 192.1.1.1 Serial1/0
在路由器C上同样配置后,认证成功
routerC(config)#router ospf 10
routerC(config-if)#ip ospf message-digest-key 1 md5 cisco
routerC(config)#interface s0/2
routerC(config-if)#ip ospf message-digest-key 1 md5 cisco
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
193.1.1.3 0 FULL/ - 00:00:39 193.1.1.3 Serial1/2
192.1.1.1 0 FULL/ - 00:00:35 192.1.1.1 Serial1/0
message-digest-key 1 的这个1必须保持一致,否则认证失败
routerC(config)#interface s0/2
routerC(config-if)#ip ospf message-digest-key 2 md5 cisco
routerB#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.1.1.1 0 FULL/ - 00:00:33 192.1.1.1 Serial1/0