ospf協議案例

   上篇我們只是對ospf協議進行初步的認識和了解,我們可以根據ospf協議的基礎知識進行一些實驗,是我們真的理解ospf協議的真正含義及應用。

   我們就以cisio路由器爲例,做下面是各種案例:

①OSPF的規則、存根、完全存根以及NSSA區域案例

拓撲圖:

Cisco路由器支持多種區域類型(規則、存根、完全存根以及NSSA區域),區域類型之間的不同表現在區域允許的LSA類型的不同。


在規則區域中,允許所有類型的LSA。其好處就是所有的路由器都有所有的路由信息,因此具有到達目的地的最佳路徑。缺點就是,任何區域外的鏈路失效將引起局部的SPF計算。


在存根區域中(Stub)中,不允許外部的LSA。因此,ABR不產生任何更新。外部LSA用於描述OSPF區域外的目的地。例如,從其他路由協議接收到的路由,比如RIP,以及重分佈到OSPF中的路由將被認爲是外部的,並將在一個外部LSA中被通告。


雖然存根區域可以防止外部區域對區域的影響,但它們並不阻止區域內對區域的影響。因爲仍然允許彙總LSA,所以,其他區域將仍然影響到存根區域。


完全存根區域(Totally Stub)區域同存根區域類似,將阻止外部LSA。但是,同存根區域不同的是,完全存根區域不允許彙總LSA。這樣其他區域將不影響完全存根區域。


NSSA區域同存根區域類似,但是,它可以將外部路由導入到區域中。區域間的路由爲類型7的LSA,並被ABR轉換爲類型5的LSA。例如,如 果你需要阻止外部LSA進入該區域,但仍需要向區域外部發送外部LSA(例如,如果區域中的某個路由器爲ASBR),就需要使用NSSA區域。


基本配置如下:

// R1 //

int e0/0

 ip ad 192.1.1.1 255.255.255.252


router os 1

 network 192.1.1.1 0.0.0.0 area 1



// R2 //

int e0/0

 ip ad 192.1.1.2 255.255.255.252


int lo0

 ip ad 193.1.1.129 255.255.255.192

 ip ospf network point-to-point    //變主機路由爲網段路由


int e1/0

 ip ad 193.1.1.2 255.255.255.128


router os 1

 network 192.1.1.2 0.0.0.0 area 1

 network 193.1.1.129 0.0.0.0 area 0

 network 193.1.1.2 0.0.0.0 area 0

 area 0 range 193.1.1.0 255.255.255.0    //區域彙總



// R3 //

int e1/0

 ip ad 193.1.1.3 255.255.255.128


int lo0

 ip ad 193.1.1.193 255.255.255.192

 ip ospf network point-to-point    //變主機路由爲網段路由


int e0/0

 ip ad 194.1.1.1 255.255.255.252


router os 1

 network 193.1.1.3 0.0.0.0 area 0

 network 193.1.1.193 0.0.0.0 area 0

 network 194.1.1.1 0.0.0.0 area 2

 area 0 range 193.1.1.0 255.255.255.0    //區域彙總



// R4 //

int e0/0

 ip ad 194.1.1.2 255.255.255.252


int e1/0

 ip ad 130.1.4.4 255.255.255.0


rotuer os 1

 netw 194.1.1.2 0.0.0.0 area 2

 summary-address 130.1.0.0 255.255.248.0    //外部路由彙總


router rip

 netw 130.1.0.0



// R5 //

int e1/0

 ip ad 130.1.4.5 255.255.255.0


int lo1

 ip ad 130.1.1.1 255.255.255.0


int lo2

 ip ad 130.1.2.1 255.255.255.0


int lo3

 ip ad 130.1.3.1 255.255.255.0


int lo5

 ip ad 130.1.5.1 255.255.255.0


int lo6

 ip ad 130.1.6.1 255.255.255.0


int lo7

 ip ad 130.1.7.1 255.255.255.0


router rip

 network 130.1.0.0




基本配置完成後,先進行驗證:

r1#sh ip ro
    130.1.0.0/21 is subnetted, 1 subnets
O E2    130.1.0.0 [110/10] via 192.1.1.2, 00:00:02, Ethernet0/0
O IA 193.1.1.0/24 [110/11] via 192.1.1.2, 00:00:02, Ethernet0/0
    192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.0 is directly connected, Ethernet0/0
    194.1.1.0/30 is subnetted, 1 subnets
O IA    194.1.1.0 [110/30] via 192.1.1.2, 00:00:02, Ethernet0/0我們觀察到了區域間路由以及外部路由。這時候其它區域的路由波動會引起本地區域的路由重新計算。外部路由同樣也會引起內部路由計算。第一個實驗,我們要進行區域設置,按圖例將各區域分別設置爲stub,nssa。只需在各區域邊界路由器上加一條命令即可。觀察設置區域前後的不同。// R1 //  area 1 stub// R2 //  area 1 stub// R3 //area 2 nssa// R4 //area 2 nssa


配置完成後我們比較一下結果:

r1#sh ip ro
O IA 193.1.1.0/24 [110/11] via 192.1.1.2, 00:00:13, Ethernet0/0
    192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.0 is directly connected, Ethernet0/0
    194.1.1.0/30 is subnetted, 1 subnets
O IA    194.1.1.0 [110/30] via 192.1.1.2, 00:00:13, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.1.1.2, 00:00:13, Ethernet0/0

注意,R1中不再有到130.1.0.0的OSPF外部路由,相反,添加了一個缺省路由。但是,仍然存在兩個內部路由,因爲stub區域並不阻止內部區域更新。



下面我們說明一下如何配置區域,以阻止外部LSA的擴散。爲了阻止其他區域的彙總LSA影響到本地區域,該區域必須配置爲完全存根區域。可以以OSPF進程下添加下列命令:

