? ? 這篇文檔主要是針對OSPF在NBMA網(wǎng)絡(luò)中運行的五種模式,由于這五種模式一直是比較難理解的部分荚孵,文檔會結(jié)合實驗拓?fù)鋱D以及對實驗配置結(jié)果的分析對五種模式進(jìn)行詳細(xì)闡述妹窖。仔細(xì)閱讀并按照我的操作步驟進(jìn)行實驗配置,絕對會讓你醍醐灌頂收叶。最后還是歡迎各位大牛提出寶貴意見骄呼。
1. OSPF在網(wǎng)絡(luò)中運行模式產(chǎn)生的原因
? ? ? 由于在本文中,只介紹NBMA網(wǎng)絡(luò)中的FR網(wǎng)絡(luò),所以以下的NBMA網(wǎng)絡(luò)將由FR網(wǎng)絡(luò)代替蜓萄。
? ? ? ? FR網(wǎng)絡(luò)沒有廣播功能隅茎,而OSPF利用組播傳送LSA報文,在FR網(wǎng)絡(luò)中為了實現(xiàn)廣播或者多播功能嫉沽,路由器復(fù)制要廣播或者多播的分組辟犀,并通過永久虛電路(PVC)發(fā)到所有目的地。該過程需要占用大量的CPU和帶寬绸硕。并且堂竟,如果FR網(wǎng)絡(luò)不是全網(wǎng)互聯(lián),例如我們常見的hub-spoken拓?fù)涞腇R網(wǎng)絡(luò)玻佩,那么路由發(fā)送的信息就不會到達(dá)所有的目的路由器出嘹,也就無法保證OSPF的正常運行。
? ? ? ? 為了解決上述問題咬崔,RFC定義了OSPF在NBMA網(wǎng)絡(luò)中的兩種運行模式税稼,Cisco在此基礎(chǔ)上增加了三種運行模式,共五種運行模式垮斯。通過定義這五種運行模式郎仆,克服了OSPF在幀中繼網(wǎng)絡(luò)中運行存在的問題。
2. OSPF在幀中繼網(wǎng)絡(luò)運行的五種模式
五種運行模式分別為:
non-broadcast兜蠕,point-to-multipoint丸升,point-to-multipoint
non-broadcast,P2P,Broadcast牺氨。
其中前兩種是RFC定義的,Cisco支持以上五種墩剖。
要修改OSPF的運行模式猴凹,可以使用命令:
在本實驗中需要提前掌握的知識點為:
(1)幀中繼網(wǎng)絡(luò)的基本配置
(2)幀中繼網(wǎng)絡(luò)中動態(tài)映射和靜態(tài)配置的區(qū)別
(3)幀中繼網(wǎng)絡(luò)中全互連和hub-spoken結(jié)構(gòu)的區(qū)別
(4)OSPF的基本配置
3:五種運行模式的區(qū)別
模式一:non-broadcast模式
? ? ?此種模式為OSPF在幀中繼網(wǎng)絡(luò)中默認(rèn)的運行模式,在此模式下岭皂,OSPF模仿在廣播網(wǎng)絡(luò)上的運行模式郊霎。如果是一個全互連(Full-Mesh)的幀中繼網(wǎng)絡(luò),不需要指定鄰居爷绘;如果是一個非全互連(Partial-Mesh)的幀中繼網(wǎng)絡(luò)书劝,則需要手動指定鄰居。當(dāng)網(wǎng)絡(luò)中鄰居不多時土至,non-broadcast是在NBMA網(wǎng)絡(luò)中運行OSPF效率最高的方式购对。
在本試驗中,采用的是hub-spoken結(jié)構(gòu)陶因,屬于非全互連骡苞,所以需要手動指定鄰居
模式二:broadcast模式
? ? 當(dāng)運行OSPF的接口設(shè)置為broadcast模式后,此時NBMA網(wǎng)絡(luò)完全看作是一個廣播型鏈路,類似于以太網(wǎng)解幽。此種選舉模式中贴见,需要選舉DR和BDR。
請注意:在本模式下躲株,有兩條關(guān)鍵命令:
第一條:
frame-relaymap ip ip-address??DLCI號? broadcast
關(guān)鍵字broadcast選項表明可以在這條VC上傳播broadcast,multicast幀片部,所以O(shè)SPF的組播報文就可以正常傳輸,保證了路由協(xié)議的正常運行霜定。
第二條:
ip ospf?priority
由于OSPF的hello報文的TTL值為1档悠,只能傳輸1跳。在Hub&Spoken模式下然爆,為了解決OSPF運行混亂問題站粟,需要通過手動配置方式,將DR固定在Hub端曾雕。解決方式是將處于Hub的路由器的接口的優(yōu)先級大于0奴烙,其余Spoken端的路由器的接口均為0。
模式三:點到多點(Point-to-multipoint)
? ? 在此模式中剖张,將所有路由器與路由器之間的連接看作是多個點到點鏈路的集合切诀。無需手動指定鄰居,也無需手動指定DR和BDR搔弄。
模式四:點到多點非廣播(Point-to-multipoint? non-broadcast)
? ? ?此種模式下幅虑,需要手動指定鄰居。
模式五:點到點(point to point)
? ? 此模式運用于點到點子接口顾犹。將路由器之間的互聯(lián)看作是多條點與點鏈路的集合倒庵。與point-to-multipoint的區(qū)別在于,point-to-point將Hub端的接口劃分為多個邏輯子接口炫刷,點與點子接口之間的連接看作是專用VC擎宝。每條VC采用組播224.0.0.5發(fā)送協(xié)議報文,無需選舉DR和BDR浑玛。
請注意:point-to-point和point-to-multipoint的雖然都可以看作是多個點到點鏈路的集合绍申,但是他們的的區(qū)別在于:hello間隔和死亡時間間隔不一樣浴骂。
四:實驗拓?fù)鋱D
五:實驗配置及結(jié)果分析
首先對四臺路由器做基本的配置:
基本的配置如下:
R0(config)#hostname FRS
FRS(config)#frame-relay switching
FRS(config)#int s0/1
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 102 int?s0/2 201
FRS(config-if)#frame-relay route 103 int?s0/3 301
FRS(config-if)#no shutdown
FRS(config-if)#int s0/2
FRS(config-if)#no shu
FRS(config-if)#clock rate 64000
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 201 int?s0/1 102
FRS(config)#int s0/3
FRS(config-if)#encapsulation frame-relay
FRS(config-if)#clock rate 64000
FRS(config-if)#frame-relay lmi-type cisco
FRS(config-if)#frame-relay intf-type dce
FRS(config-if)#frame-relay route 301 int?s0/1 103
以上為FRS(幀中繼交換機(jī))的基本配置燃少,在這里請一定注意肮之,本實驗采用的是hub-spoken結(jié)構(gòu)舞萄,所以在路由器R2和R3之間彬伦,并沒有進(jìn)行接口的映射配置什往。
FRS(config-if)#do show frame-relay rou////查看接口輸入和輸出對應(yīng)的DLCI
? ? ?第一條命令的含義是:路由器從接口s0/1接口到DLCI=102的數(shù)據(jù)幀包蓝,需要從s0/2接口輸出糖权,并且將DLCI替換為201.其余命令的含義類似厕隧。
對路由器R1和R2和R3進(jìn)行基本的配置
R1(config)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config)#int s0/1
R1(config-if)#no shu
R1(config-if)#no shutdown
R1(config-if)#ip add 192.168.123.1?255.255.255.0
R1(config-if)#encapsulation frame-relay
R1(config-if)#frame-relay lmi-type cisco
R1(config-if)#frame-relay map ip ?192.168.123.2 102 broadcast//采用靜態(tài)映射方式
R1(config-if)#frame-relay map ip?192.168.123.3 103 broadcast
R1(config-if)#frame-relay map ip ?192.168.123.1 102////配置自己接口的IP地址的映射
R1(config-if)#no frame-relay inverse-arp//關(guān)閉IARP
R1(config)#router ospf 1///OSPF的配置
R1(config-router)#network 1.1.1.0 0.0.0.255?area 0///網(wǎng)段的宣告
R1(config-router)#network 192.168.123.0 ?0.0.0.255 area 0
同理R2和R3的配置類似拆又,但是由于R1是HUB點儒旬,R2和R3是Spoken點,那么配置有存在不一樣
R2(config)#int lo 0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no shu
R2(config)#int s0/2
R2(config-if)#no shu
R2(config-if)#ip add 192.168.123.2?255.255.255.0
R2(config-if)#encapsulation frame-relay
R2(config-if)#frame-relay lmi-type cisco
R2(config-if)#frame-relay map ip?192.168.123.1 201 broadcast///關(guān)鍵點201
R2(config-if)#frame-relay map ip?192.168.123.3 201 br////關(guān)鍵點201
R2(config-if)#frame-relay map ip?192.168.123.2 201
R2(config-if)#no frame-relay inverse-arp
R2(config)#router ospf 1
R2(config-router)#network 2.2.2.0 0.0.0.255?area 0
R2(config-router)#network 192.168.123.0?0.0.0.255 area 0
R3的基本配置:
R3(config)#int lo 0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int s0/3
R3(config-if)#no shu
R3(config-if)#no shutdown
R3(config-if)#ip add 192.168.123.3?255.255.255.0
R3(config-if)#encapsulation frame-relay
R3(config-if)#frame-relay lmi-type cisco
R3(config-if)#frame-relay map ip?192.168.123.1 301 b///關(guān)鍵點301
R3(config-if)#frame-relay map ip?192.168.123.2 301 br///關(guān)鍵點301
R3(config-if)#no frame-relay inverse-arp
R3(config)#router ospf 1
R3(config-router)#network 3.3.3.0 0.0.0.255?area 0
R3(config-router)#network 192.168.123.0?0.0.0.255 area 0
以上是基本配置帖族,配置完成之后栈源,
R1#show frame-relay map
由此表明靜態(tài)映射配置成功
查看路由表生成狀態(tài):
R1#show ip route ospf
R1#
發(fā)現(xiàn)路由表沒有生成。
R1#show ip os neighbor
表明鄰居沒有生成竖般。
下面針對不同的運行模式找出出現(xiàn)上述問題的原因甚垦。
模式一:non-broadcast(缺省模式)
上述實驗中,采用的是幀中繼網(wǎng)絡(luò)涣雕,默認(rèn)的OSPF網(wǎng)絡(luò)類型為NBMA
在NBMA中艰亮,不能發(fā)送廣播或者組播報文,所以路由器的接口之間無法發(fā)送LSA挣郭,也就無法建立鄰居迄埃。解決方案是手動指定鄰居。
在上述基本配置的基礎(chǔ)上兑障,在R1上需要添加的命令為:
R1(config)#router ospf1
R1(config-router)#neighbor 192.168.123.2
R1(config-router)#nei 192.168.123.3
R1(config-router)#int s0/1
R1(config-if)#ip os priority 10
在R2上添加的命令:
R2(config)#int s0/2
R2(config-if)#ip os priority 0
在R3上添加的命令:
R3(config)#int s0/3
R3(config-if)# ip os pri 0
對上述命令的解釋:
手動指定鄰居(只需要指定一端就可以)之后侄非,鄰居可以建立起來。
R1(config-if)#do show ip os nei
鄰居關(guān)系建立成功流译,但是請注意:
這里存在修改R1和R2和R3的優(yōu)先級逞怨。
? ?由于位于spoken位置的R2和R3只和位于hub端的R1通信。由于hello包的TTL為1福澡,那么路由器R1不會轉(zhuǎn)發(fā)hello包叠赦,這樣導(dǎo)致R2和R3無法交流hello包。由于R2和R3的路由器id均比R1大革砸,那么他們就會認(rèn)為自己是DR除秀,而R1只會認(rèn)為R3是DR,因為R3的路由器id最大算利。這樣就會導(dǎo)致OSPF運行混亂鳞仙。為了解決這個問題,將R1的優(yōu)先級改為最大笔时,R2和R3的優(yōu)先級均修改為0.不參與DR和BDR的選舉。請注意:R2和R3不可以參與BDR的選舉仗岸,原理同上允耿。
查看路由表:
R2#show ip route ospf
R2與R3之間的下一跳均是自己的非直連鄰居。也就是他們之間互訪的時候扒怖,忽略了R1的中轉(zhuǎn)较锡。
模式二:Broadcast
首先將在NBMA模式中指定鄰居的命令刪除:
R1(config)#router?ospf 1
R1(config-router)#no?neighbor 192.168.123.2
R1(config-router)#no?neighbor 192.168.123.3
修改網(wǎng)絡(luò)類型:
在R1,R2盗痒,R3上均做如下配置:
R1(config-if)#ipospf network br
查看路由表:
R2(config-if)#do show ip rou os
查看R1的鄰居表
R1#show ip os nei
由實驗可以看出蚂蕴,無需手動指定鄰居低散,在這個過程中有DR的選舉。
重點注意:由于在R1骡楼,R2熔号,R3的基本配置命令中,存在關(guān)鍵字broadcast鸟整,例如:
R2(config-if)#frame-relay map ip192.168.123.1 201?broadcast
這里broadcast選項表明可以在這條VC上傳播broadcast,multicast幀引镊,所以O(shè)SPF的組播報文就可以正常傳輸,保證了路由協(xié)議的正常運行篮条。
模式三:Point-to-multipoint
在上述配置的基礎(chǔ)上弟头,對R1,R2涉茧,R3上均如下配置:
R1/R2/R3(config-if)#ip ospf network?point-to-multipoint
查看鄰居關(guān)系
R1(config-if)#do show ip os nei
由此可以看出赴恨,在此種網(wǎng)絡(luò)類型中,無需指定鄰居伴栓。也不進(jìn)行DR和BDR的選舉伦连。
模式四:point-to-multipoint NBMA
在上述配置的基礎(chǔ)上作如下修改:
R1(config-router)#int s0/1
R1(config-if)#ip ospf network point-to-multipoint non-broadcast///修改模式
R1(config-router)#neighbor 192.168.123.2////指定鄰居
R1(config-router)#neighbor 192.168.123.3
分別在R2和R3上做如下修改:
R2(config-if)#int s0/2
R2(config-if)#ip ospf network point-to-multipoint non-broadcast
R3(config-if)#int s0/3
R3(config-if)#ip ospf network point-to-multipoint non-broadcast
查看鄰居建立關(guān)系:
查看路由表:
路由表成功生成。
模式五:point to point
首先是對位于hub端的R1進(jìn)行配置
R1(config)#int s0/1
R1(config-if)#no ip add 192.168.123.1 255.255.255.0
R1(config-if)# no frame-relay map ip?192.168.123.2 102 bro////
R1(config-if)#no frame-relay map ip?192.168.123.3 103 bro
R1(config-if)#no frame-relay map ip?192.168.123.1 102 bro
////上述三條命令是將原來主接口下面的靜態(tài)映射刪除
////下面命令是設(shè)定子接口挣饥,并對子接口進(jìn)行靜態(tài)映射
R1(config)#int s0/1.2 po
R1(config)#int s0/1.2 point-to-point
R1(config-subif)#frame-relay interface-dlci?102
R1(config-subif)#ip address 192.168.12.1?255.255.255.0
R1(config-subif)#frame-relay interface-dlci?102
R1(config-fr-dlci)#exit
R1(config-subif)#exit
R1(config)#int s0/1.3 point-to-point
R1(config-subif)#ip add 192.168.13.1?255.255.255.0
R1(config-subif)#frame-relay interface-dlci?103
///下面命令是把子接口的網(wǎng)段宣告進(jìn)OSPF進(jìn)程
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.0?0.0.0.255 area 0
R1(config-router)#network 192.168.13.0?0.0.0.255 area 0
下面對位于spoken端的R2和R3進(jìn)行配置
R2(config)#int s0/2
///首先把主接口下原來的靜態(tài)映射刪除
R2(config-if)#no frame-relay map ip?192.168.123.1 201 br
R2(config-if)#no frame-relay map ip?192.168.123.3 201 br
R2(config-if)#no ip add
////修改主接口的網(wǎng)絡(luò)類型
R2(config-if)#ip ospf network?point-to-point
////保證主接口的ip地址與R1上對應(yīng)的子接口的ip地址在同一個網(wǎng)段
R2(config-if)#ip add 192.168.12.2?255.255.255.0
R2(config-if)#EXIT
R2(config)#router ospf 1
R2(config-router)#network 192.168.12.0 ?0.0.0.255 area 0
R2(config-router)# no network 192.168.123.2?0.0.0.255 area 0
R3的配置為:
R3(config)#int s0/3
///首先把主接口下原來的靜態(tài)映射刪除
R3(config-if)#no frame-relay map ip?192.168.123.1 301 br
R3(config-if)#no frame-relay map ip?192.168.123.2 301 br
R3(config-if)#no ip add
////修改主接口的網(wǎng)絡(luò)類型
R3(config-if)#ip ospf network?point-to-point
////保證主接口的ip地址與R1上對應(yīng)的子接口的ip地址在同一個網(wǎng)段
R3(config-if)#ip add 192.168.13.3?255.255.255.0
R3(config-if)#EXIT
R3(config)#router os
R3(config)#router ospf 1
R3(config-router)#network 192.168.13.0?0.0.0.255 area 0
R3(config-router)#no network 192.168.123.0?0.0.0.255 area 0
做完上述配置之后除师,查看鄰居建立:
R1#show ip os neighbor
由此看出,此時鄰居并沒有建立成功
重點注意:
? ? ?之所以鄰居關(guān)系沒有建立成功扔枫,是由于把R1上的主接口ip地址去掉了汛聚,取而代之的是使用R1的子接口,所以在做靜態(tài)映射到時候短荐,需要對應(yīng)的子接口的映射倚舀。
所以,我們需要做的就是在R2和R3的接口下作與子接口的靜態(tài)映射
在R2上添加如下命令:
R2(config-if)#ints0/2
R2(config-if)#frame-relay map ip 192.168.12.1 201 broadcast
在R3上添加如下命令:
R3(config)#int s0/3
R3(config-if)#frame-relay map ip?192.168.13.1 301 broadcast
查看鄰居關(guān)系:
R1#show ip os nei
鄰居建立成功忍宋,但是不選舉DR和BDR痕貌。
六:總結(jié)
? ? ? ?通過對實驗的配置分析,得出如下結(jié)論: