天天看點

BSCI—9:配置OSPF認證

一、認證的作用

1.增加網絡安全性(推薦使用MD5)

2.對OSPF重新配置時,不同密碼可以配置在新密碼和舊密碼的路由器上,防止它們在一個共享的公共廣播網絡的情況下互相通信

二、認證的種類

OSPF路由方式有三種:0 Null (也就是不認證), 1 (明文認證), 2 (MD5加密校驗和)

三、實驗拓撲,各種資訊如拓撲所示:

1.  明文認證:

R1:

Router>

Router>en

Router#conf t

Router(config)#hostname R1

R1(config)#interface f0/0

R1(config-if)#ip address 192.168.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exit

R1(config)#router ospf 1     //啟用OSPF路由協定

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 192.168.1.1 0.0.0.0 area 0

R1(config-router)#exit

R1(config-if)#ip ospf authentication     //啟用認證,不打這個指令的話,密碼不起作用

R1(config-if)#ip ospf authentication-key cisco    //配置密碼(兩邊需一樣)

R1(config)#router ospf 1

R1(config-router)#area 0 authentication    //區域0采用明文認證

R1(config-router)#end

R1#

R2:

Router(config)#hostname R2

R2(config)#interface f0/0

R2(config-if)#ip address 192.168.1.2 255.255.255.0

R2(config-if)#no sh

R2(config-if)#exit

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 192.168.1.2 0.0.0.0 area 0

R2(config-router)#exit

R2(config-if)#ip ospf authentication    //啟用認證,不打這個指令的話,密碼不起作用

R2(config-if)#ip ospf authentication-key cisco     //配置密碼

R2(config-router)#area 0 authentication      //區域0采用明文認證

R2(config-router)#end

R2#

檢視R1接口資訊:

R1#show ip ospf interface f0/0

FastEthernet0/0 is up, line protocol is up

  Internet address is 192.168.1.1/24, Area 0

  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1

  Transmit Delay is 1 sec, State DR, Priority 1

  Designated Router (ID) 1.1.1.1, Interface address 192.168.1.1

  Backup Designated Router (ID) 2.2.2.2, Interface address 192.168.1.2

  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

    Hello due in 00:00:07

  Index 1/1, flood queue length 0

  Next 0x0(0)/0x0(0)

  Last flood scan length is 1, maximum is 1

  Last flood scan time is 0 msec, maximum is 0 msec

  Neighbor Count is 1, Adjacent neighbor count is 1

    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)

  Suppress hello for 0 neighbor(s)

  Simple password authentication enabled   //明文密碼認證啟用

檢視R1鄰居表:

R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2.2           1   FULL/BDR        00:00:31    192.168.1.2     FastEthernet0/0

2.MD5認證

MD5算法用在類型2 的認證方式中,将OSPF資料包内容與一個密碼計算一個散列值,與密鑰ID一起發送,有了密鑰ID可以讓路由器指定多個密碼,密碼最大長度16位元組,密鑰ID在1-255之間,一對鄰居路由器密鑰ID與密碼必須相同.

R1:

R1(config-if)#no ip ospf authentication     //NO掉明文認證

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

//使用Key-id為1,密碼為cisco的MD5認證方式(Key-id與密碼兩邊都需一樣)

R1(config-router)#area 0 authentication message-digest   //區域0采用MD5認證

R2:

R2(config-if)#no ip ospf authentication     //同上

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

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

  Backup Designated Router (ID) 1.1.1.1, Interface address 192.168.1.1

    Hello due in 00:00:09

    Adjacent with neighbor 2.2.2.2

  Message digest authentication enabled    //啟用MD5認證

    Youngest key id is 1

注意:在一個區域隻能使用一種認證方式,在不同鍊路之間密碼可以不同。

本文轉自 meiyanaa 51CTO部落格,原文連結:http://blog.51cto.com/justim/273239,如需轉載請自行聯系原作者

繼續閱讀