// R1 //

 area 1 stub no-summary


// R2 //

 area 1 stub no-summary


驗證結果如下:

r1#sh ip ro

    192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.0 is directly connected, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.1.1.2, 00:00:48, Ethernet0/0

在R1上只出現了一條缺省路由。



注意R3上顯示路由表時,只觀察到一條N2路由,即外部路由。

r3#sh ip ro

    130.1.0.0/21 is subnetted, 1 subnets
O N2    130.1.0.0 [110/10] via 194.1.1.2, 00:17:57, Ethernet0/0
    193.1.1.0/24 is variably subnetted, 4 subnets, 3 masks
C       193.1.1.192/26 is directly connected, Loopback0
O       193.1.1.128/26 [110/11] via 193.1.1.2, 00:17:57, Ethernet1/0
O       193.1.1.0/24 is a summary, 00:17:57, Null0
C       193.1.1.0/25 is directly connected, Ethernet1/0
    192.1.1.0/30 is subnetted, 1 subnets
O IA    192.1.1.0 [110/20] via 193.1.1.2, 00:01:32, Ethernet1/0
    194.1.1.0/30 is subnetted, 1 subnets
C       194.1.1.0 is directly connected, Ethernet0/0

②OSPF區域間、外部路由彙總

拓撲圖:

Cisco允許對地址進行彙總,以通過限制區域間通告的路由來達到節省資源的目的。Cisco路由器支持兩種類型的地址彙總:區域間彙總和外部路由彙總。區域間彙總用於在區域間彙總地址,而外部彙總用於收集到某個域中的一系列外部路由的彙總。


// R1 //

int e0/0

 ip ad 192.1.1.1 255.255.255.252


router os 1

 network 192.1.1.1 0.0.0.0 area 1



// R2 //

int e0/0

 ip ad 192.1.1.2 255.255.255.252


int e1/0

 ip ad 193.1.1.2 255.255.255.128


int lo0

 ip ad 193.1.1.129 255.255.255.192

router os 1

 network 192.1.1.2 0.0.0.0 area 1

 network 193.1.1.2 0.0.0.0 area 0

 network 193.1.1.129 0.0.0.0 area 0



// R3 //

int e1/0

 ip ad 193.1.1.3 255.255.255.128


int e0/0

 ip ad 194.1.1.1 255.255.255.252


int lo0

 ip ad 193.1.1.193 255.255.255.192


router os 1

 network 193.1.1.193 0.0.0.0 area 0

 network 193.1.1.3 0.0.0.0 area 0

 network 194.1.1.1 0.0.0.0 area 2



// R4 //

int e0/0

 ip ad 194.1.1.2 255.255.255.252


int e1/0

 ip ad 130.1.4.4 255.255.255.0


router os 1

 network 194.1.1.2 0.0.0.0 area 2


router rip

 network 130.1.0.0



// R5 //

int e1/0

 ip ad 130.1.4.5 255.255.255.0


int lo1

 ip ad 130.1.1.1 255.255.255.0


int lo2

 ip ad 130.1.2.1 255.255.255.0


int lo3

 ip ad 130.1.3.1 255.255.255.0


int lo5

 ip ad 130.1.5.1 255.255.255.0


int lo6

 ip ad 130.1.6.1 255.255.255.0


int lo7

 ip ad 130.1.7.1 255.255.255.0


router rip

 network 130.1.0.0



基本配置完成後,我們首選來驗證一下。


r1#sh ip ro

    130.1.0.0/24 is subnetted, 7 subnets
O E2    130.1.3.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.2.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.1.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.7.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.6.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.5.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
O E2    130.1.4.0 [110/10] via 192.1.1.2, 00:00:03, Ethernet0/0
    193.1.1.0/24 is variably subnetted, 3 subnets, 2 masks
O IA    193.1.1.192/26 [110/21] via 192.1.1.2, 00:00:48, Ethernet0/0
O IA    193.1.1.128/26 [110/11] via 192.1.1.2, 00:00:48, Ethernet0/0
O IA    193.1.1.0/25 [110/20] via 192.1.1.2, 00:00:48, Ethernet0/0
    192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.0 is directly connected, Ethernet0/0
    194.1.1.0/30 is subnetted, 1 subnets
O IA    194.1.1.0 [110/30] via 192.1.1.2, 00:39:39, Ethernet0/0



在我們彙總完成後,上述結果裏,紅、藍色顯示部分將會被取代。方法如下:


區域間彙總:

// R2 //

router os 1

area 0 range 193.1.1.0 255.255.255.0


// R3 //

router os 1

area 0 range 193.1.1.0 255.255.255.0


外部路由彙總:

// R4 //

router os 1

summary-address 130.1.0.0 255.255.248.0



驗證如下:

r1#sh ip ro

    130.1.0.0/21 is subnetted, 1 subnets
O E2    130.1.0.0 [110/10] via 192.1.1.2, 00:00:02, Ethernet0/0
O IA 193.1.1.0/24 [110/11] via 192.1.1.2, 00:00:13, Ethernet0/0
    192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.0 is directly connected, Ethernet0/0
    194.1.1.0/30 is subnetted, 1 subnets
O IA    194.1.1.0 [110/30] via 192.1.1.2, 00:47:19, Ethernet0/0

③OSPF鄰居認證實際案例

拓撲圖:

鄰居認證使得路由器確認每次所收到的路由更新的源。如果關鍵字不匹配,就會拒絕路由更新。


思科使用兩種類型的鄰居認證:純文本和MD5。


純文本認證發一個關鍵字,這個關鍵字是明文傳輸,可被非法用戶所竊取,所以不推薦使用。


MD5認證發一個報文摘要,而不是關鍵字。MD5被用來生成一個關鍵字的散列。這個散列是被髮送的對象。MD5方式不易被非法用戶所竊取。


