有些時候,由於區域包含的路由器過多或區域的地理位置原因等,造成網絡中配置的OSPF區域(非area 0)不能夠與area 0相連。大家都知道,在OSPF的所有區域內,area 0 是骨幹區域,非0區域都要與area0相連,才能夠得知其他網絡的路由信息。如下圖所示情況:
拓撲中的網絡爲192.168.X.0 /24,area 2 不能與area 0直接相連,這樣R4就不能夠學習到area 0區域的路由。
基本配置:
R1:
En
Confi t
Host R1
Inter f0/0
Ip add 192.168.1.1 255.255.255.0
No sh
Router ospf 1
Net 192.168.1.1 0.0.0.0 area 0 ——將啓用OSPF的接口通告出去。
R2:
En
Confi t
Host R2
Inter f0/0
Ip add 192.168.1.2 255.255.255.0
No sh
Inter f0/1
Ip add 192.168.2.1 255.255.255.0
No sh
Router ospf 1
Net 192.168.1.2 0.0.0.0 area 0 ——接口具體屬於哪個區域,根據上圖來配置。
Net 192.168.2.1 0.0.0.0 area 1
R3:
En
Conf t
Host R3
Inter f0/0
Ip add 192.168.2.2 255.255.255.0
No sh
Inter f0/1
Ip add 192.168.3.1 255.255.255.0
No sh
Router ospf 1
Net 192.168.2.2 0.0.0.0 area 1
Net 192.168.3.1 0.0.0.0 area 2
R4:
En
Conf t
Host R4
Inter f0/0
Ip add 192.168.3.2 255.255.255.0
No sh
Inter loo 0 ——這裏我啓用迴環接口,目的是不用再增加設備。因爲迴環接口默認鏈路自動up,只需配好IP就OK了。
Ip add 3.3.3.3 255.255.255.255
配置完以後可以看到:
R1:
R3:
R4:
一般情況下,我們有以下三種方式來解決。
方法一:多進程ospf,路由重發布。
可以看出:R3上有到達所有網絡的路由,但是area 0 的R1、邊界路由R2卻學習不到。由此,我們可以使用路由重發布來將R3學習到的area2內的路由重發布到area 1中。同樣的,將R3中的關於area 0、area 1的路由重發布到area2中。
我們要R3 運行兩個OSPF進程,接下來我們就要在不同的ospf進程之間進行路由重發布。
進程1:通告area 1的接口;
進程2:通告 area 2 的接口。
我們來配置一下:首先將R3現有的OSPF進程1內通告的192.168.3.1 no 掉。
R3(config)#router ospf 1
R3(config-router)#no net 192.168.3.1 0.0.0.0 area 2
建立一個新的ospf進程 2:
R3(config)#router ospf 2
R3(config-router)#net 192.168.3.1 0.0.0.0 area 2
這樣,R3又重新學習到了area 2中的網絡 3.3.3.3
接下來我們來做重發布:
1) 將進程2發佈到進程1:
R3(config)#router ospf 1
R3(config-router)#redis ospf 2 subnets
這樣R1、R2上就可以看到3.3.3.3 網絡的路由了。
R2 同樣可以學習到3.3.3.3。
2) 將進程1發佈到進程2:
R3(config)#router ospf 2
R3(config-router)#redistribute ospf 1 sub
這樣,R4就可以學習到area 0 、area1 中的路由信息了。
方法二:隧道技術
還原實驗環境。
我們可以在R2、R3之間建立一條雙向的隧道,讓area 2 在邏輯上與area 0相連。
R2:建隧道並配置IP:
R2(config)#interface tunnel 1
R2(config-if)#tun source 192.168.2.1
R2(config-if)#tun des 192.168.2.2
R2(config-if)#ip add 192.168.4.1 255.255.255.0
R2(config-router)#net 192.168.4.1 0.0.0.0 area 0 ---通告隧道的網絡到area 0
R3:建隧道並配置IP:
R3(config)#interface tunnel 1
R3(config-if)#tun source 192.168.2.2
R3(config-if)#tun des 192.168.2.1
R3(config-if)#ip add 192.168.4.2 255.255.255.0
R3(config-router)#net 192.168.4.2 0.0.0.0 area 0 ---通告隧道的網絡到area 0
這樣,R1、R4就學習到了彼此的路由信息。
方法三:virtual-link
還原環境。
在R2和R3上進行配置:
R2:
Router ospf 1
Area 1 virtual-link 192.168.3.1 --這裏的IP是路由器的routerID,實驗中我沒有配置router ID,默認是最高的接口IP
R3:
Router ospf 1
Area 1 virtual-link 192.168.2.1
結果:
成功!