OSPF的認證問題
1.OSPF支援兩種型別的認證
-明文認證
-MD5認證
2.OSPF的認證分為
-鏈路認證 -區域認證 -虛鏈路認證
3.認證分為兩個部分
-開啟認證 -出示金鑰
我們通過實驗來解析OSPF的各種認證問題,首先搭建如下拓撲:
配置步驟如下
R1>en
R1#config
R1(config)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#int s1/0
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int s1/1
R1(config-if)#ip add 13.1.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 100
R1(config-router)#net 1.1.1.0 0.0.0.255 area 0
R1(config-router)#net 12.1.1.10 0.0.0.255 area 0
R1(config-router)#net 13.1.1.0 0.0.0.255 area 2
R1(config-router)#exit
R1(config)#
R2>en R2#config R2(config)#int lo 0 R2(config-if)#ip add 2.2.2.2 255.255.255.0 R2(config-if)#no shut R2(config-if)#exit R2(config)#int s1/1 R2(config-if)#ip add 12.1.1.2 255.255.255.0 R2(config-if)#no shut R2(config-if)#exit R2(config)#int s1/0 R2(config-if)#ip add 24.1.1.1 255.255.255.0 R2(config-if)#no shut R2(config-if)#exit R2(config)#router ospf 100 R2(config-router)#net 24.1.1.0 0.0.0.255 area 1 R2(config-router)#net 12.1.1.0 0.0.0.255 area 0 R2(config-router)#net 2.2.2.0 0.0.0.255 area 0 R2(config-router)#exit R2(config)# R3>en R3#config R3(config)#int lo 0 R3(config-if)#ip add 3.3.3.3 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#int s1/0 R3(config-if)#ip add 13.1.1.2 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#int s1/1 R3(config-if)#ip add 35.1.1.1 255.255.255.0 R3(config-if)#no shut R3(config-if)#exit R3(config)#router ospf 100 R3(config-router)#net 3.3.3.0 0.0.0.255 area 2 R3(config-router)#net 13.1.1.0 0.0.0.255 area 2 R3(config-router)#net 35.1.1.0 0.0.0.255 area 3 R3(config-router)#exit R4>en R4#config R4(config)#int lo 0 R4(config-if)#ip add 4.4.4.4 255.255.255.0 R4(config-if)#no shut R4(config-if)#exit R4(config)#int s1/0 R4(config-if)#ip add 24.1.1.2 255.255.255.0 R4(config-if)#no shut R4(config-if)#exit R4(config)#router ospf 100 R4(config-router)#net 4.4.4.0 0.0.0.255 area 1 R4(config-router)#net 24.1.1.0 0.0.0.255 area 1 R4(config-router)#exit R4(config)# R5>en R5#config R5(config)#int lo 0 R5(config-if)#ip add 5.5.5.5 255.255.255.0 R5(config-if)#no shut R5(config-if)#exit R5(config)#int s1/0 R5(config-if)#ip add 35.1.1.2 255.255.255.0 R5(config-if)#no shut R5(config-if)#exit R5(config)#router ospf 100 R5(config-router)#net 5.5.5.0 0.0.0.255 area 3 R5(config-router)#net 35.1.1.0 0.0.0.255 area 3 R5(config-router)#exit R5(config)# 首先我們在 Area1上配置鏈路認證 R2(config)#int s1/0 進入介面下 R2(config-if)#ip ospf authentication 開啟OSPF明文認證 R2(config-if)#ip ospf authentication-key cisco 出示OSPF明文金鑰 R2(config-if)#end R2#clear ip ospf process Reset ALL OSPF processes? [no]: y 清空OSPF程序讓其重新建立鄰居關係 R2# *Jan 2 15:07:32.379: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on Serial1/1 from FULL to DOWN, Neighbor Down: Interface down or detached *Jan 2 15:07:32.427: %OSPF-5-ADJCHG: Process 100, Nbr 4.4.4.4 on Serial1/0 from FULL to DOWN, Neighbor Down: Interface down or detached *Jan 2 15:07:32.991: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on Serial1/1 from LOADING to FULL, Loading Done OSPF鄰居關係重新建立 R2# *Jan 2 15:08:09.087: OSPF: Rcv pkt from 24.1.1.2, Serial1/0 : Mismatch Authentication Key - Clear Text R2#no debug all 提示R2和R4之間的認證金鑰不匹配 此時我們繼續在R4上進行相同配置 R4(config)#int s1/0 R4(config-if)#ip ospf authentication 開啟認證 R4(config-if)#ip ospf authentication-key cisco 出示金鑰 R4(config-if)# *Jan 2 15:11:49.815: %OSPF-5-ADJCHG: Process 100, Nbr 2.2.2.2 on Serial1/0 from LOADING to FULL, Loading Done R4(config-if)#exit 鄰居關係建立成功 那麼OSPF的鏈路明文認證就配置成功了,我們繼續在 Area0 配置鏈路的MD5認證 R1(config)#int s1/0 R1(config-if)#ip ospf authentication message-digest 開啟鏈路的MD5認證 R1(config-if)#ip ospf message-digest-key <1-255> Key ID R1(config-if)#ip ospf message-digest-key 1 配置金鑰序號(建議兩端配置相同) md5 Use MD5 algorithm R1(config-if)#ip ospf message-digest-key 1 md5 ? 金鑰型別為MD5 <0-7> Encryption type (0 for not yet encrypted, 7 for proprietary) LINE The OSPF password (key) (maximum 16 characters) R1(config-if)#ip ospf message-digest-key 1 md5 cisco 金鑰為cisco R1#clear ip ospf process Reset ALL OSPF processes? [no]: y 清空OSPF程序,讓鄰居關係重新建 立 R1# *Jan 2 15:17:17.903: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on Serial1/1 from FULL to DOWN, Neighbor Down: Interface down or detached *Jan 2 15:17:18.387: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on Serial1/1 from LOADING to FULL, Loading Done R1#debug ip ospf adj 跟蹤檢視OSPF鄰居建立過程 OSPF adjacency events debugging is on R1#debug ip ospf *Jan 2 15:17:36.951: OSPF: Send with youngest Key 1 *Jan 2 15:17:44.007: OSPF: Rcv pkt from 12.1.1.2, Serial1/0 : Mismatch Authentication type. Input packet specified type 0, we use type 2 提示認證不匹配 那麼此時我們在R2上進行相同的配置 R2(config)#int s1/1 R2(config-if)#ip ospf authen R2(config-if)#ip ospf authentication mess R2(config-if)#ip ospf authentication message-digest R2(config-if)#ip ospf mess R2(config-if)#ip ospf message-digest-key 1 md5 cisco *Jan 2 15:21:02.667: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on Serial1/1 from LOADING to FULL, Loading Done 此時我們發現鄰居關係已經成功的 建立 到此OSPF的鏈路明文和MD5認證就介紹到這裡. 我們繼續介紹OSPF的虛鏈路認證 虛鏈路的明文認證 R1(config)#router ospf 100 R1(config-router)#area 2 virtual-link 3.3.3.3 authentication 開啟虛鏈路認證 R1(config-router)#area 2 virtual-link 3.3.3.3 authentication-key cisco 出示虛鏈路認證 金鑰 R1(config)#exit 在R3上進行同樣的配置 R3(config)#router ospf 100 R3(config-router)#area 2 vir R3(config-router)#area 2 virtual-link 1.1.1.1 authentication R3(config-router)#area 2 virtual-link 1.1.1.1 authentication-key cisco *Jan 2 15:41:08.423: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on OSPF_VL0 fro m LOADING to FULL, Loading Done 此時虛鏈路明文認證建立成功,鄰居關係建立成功 虛鏈路MD5認證配置也很簡單R3(config-router)#area 2 virtual-link 1.1.1.1 message-digest-key 1 md5 cisco
R3(config-router)#area 2 virtual-link 1.1.1.1 authentication message-digest
R1(config-router)#area 2 virtual-link 3.3.3.3 message-digest-key 1 md5 cisco
R1(config-router)#area 2 virtual-link 3.3.3.3 authentication message-digest
OSPF的區域認證配置
R3(config)#router ospf 100
R3(config-router)#area 3 authentication 開啟區域認證
R3(config-router)#exit
R3(config)#int s1/1
R3(config-if)#ip ospf authentication-key cisco 出示區域認證金鑰
在路由器R3和R5之間配置區域認證,在OSPF程序下開啟認證,在屬於相應區域的介面上配置金鑰
繼續在R5上進行相同的操作
R5(config)#router ospf 100
R5(config-router)#area 3 authentication
R5(config-router)#exit
R5(config)#int s1/0
R5(config-if)#ip ospf au
R5(config-if)#ip ospf authentication-key cisco
*Jan 2 16:09:06.455: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on Serial1/0 from LOADING to FULL, Loading Done
R5(config-if)# 鄰居關係建立成功
OSPF區域的MD5認證配置方法
1.在OSPF程序下開啟區域認證
area 0 authentication message-digest
2.在屬於欲配置認證的區域的介面上配置密文密碼
ip ospf message-digest-key 1 md5 cisco
OSPF的區域認證配置成功
轉載於:https://blog.51cto.com/liushuo890/1106242