這個案例中,我們在R1與R2之間使用明文認證,在R2與R3之間使用MD5認證。



/ / R1 / /

INT E0 / 0

 IP廣告192.1.1.1 255.255.255.0

 思科IP OSPF認證密鑰/ /明文認證,關鍵字爲思科


路由器操作系統1

 網絡192.1.1.1 0.0.0.0區域0

 區域0認證



/ / R2 / /

INT E0 / 0

 IP廣告192.1.1.2 255.255.255.0

 思科IP OSPF認證密鑰/ /明文認證,關鍵字爲思科


中期E1 / 0

 IP廣告193.1.1.2 255.255.255.0

 IP OSPF消息摘要鍵1 MD5餅乾


路由器操作系統1

 網絡192.1.1.2 0.0.0.0區域0

 網絡193.1.1.2 0.0.0.0面積1

 區域0認證

 面積1認證信息摘要



/ / R3 / /

中期E1 / 0

 IP AD 193.1.1.3 255.255.255.0

 IP OSPF消息摘要鍵1 MD5餅乾


路由器操作系統1

 網絡193.1.1.3 0.0.0.0 1

 面積1認證信息摘要




驗證過程:

R1#sh的IP OS INT E0 / 0
端口Ethernet0 / 0,線路協議是
 互聯網地址192.1.1.1/24,面積
 1 0 進程ID,路由器ID 192.1.1.1,網絡類型廣播,成本:10
 發送延遲1國家BDR,優先級1
 指定路由器193.1.1.2(ID),接口地址192.1.1.2
 備份指定路由器192.1.1.1(ID),接口地址192.1.1.1
 配置的定時器的時間間隔,你好10,死40 秒,等待40,重發5
   您好由於00:00:06
 指數1/1,洪水隊列長度爲0的
 下一個0x0的(0)/ 0X0(0)
 最近洪水掃描長度爲1,最大爲1
 最後水災掃描時間爲0毫秒,最大爲0毫秒
 鄰居數爲1時,相鄰的鄰居數爲1
   相鄰的鄰居193.1.1.2(指定路由器)
 抑制打招呼0鄰居(次)簡單密碼認證


R2#SH IP OS INT E0 / 0
端口Ethernet0 / 0,線路協議是
 互聯網地址192.1.1.2/24,面積
 1 0 進程ID,路由器ID 193.1.1.2,網絡類型廣播,成本:10
 發送延遲1國家DR,優先級1
 指定路由器193.1.1.2(ID),接口地址192.1.1.2
 備份指定路由器(ID)192.1.1.1,接口地址192.1.1.1
 配置的定時器的時間間隔,你好10,死40 秒,等待40,重發5
   您好○時00分04秒
 指數1/1,洪水隊列長度爲0的
 下一個0x0的(0)/ 0X0(0)
 最近洪水掃描長度爲1,最大爲2
 最新洪水掃描時間爲0毫秒,最大爲0毫秒
 鄰居計數爲1,相鄰的鄰居計數是
   相鄰的鄰居192.1.1.1(備份指定路由器)
 禁止爲0的鄰居打招呼(次)簡單密碼認證


R2#SH IP OS E1 / 0
以太網1/0,線路協議是
 Internet地址的193.1.1.2/24區
 進程ID 1路由器ID 193.1.1.2,網絡類型廣播,成本:10
 發送延遲1國家DR,優先級1
 指定路由器193.1.1.2(ID),接口地址193.1.1.2
 備份指定路由器(ID)193.1.1.3,接口地址193.1.1.3
 配置的定時器的時間間隔,你好10,死40 秒,等待40,重發5
   你好,由於
 指數在0時00分03秒1/2,洪水隊列長度爲0的
 下一個0x0的(0)/ 0X0(0)
 最近洪水掃描長度爲2,最大的是2
 最後水災掃描時間爲0毫秒,最大爲0毫秒
 鄰居數爲1時,相鄰的鄰居數爲1
   相鄰的鄰居193.1.1.3(備份指定路由器)
 抑制打招呼的鄰居(0)  啓用消息摘要認證    最年輕的密鑰ID爲1


R3#sh的IP OS E1 / 0
以太網1/0,線路協議是
 Internet地址的193.1.1.3/24區
 進程ID 1路由器ID 193.1.1.3,網絡類型廣播,成本:10
 發送延遲1國家BDR,優先級1
 指定路由器193.1.1.2(ID),接口地址193.1.1.2
 備份指定路由器193.1.1.3(ID),接口地址193.1.1.3
 配置的定時器的時間間隔,你好10,死40 秒,等待40,重發5
   您好○時00分04秒
 指數1/1,洪水隊列長度爲0的
 下一個0x0的(0)/ 0X0(0)
 最近洪水掃描長度爲1,最大爲2
 最新洪水掃描時間爲0毫秒,最大爲0毫秒
 鄰居計數爲1,相鄰的鄰居數爲1
   相鄰的鄰居193.1.1.2(指定路由器)
 抑制打招呼  消息摘要認證啓用    年紀最小的鍵ID爲1 0鄰居(S)




爲了更進一步理解認證過程,我們可以打開DEBUG,並將R3的MD5認證鍵改爲5:

/ / R3 / /

調試IP OSPF ADJ


中期E1 / 0

 IP OSPF消息摘要鍵5 MD5餅乾


R3#
01:16:03:OSPF:接收封包從193.1.1.2,端口Ethernet1 / 0:不匹配驗證密鑰-沒有消息摘要鍵1接口
01:16:09:OSPF:發送最年輕的關鍵5



R3#顯示IP OSPF鄰居/ /觀察結果無法發現鄰居。


/ /認證未通過,無法與R2建立起鄰居關係。


當我們把MD5認證KEY改回1後,認證通過。



第二步實驗,我們把關鍵字進行修改:

/ / R3 / /

調試IP OSPF ADJ


中期E1 / 0

 IP OSPF消息摘要鍵1 MD5崔健


01:21:33:OSPF:接收封包從193.1.1.2,端口Ethernet1 / 0:不匹配驗證密鑰-消息摘要密鑰1
01:21:40:OSPF:發送,最年輕的關鍵1


我們要在實際工作中學會使用調試這個思科排錯的利器。


④OSPF虛鏈路(virtual-link)配置實例

拓撲圖:

這個配置將驗證一個OSPF虛電路(Virtual-Link)的過程,重點在觀察虛鏈路連接的臨時網絡與正常區域間路由有何區別。上圖中區域4(area 4)沒有和area 0直接相連。在R2與R3之間配置了一條虛鏈路。


// R1 //

int lo0

 ip ad 1.1.1.1 255.255.255.0


int e0

 ip ad 192.1.1.1 255.255.255.0


router os 1

 network 192.1.1.0 0.0.0.255 area 0



// R2 //

int lo0

 ip ad 2.2.2.2 255.255.255.0


int e0

 ip ad 192.1.1.2 255.255.255.0


int e1

 ip ad 193.1.1.2 255.255.255.0


router os 1

 network 192.1.1.0 0.0.0.255 area 0

 network 193.1.1.0 0.0.0.255 area 1



// R3 //

int lo0

 ip ad 3.3.3.3 255.255.255.0


int e1

 ip ad 193.1.1.3 255.255.255.0


int e0

 ip ad 194.1.1.3 255.255.255.0


router os 1

 network 193.1.1.0 0.0.0.255 area 1

 network 194.1.1.0 0.0.0.255 area 4



// R4 //

int lo0

 ip ad 4.4.4.4 255.255.255.0


int e0

 ip ad 194.1.1.4 255.255.255.0


router os 1

 network 194.1.1.0 0.0.0.255 area 4




基本配置完成後,我們在每臺路由器上分別來驗證一下:

r1#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:00:33    192.1.1.2       Ethernet0/0
r1#
r1#sh ip ro

    1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/20] via 192.1.1.2, 00:00:19, Ethernet0/0
C    192.1.1.0/24 is directly connected, Ethernet0/0

//注意R1上有關於193.1.1.0的路由條目,是屬於IA類型(域間路由)


r2#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:35    192.1.1.1       Ethernet0/0
3.3.3.3           1   FULL/BDR        00:00:35    193.1.1.3       Ethernet1/0
r2#
r2#
r2#sh ip ro

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
C    192.1.1.0/24 is directly connected, Ethernet0/0



r3#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:32    193.1.1.2       Ethernet1/0
4.4.4.4           1   FULL/DR         00:00:34    194.1.1.4       Ethernet0/0
r3#sh ip ro

    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
O IA 192.1.1.0/24 [110/20] via 193.1.1.2, 00:02:49, Ethernet1/0
C    194.1.1.0/24 is directly connected, Ethernet0/0
//注意R3中有關於192.1.1.0的路由是屬於IA類型(域間路由)


r4#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/BDR        00:00:33    194.1.1.3       Ethernet0/0
r4#sh ip ro

    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    194.1.1.0/24 is directly connected, Ethernet0/0
//R4上沒有關於AREA 0內的任何路由信息






我們下面在R2、R3上添加Virtual-link的配置:

R2:

router os 1

 area 1 virtual-link 3.3.3.3


R3:

router os 1

 area 1 virtual-link 2.2.2.2





對比之前的路由信息,看有何區別:

r1#sh ip ro
    1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/20] via 192.1.1.2, 00:00:01, Ethernet0/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
O IA 194.1.1.0/24 [110/30] via 192.1.1.2, 00:00:01, Ethernet0/0

//多了一條194網段的路由,類型IA(區域間)



r2#sh ip ro

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
O IA 194.1.1.0/24 [110/20] via 193.1.1.3, 00:00:06, Ethernet1/0

//多了一條194網段路由,類型爲IA(區域間)


r3#sh ip ro

    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
O    192.1.1.0/24 [110/20] via 193.1.1.2, 00:02:56, Ethernet1/0
C    194.1.1.0/24 is directly connected, Ethernet0/0

//R3的192路由原本爲IA類型(區域間),現在轉爲O類型(區域內),說明R3認爲自已與192網段是直連的。虛鏈路相當於將R3直接連接了AREA 0 與 AREA 4區域



r4#sh ip ro

    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/20] via 194.1.1.3, 00:03:40, Ethernet0/0
O IA 192.1.1.0/24 [110/30] via 194.1.1.3, 00:03:25, Ethernet0/0
C    194.1.1.0/24 is directly connected, Ethernet0/0

//R4上192路由類型IA(區域間)



最後我們將虛鏈路效果再與正常連接方式進行一下比對,如下圖:

驗證如下:

r1#sh ip ro
    1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/20] via 192.1.1.2, 00:00:41, Ethernet0/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
C    192.2.2.0/24 is directly connected, Ethernet1/0
O IA 194.1.1.0/24 [110/20] via 192.2.2.4, 00:00:39, Ethernet1/0




r2#sh ip ro

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
O    192.2.2.0/24 [110/20] via 192.1.1.1, 00:01:04, Ethernet0/0
O IA 194.1.1.0/24 [110/30] via 192.1.1.1, 00:00:03, Ethernet0/0
r2#



r3#sh ip ro

    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
O IA 192.1.1.0/24 [110/20] via 193.1.1.2, 00:01:31, Ethernet1/0
O IA 192.2.2.0/24 [110/30] via 193.1.1.2, 00:01:15, Ethernet1/0
O IA 194.1.1.0/24 [110/40] via 193.1.1.2, 00:00:15, Ethernet1/0



r4#sh ip ro
    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/30] via 192.2.2.1, 00:00:39, Ethernet1/0
O    192.1.1.0/24 [110/20] via 192.2.2.1, 00:01:37, Ethernet1/0
C    192.2.2.0/24 is directly connected, Ethernet1/0
C    194.1.1.0/24 is directly connected, Ethernet0/0



r5#sh ip ro

    5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/40] via 194.1.1.4, 00:00:52, Ethernet0/0
O IA 192.1.1.0/24 [110/30] via 194.1.1.4, 00:00:52, Ethernet0/0
O IA 192.2.2.0/24 [110/20] via 194.1.1.4, 00:00:52, Ethernet0/0
C    194.1.1.0/24 is directly connected, Ethernet0/0





如果上述方式還不容易理解,你也可以將virtual-link可以想象成:將R2與R3合併成一臺路由器,如下圖:

r1#sh ip ro

    1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/20] via 192.1.1.2, 00:00:57, Ethernet0/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
O IA 194.1.1.0/24 [110/74] via 192.1.1.2, 00:00:24, Ethernet0/0



r2#sh ip ro

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
C    192.1.1.0/24 is directly connected, Ethernet0/0
C    194.1.1.0/24 is directly connected, Serial2/0




r3#sh ip ro

    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
C    193.1.1.0/24 is directly connected, Ethernet1/0
O IA 192.1.1.0/24 [110/20] via 193.1.1.2, 00:01:06, Ethernet1/0
O IA 194.1.1.0/24 [110/74] via 193.1.1.2, 00:00:37, Ethernet1/0



r4#sh ip ro

    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
O IA 193.1.1.0/24 [110/74] via 194.1.1.2, 00:00:17, Serial2/0
O IA 192.1.1.0/24 [110/74] via 194.1.1.2, 00:00:17, Serial2/0
C    194.1.1.0/24 is directly connected, Serial2/0

⑤在NBMA網絡廣播模式下配置OSPF實際案例

拓撲圖:

廣播式網絡是一個漸進的操作過程,它可以定義所有鄰居。當給一個接口配置廣播時,這個接口就好像是連入了LAN中,網絡中仍要選出DR和BDR,需特別保證路由器選出的DR/BDR與網絡中所有路由器都有物理連接。使用接口命令ip ospf network broadcast可以向所有路由器上設置網絡類型。R2、R4的串行接口被配置成OSPF PRIORITY爲0,這將保證R3成爲DR。// 幀交換機frame-relay switchingint s2/0  encapsulation frame-relay  clock rate 64000  frame-relay intf-type dce  frame-relay route 200 int s3/0 300int s3/0  encapsulation frame-relay  clock rate 64000  frame-relay intf-type dce  frame-relay route 300 int s2/0 200  frame-relay route 399 int s4/0 400int s4/0  encapsulation frame-relay  clock rate 64000  frame-relay intf-type dce  frame-relay route 400 int s2/0 399// R2 //int lo0  ip ad 2.2.2.2 255.255.255.0int s2/0  encapsulation frame-relayip ospf network broadcast    //將OSPF網絡類型設置爲廣播模式ip ospf priority 0    //優先級爲0,不參與DR選舉  ip ad 192.1.1.2 255.255.255.0  frame-relay map ip 192.1.1.3 200 broadcast  frame-relay map ip 192.1.1.4 200 broadcastrouter os 1  network 2.2.2.2 0.0.0.0 area 0  network 192.1.1.2 0.0.0.0 area 0// R3 //int lo0  ip ad 3.3.3.3 255.255.255.0int s3/0  encapsulation frame-relayip ospf network broadcast    //將OSPF網絡類型設置爲廣播模式  ip address 192.1.1.3 255.255.255.0  frame-relay map ip 192.1.1.2 300 broadcast  frame-relay map ip 192.1.1.4 399 broadcastrouter os 1  network 3.3.3.3 0.0.0.0 area 0  network 192.1.1.3 0.0.0.0 area 0// R4 //int lo0  ip ad 4.4.4.4 255.255.255.0int s4/0  encapsulation frame-relay  ip ad 192.1.1.4 255.255.255.0ip ospf network broadcast    //將OSPF網絡類型設置爲廣播模式  ip ospf priority 0    //優先級爲0,不參與DR選舉  frame-relay map ip 192.1.1.2 400 broadcast  frame-relay map ip 192.1.1.3 400 broadcastrouter os 1  network 4.4.4.4 0.0.0.0 area 0  network 192.1.1.4 0.0.0.0 area 0驗證過程:一、首先來檢查DR選舉是否按我們的設計,R3被選舉爲DR,R2、R4不參與選舉,同時注意網絡類型是否爲NBMA,hello時間間隔是否爲30秒。。。。。。r3#sh ip os int s3/0
Serial3/0 is up, line protocol is up
 Internet Address 192.1.1.3/24, Area 0
 Process ID 1, Router ID 3.3.3.3, Network Type BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DR, Priority 1
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
   Hello due in 00:00:27
 Index 2/2, flood queue length 0
 Next 0x0(0)/0x0(0)
 Last flood scan length is 2, maximum is 2
 Last flood scan time is 0 msec, maximum is 0 msec
 Neighbor Count is 2, Adjacent neighbor count is 2
   Adjacent with neighbor 4.4.4.4
   Adjacent with neighbor 2.2.2.2
 Suppress hello for 0 neighbor(s)r2#sh ip os int s2/0
Serial2/0 is up, line protocol is up
 Internet Address 192.1.1.2/24, Area 0
 Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DROTHER, Priority 0
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
   Hello due in 00:00:06
 Index 2/2, 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 3.3.3.3  (Designated Router)
 Suppress hello for 0 neighbor(s)r4#sh ip ospf int s4/0
Serial4/0 is up, line protocol is up
 Internet Address 192.1.1.4/24, Area 0
 Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DROTHER, Priority 0
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
   Hello due in 00:00:05
 Index 2/2, 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 3.3.3.3  (Designated Router)
 Suppress hello for 0 neighbor(s)
二、接下來觀察各路由器鄰居建立情況:r2#sh ip os neiNeighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:01:50    192.1.1.3       Serial2/0r3#sh ip os neiNeighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           0   FULL/DROTHER    00:01:41    192.1.1.4       Serial3/0
2.2.2.2           0   FULL/DROTHER    00:01:30    192.1.1.2       Serial3/0r3#sh ip os neiNeighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:01:48    192.1.1.3       Serial4/0三、最後驗證路由:r2#sh ip ro        2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:00:17, Serial2/0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.1.1.4, 00:00:17, Serial2/0
C    192.1.1.0/24 is directly connected, Serial2/0r3#sh ip ro     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.1.1.2, 00:00:38, Serial3/0
    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.1.1.4, 00:00:38, Serial3/0
C    192.1.1.0/24 is directly connected, Serial3/0r4#sh ip ro     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.1.1.2, 00:01:04, Serial4/0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:01:04, Serial4/0
    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    192.1.1.0/24 is directly connected, Serial4/0
r4#



如果我們將R2路由器的優先級調整爲10,重啓後R2將成爲DR,R3作爲BDR,R4作爲DROTHER,這樣的結果會導致R4無法收到R2、R3的路由更新,原因如下:


r4#sh ip ospf database

           OSPF Router with ID (4.4.4.4) (Process ID 1)

               Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
2.2.2.2         2.2.2.2         99          0x80000009 0xCF69   2
3.3.3.3         3.3.3.3         109         0x8000000B 0xDF4A   2
4.4.4.4         4.4.4.4         107         0x8000000C 0xFB1F   2

               Net Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum
192.1.1.2       2.2.2.2         108         0x80000001 0x4910


r4#sh ip os database router

           OSPF Router with ID (4.4.4.4) (Process ID 1)

               Router Link States (Area 0)

Adv Router is not-reachable
 LS age: 124
 Options: (No TOS-capability, DC)
 LS Type: Router Links
 Link State ID: 2.2.2.2
 Advertising Router: 2.2.2.2
 LS Seq Number: 80000009
 Checksum: 0xCF69
 Length: 48
 Number of Links: 2

   Link connected to: a Transit Network
    (Link ID) Designated Router address: 192.1.1.2
    (Link Data) Router Interface address: 192.1.1.2
     Number of TOS metrics: 0
      TOS 0 Metrics: 64

   Link connected to: a Stub Network
    (Link ID) Network/subnet number: 2.2.2.2
    (Link Data) Network Mask: 255.255.255.255
     Number of TOS metrics: 0
      TOS 0 Metrics: 1


Adv Router is not-reachable
 LS age: 198
 Options: (No TOS-capability, DC)
 LS Type: Router Links
 Link State ID: 3.3.3.3
 Advertising Router: 3.3.3.3
 LS Seq Number: 8000000B
 Checksum: 0xDF4A
 Length: 48
 Number of Links: 2

   Link connected to: a Transit Network
    (Link ID) Designated Router address: 192.1.1.2
    (Link Data) Router Interface address: 192.1.1.3
     Number of TOS metrics: 0
      TOS 0 Metrics: 64

   Link connected to: a Stub Network
    (Link ID) Network/subnet number: 3.3.3.3
    (Link Data) Network Mask: 255.255.255.255
     Number of TOS metrics: 0
      TOS 0 Metrics: 1


 LS age: 215
 Options: (No TOS-capability, DC)
 LS Type: Router Links
 Link State ID: 4.4.4.4
 Advertising Router: 4.4.4.4
 LS Seq Number: 8000000C
 Checksum: 0xFB1F
 Length: 48
 Number of Links: 2

   Link connected to: a Transit Network
    (Link ID) Designated Router address: 192.1.1.3
    (Link Data) Router Interface address: 192.1.1.4
     Number of TOS metrics: 0
      TOS 0 Metrics: 64

   Link connected to: a Stub Network
    (Link ID) Network/subnet number: 4.4.4.4
    (Link Data) Network Mask: 255.255.255.255
     Number of TOS metrics: 0
      TOS 0 Metrics: 1

⑥在NBMA網絡點到多點模式下配置OSPF實際案例

拓撲圖:

一個點到多點網絡被看作若干具有一個或多個鄰居的點到點接口。當一個接口被配置給點到多點網絡,就不需要DR/BDR,不需要定義鄰居,這大大簡化了給NBMA網絡配置OSPF。


使用端口命令 ip ospa network point-to-multioint可以給所有路由器設置網絡類型。既不需要定義鄰居,也不需要設置優先級,因爲網絡中沒有DR/BDR。


// 幀交換機

frame-relay switching


int s2/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 200 int s3/0 300


int s3/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 300 int s2/0 200

 frame-relay route 399 int s4/0 400


int s4/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 400 int s2/0 399



// R2 //

int lo0  ip ad 2.2.2.2 255.255.255.0

int s2/0

 encapsulation frame-relay

 ip ad 192.1.1.2 255.255.255.0

 ip ospf network point-to-multipoint    //改變接口模式爲點到多點

 frame-relay map ip 192.1.1.3 200 broadcast

 frame-relay map ip 192.1.1.4 200 broadcast


router os 1

 network 2.2.2.2 0.0.0.0 area 0

 network 192.1.1.2 0.0.0.0 area 0



// R3 //

int lo0

 ip ad 3.3.3.3 255.255.255.0


int s3/0

 encapsulation frame-relay

 ip address 192.1.1.3 255.255.255.0

 ip ospf network point-to-multipoint    //改變接口模式爲點到多點

 frame-relay map ip 192.1.1.2 300 broadcast

 frame-relay map ip 192.1.1.4 399 broadcast


router os 1

 network 3.3.3.3 0.0.0.0 area 0

 network 192.1.1.3 0.0.0.0 area 0


// R4 //

int lo0

 ip ad 4.4.4.4 255.255.255.0


int s4/0

 encapsulation frame-relay

 ip ad 192.1.1.4 255.255.255.0

 ip ospf network point-to-multipoint    //改變接口模式爲點到多點

 frame-relay map ip 192.1.1.2 400 broadcast

 frame-relay map ip 192.1.1.3 400 broadcast


router os 1

 network 4.4.4.4 0.0.0.0 area 0

 network 192.1.1.4 0.0.0.0 area 0


注意上述配置中沒有任何特別操作,比如使用neighbor命令指明鄰居,設置OSPF優先級等等,這就是點到多點模式下的特點。



驗證過程:

一、首先來檢查DR選舉是否按我們的設計,R3被選舉爲DR,R2、R4不參與選舉,同時注意網絡類型是否爲NBMA,hello時間間隔是否爲30秒。。。。。。


r3#sh ip os int s3/0
Serial3/0 is up, line protocol is up
 Internet Address 192.1.1.3/24, Area 0
 Process ID 1, Router ID 3.3.3.3, Network Type POINT_TO_MULTIPOINT, Cost: 64
 Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:18
 Index 2/2, flood queue length 0
 Next 0x0(0)/0x0(0)
 Last flood scan length is 1, maximum is 2
 Last flood scan time is 0 msec, maximum is 0 msec
 Neighbor Count is 2, Adjacent neighbor count is 2
   Adjacent with neighbor 4.4.4.4
   Adjacent with neighbor 2.2.2.2
 Suppress hello for 0 neighbor(s)



r2#sh ip os int s2/0
Serial2/0 is up, line protocol is up
 Internet Address 192.1.1.2/24, Area 0
 Process ID 1, Router ID 2.2.2.2, Network Type POINT_TO_MULTIPOINT, Cost: 64
 Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:01
 Index 2/2, flood queue length 0
 Next 0x0(0)/0x0(0)
 Last flood scan length is 1, maximum is 2
 Last flood scan time is 0 msec, maximum is 0 msec
 Neighbor Count is 1, Adjacent neighbor count is 1
   Adjacent with neighbor 3.3.3.3
 Suppress hello for 0 neighbor(s)



r4#sh ip ospf int s4/0
Serial4/0 is up, line protocol is up
 Internet Address 192.1.1.4/24, Area 0
 Process ID 1, Router ID 4.4.4.4, Network Type POINT_TO_MULTIPOINT, Cost: 64
 Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:02
 Index 2/2, 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 3.3.3.3
 Suppress hello for 0 neighbor(s)



二、接下來觀察各路由器鄰居建立情況:

r2#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/  -        00:01:33    192.1.1.3       Serial2/0


r3#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           1   FULL/  -        00:01:56    192.1.1.4       Serial3/0
2.2.2.2           1   FULL/  -        00:01:36    192.1.1.2       Serial3/0


r4#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/  -        00:01:37    192.1.1.3       Serial4/0



三、最後驗證路由:

r2#sh ip ro  

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:08:30, Serial2/0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/129] via 192.1.1.3, 00:08:30, Serial2/0
    192.1.1.0/24 is variably subnetted, 3 subnets, 2 masks
C       192.1.1.0/24 is directly connected, Serial2/0
O       192.1.1.3/32 [110/64] via 192.1.1.3, 00:08:30, Serial2/0
O       192.1.1.4/32 [110/128] via 192.1.1.3, 00:08:30, Serial2/0




r3#sh ip ro


    2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.1.1.2, 00:08:54, Serial3/0
    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.1.1.4, 00:08:54, Serial3/0
    192.1.1.0/24 is variably subnetted, 3 subnets, 2 masks
C       192.1.1.0/24 is directly connected, Serial3/0
O       192.1.1.2/32 [110/64] via 192.1.1.2, 00:08:54, Serial3/0
O       192.1.1.4/32 [110/64] via 192.1.1.4, 00:08:54, Serial3/0




r4#sh ip ro

    2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/129] via 192.1.1.3, 00:09:20, Serial4/0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:09:20, Serial4/0
    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
    192.1.1.0/24 is variably subnetted, 3 subnets, 2 masks
C       192.1.1.0/24 is directly connected, Serial4/0
O       192.1.1.2/32 [110/128] via 192.1.1.3, 00:09:20, Serial4/0
O       192.1.1.3/32 [110/64] via 192.1.1.3, 00:09:20, Serial4/0



注意,在點到多點或點到點模式下,路由表中會自動生成32位主機路由。

⑦在NBMA網絡非廣播模式下配置OSPF實際案例

拓撲圖:

當在NBMA網絡(如幀中繼、ATM)中配置OSPF,必須注意哪個路由器是網絡的DR和BDR,DR和BDR要求與網絡中的所有路由器都有完全的邏輯連接。


同時,根據所使用的是四種網絡類型中的哪一種(廣播式、非廣播式、點到點、點到多點),有必要使用額外的配置。


這個實驗是在非廣播的NBMA幀中繼網絡中使用了OSPF。這種類型是幀中繼網絡中物理接口的缺省類型。在非廣播式網絡中,存在一個DR或 BDR,這要根據網絡的性能,這要根據網絡的性能,這個DR和BDR必須有一個包含所有處於幀中繼的路由器的靜態表,在OSPF進程中使用鄰居命令可以完 成這個任務。


對於這個實驗,DR是路由器3,因爲它具有與網絡上其它所有路由器的完整的物理連接。如上圖表示。


// 幀交換機

frame-relay switching


int s2/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 200 int s3/0 300


int s3/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 300 int s2/0 200

 frame-relay route 399 int s4/0 400


int s4/0

 encapsulation frame-relay

 clock rate 64000

 frame-relay intf-type dce

 frame-relay route 400 int s2/0 399



// R2 //

int lo0  ip ad 2.2.2.2 255.255.255.0

int s2/0

 encapsulation frame-relay

ip ospf priority 0    //優先級爲0,不參與DR選舉

 ip ad 192.1.1.2 255.255.255.0

 frame-relay map ip 192.1.1.3 200 broadcast

 frame-relay map ip 192.1.1.4 200 broadcast


router os 1

 network 2.2.2.2 0.0.0.0 area 0

 network 192.1.1.2 0.0.0.0 area 0



// R3 //

int lo0

 ip ad 3.3.3.3 255.255.255.0


int s3/0

 encapsulation frame-relay

 ip address 192.1.1.3 255.255.255.0

 frame-relay map ip 192.1.1.2 300 broadcast

 frame-relay map ip 192.1.1.4 399 broadcast


router os 1

 network 3.3.3.3 0.0.0.0 area 0

 network 192.1.1.3 0.0.0.0 area 0

 neighbor 192.1.1.2    //NBMA模式下OSPF必須手動指定鄰居

 neighbor 192.1.1.4    //NBMA模式下OSPF必須手動指定鄰居



// R4 //

int lo0

 ip ad 4.4.4.4 255.255.255.0


int s4/0

 encapsulation frame-relay

 ip ad 192.1.1.4 255.255.255.0

 ip ospf priority 0    //優先級爲0,不參與DR選舉

 frame-relay map ip 192.1.1.2 400 broadcast

 frame-relay map ip 192.1.1.3 400 broadcast


router os 1

 network 4.4.4.4 0.0.0.0 area 0

 network 192.1.1.4 0.0.0.0 area 0





驗證過程:

一、首先來檢查DR選舉是否按我們的設計,R3被選舉爲DR,R2、R4不參與選舉,同時注意網絡類型是否爲NBMA,hello時間間隔是否爲30秒。。。。。。


r3#sh ip os int s3/0
Serial3/0 is up, line protocol is up
 Internet Address 192.1.1.3/24, Area 0
 Process ID 1, Router ID 3.3.3.3, Network Type NON_BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DR, Priority 1
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:27
 Index 2/2, flood queue length 0
 Next 0x0(0)/0x0(0)
 Last flood scan length is 2, maximum is 2
 Last flood scan time is 0 msec, maximum is 0 msec
 Neighbor Count is 2, Adjacent neighbor count is 2
   Adjacent with neighbor 4.4.4.4
   Adjacent with neighbor 2.2.2.2
 Suppress hello for 0 neighbor(s)



r2#sh ip os int s2/0
Serial2/0 is up, line protocol is up
 Internet Address 192.1.1.2/24, Area 0
 Process ID 1, Router ID 2.2.2.2, Network Type NON_BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DROTHER, Priority 0
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:20
 Index 2/2, 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 3.3.3.3  (Designated Router)
 Suppress hello for 0 neighbor(s)



r4#sh ip ospf int s4/0
Serial4/0 is up, line protocol is up
 Internet Address 192.1.1.4/24, Area 0
 Process ID 1, Router ID 4.4.4.4, Network Type NON_BROADCAST, Cost: 64
 Transmit Delay is 1 sec, State DROTHER, Priority 0
 Designated Router (ID) 3.3.3.3, Interface address 192.1.1.3
 No backup designated router on this network
 Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
   Hello due in 00:00:05
 Index 2/2, 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 3.3.3.3  (Designated Router)
 Suppress hello for 0 neighbor(s)


二、接下來觀察各路由器鄰居建立情況:

r2#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:01:50    192.1.1.3       Serial2/0


r3#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
4.4.4.4           0   FULL/DROTHER    00:01:41    192.1.1.4       Serial3/0
2.2.2.2           0   FULL/DROTHER    00:01:30    192.1.1.2       Serial3/0


r3#sh ip os nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           1   FULL/DR         00:01:48    192.1.1.3       Serial4/0



三、最後驗證路由:

r2#sh ip ro  

    2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:00:17, Serial2/0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.1.1.4, 00:00:17, Serial2/0
C    192.1.1.0/24 is directly connected, Serial2/0




r3#sh ip ro

    2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.1.1.2, 00:00:38, Serial3/0
    3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
    4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.1.1.4, 00:00:38, Serial3/0
C    192.1.1.0/24 is directly connected, Serial3/0




r4#sh ip ro

    2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.1.1.2, 00:01:04, Serial4/0
    3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 192.1.1.3, 00:01:04, Serial4/0
    4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    192.1.1.0/24 is directly connected, Serial4/0

⑧rip協議與單區域ospf

拓撲圖:

配置過程如下:

1、各路由器設備端口配置:

R1

R2

R3

2、未配置任何協議前各路由器的路由表

R1


R2

R3

3、各路由器配置相關協議

R1

R2

R3

4、各路由器相關協議配置過後的路由表

R1

R2

R3

5、驗證互通性:

R2 ping R3

R3 ping  R2

⑨rip協議與多區域ospf

拓撲圖:

端口及協議配置結果:

R1

R2

R3

R4

R5

R6

每個路由器都已經配置了相關的協議以及端口ip,下面需要在R2配置路由轉發功能,使rip協議網絡能夠發送數據到ospf協議網絡。由於已知rip協議網絡爲小型網絡,故不能夠將ospf網絡數據路由轉發給rip網絡,需要在rip與ospf臨界區域的路由器配置默認路由,能夠解決ospf網絡與rip網絡基本的通信,但不會對rip網絡區域的路由器造成堵塞或者壓力。解決方法的配置過程如下:

配置默認路由後的路由表:

R5

R6

驗證實驗結果:

R1 ping R4

R1 ping R6

R6 ping R1

R6 ping R4

這些都是常用的ospf協議的應用案例。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章