實驗目錄:
1.OSPF多區域基本配置
2.OSPF創建虛鏈路
3.OSPF引入外部路由
4.OPPF中的stub區域
5.OSPF中的stub no-summary區域
6.OSPF中的NSSA區域
一.OSPF多區域基本配置
按照上面的拓撲配置ip地址
宣告網絡
R1上的lo0和s0/2/0宣告到區域1中。
[R1]ospf
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]network 1.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]q
R2上的s0/2/0宣告到區域1中。
其他宣告到區域0中
[R2]ospf
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]q
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]q
[R2-ospf-1]q
R3上的s0/2/0宣告到區域0中
S0/2/2和lo0宣告到區域2中
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255
[R3-ospf-1]area 2
[R3-ospf-1-area-0.0.0.2]net 192.168.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.2]net 3.3.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.2]q
[R3-ospf-1]q
R4上的s0/2/0宣告到區域2中
Lo0宣告到區域3中
[R4]ospf
[R4-ospf-1]area 2
[R4-ospf-1-area-0.0.0.2]net 192.168.3.0 0.0.0.255
[R4-ospf-1-area-0.0.0.2]q
[R4-ospf-1]area 3
[R4-ospf-1-area-0.0.0.3]net 4.4.4.0 0.0.0.255
[R4-ospf-1-area-0.0.0.3]q
基本的多區域OSPF已經配置完畢
查看一下R1的路由,是不能學習到區域3的路由的,因為區域3不與主干區域相連!
[R1]display ip routing-table protocol ospf
Public Routing Table : OSPF
Summary Count : 6
OSPF Routing table Status : < Active>
Summary Count : 4
Destination/Mask Proto Pre Cost NextHop Interface
2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0
3.3.3.3/32 OSPF 10 3124 192.168.1.2 S0/2/0
192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0
192.168.3.0/24 OSPF 10 4686 192.168.1.2 S0/2/0
OSPF Routing table Status : < Inactive>
Summary Count : 2
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0
192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0
上面輸出顯示,我們沒有學習到area3的路由4.4.4.0
幾個查看命令
[R1]display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
192.168.3.0/24 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1
3.3.3.3/32 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1
2.2.2.2/32 1562 Inter 192.168.1.2 2.2.2.2 0.0.0.1
1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1
192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1
192.168.2.0/24 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1
Total Nets: 6
Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0
[R1]display ospf interface
OSPF Process 1 with Router ID 1.1.1.1
Interfaces
Area: 0.0.0.1
IP Address Type State Cost Pri DR BDR
1.1.1.1 PTP Loopback 1 1 0.0.0.0 0.0.0.0
192.168.1.1 PTP P-2-P 1562 1 0.0.0.0 0.0.0.0
解決不能學到區域3的路由的方法是:創建虛鏈路
二.OSPF創建虛鏈路
實驗拓撲同實驗一
vlink-peer 命令用來創建並配置一條虛連接,undo vlink-peer 命令用來刪除一條已
有的虛連接。
根據 RFC2328 的規定,OSPF 的區域必須是和骨干區域保持連通的,可以使用
vlink-peer 命令建立邏輯上的連通性。在某種程度上,可以將虛連接看做一個普通
的使能了OSPF 的接口,因為在其上配置的hello、retransmit 和trans-delay 等參數
的原理是類似的。
需要注意的是,當配置虛連接驗證時,由骨干區域的authentication-mode 命令來
確定使用的驗證類型是MD5 密文驗證或是明文驗證。
相關配置可參考命令 authentication-mode 和display ospf。
注意:
全部是在area 2上做的
|
[R1]display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
|
192.168.3.0/24 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1
4.4.4.4/32 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1
3.3.3.3/32 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1
2.2.2.2/32 1562 Inter 192.168.1.2 2.2.2.2 0.0.0.1
1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1
192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1
192.168.2.0/24 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1
Total Nets: 7
Intra Area: 2 Inter Area: 5 ASE: 0 NSSA: 0
上面的輸出可以看出,區域1已經可以學習到區域3的路由!
三.OSPF引入外部路由
實驗拓撲
引入路由簡介
import-route 命令用來引入外部路由信息,undo import-route 命令用來取消對外
部路由信息的引入。
如果引入類型為 1 的外部路由,則在路由表中,metric 值為本路由器到達廣播此條
外部路由的路由器的metric 值加上引入時使用的cost 值。如果引入類型2 的外部路
由,則路由表中的metric 值就是引入時設定的cost 值。
此命令不是累加形式,cost、type、tag 等參數應在同一條命令中一次設定,否則后
配置的命令會覆蓋先配置的命令。
缺省情況下,不引入其它協議的路由信息。
我們在R3上做一條通往R4的靜態路由,R4向R3上做一條默認路由
[R3]ip route-static 4.4.4.0 24 192.168.3.2
[R4]ip route-static 0.0.0.0 0 192.168.3.1
引入外部靜態路由和直連路由
|
[
如果不引入直連路由的話,我們會學習不到R3直連的192.168.3.0網段
查看下面的路由,我們就可以看到外部路由的標志
[R1]display ip routing-table protocol ospf
Public Routing Table : OSPF
Summary Count : 9
OSPF Routing table Status : < Active>
Summary Count : 7
Destination/Mask Proto Pre Cost NextHop Interface
2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0
3.3.3.3/32 O_ASE 150 1 192.168.1.2 S0/2/0
4.4.4.0/24 O_ASE 150 1 192.168.1.2 S0/2/0
192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0
192.168.2.1/32 O_ASE 150 1 192.168.1.2 S0/2/0
192.168.3.0/24 O_ASE 150 1 192.168.1.2 S0/2/0
192.168.3.2/32 O_ASE 150 1 192.168.1.2 S0/2/0
OSPF Routing table Status : < Inactive>
Summary Count : 2
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0
192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0
四.OPPF中的stub區域
實驗拓撲同實驗三
注意:
如果要將一個區域配置成 Stub 區域,則該區域中的所有路由器都必須配置此屬性。
相關配置可參考命令 default-cost。
把區域1配置為stub區域
|
末節區域過濾4,5類lsa,沒有過濾3類lsa,所以有ospf區域內的所有路由條目。
外部路由走默認路由!
[R1]display ip routing-table protocol ospf
Public Routing Table : OSPF
Summary Count : 5
OSPF Routing table Status : < Active>
Summary Count : 3
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 OSPF 10 1563 192.168.1.2 S0/2/0
2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0
192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0
OSPF Routing table Status : < Inactive>
Summary Count : 2
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0
192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0
五.OSPF中的stub no-summary區域
實驗拓撲同實驗三
簡介:
完全末節區域是末節區域的升級,添加了過濾3類lsa功能,所以內部的路由也被匯總成為一條默認的路由。
注意:
完全末節區域不需要區域內的路由都開啟stub no-summary ,但其他的路由器要開啟stub
比如此實驗,
R1不必開啟stub no-summary,但必須開啟stub R2必須開啟stub no-summary
|
過濾3,4,5類LSA,而且SAR會產生一條默認路由,到區域0的也走默認路由
使用“display ospf lsdb”可以清楚的看出!
[R1]display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
0.0.0.0/0 1563 Inter 192.168.1.2 2.2.2.2 0.0.0.1
1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1
192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1
Total Nets: 3
Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0
完全末節區域是末節區域的升級,添加了過濾3類lsa功能,所以內部的路由也被匯總成為一條默認的路由。上面的輸出可以看出,已經學習不到其他區域的路由了,取而代之的是一條默認路由!
[R1]display ip routing-table
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 OSPF 10 1563 192.168.1.2 S0/2/0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.0/24 Direct 0 0 192.168.1.1 S0/2/0
192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.2/32 Direct 0 0 192.168.1.2 S0/2/0
六.OSPF中的NSSA區域
此實驗的小目錄
1.驗證NSSA不學習其他區域引進的外部路由
2.[R4-ospf-1-area-0.0.0.2] nssa default-route-advertise
3.NSSA的完全末節區域
[R4-ospf-1-area-0.0.0.2] nssa no-summary
4.NSSA可以引入外部路由,7轉為5類lsa
|
配置RIPv2
[R1]
[R1]rip
[R1-rip-1]ver 2
[R1-rip-1]un s
[R1-rip-1]net 192.168.1.0
[R1-rip-1]net 1.1.1.0
[R1-rip-1]q
配置ospf
[R2]rip
[R2-rip-1]ver 2
[R2-rip-1]un s
[R2-rip-1]net 192.168.1.0
[R2-rip-1]q
[R2]ospf
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]net 2.2.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]net 192.168.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]q
[R2-ospf-1]q
[R3]ospf
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]net 192.168.2.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]q
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]net 3.3.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]q
[R3-ospf-1]q
[R4]ospf
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255
[R4]ospf
[R4-ospf-1]area 2
[R4-ospf-1-area-0.0.0.2]net 192.168.4.0 0.0.0.255
[R4-ospf-1-area-0.0.0.2]q
[R4-ospf-1]q
[R5]ospf
[R5-ospf-1]area 2
[R5-ospf-1-area-0.0.0.2]net 192.168.4.0 0.0.0.255
[R5-ospf-1-area-0.0.0.2]network 5.5.5.0 0.0.0.255
[R5-ospf-1-area-0.0.0.2]q
在沒有配置 NSSA之前,區域2是可以學習到區域1引入的路由
[R5]display ospf routing
OSPF Process 1 with Router ID 5.5.5.5
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
192.168.3.0/24 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2
192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2
5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2
3.3.3.3/32 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2
2.2.2.2/32 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2
192.168.2.0/24 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2
Routing for ASEs
Destination Cost Type Tag NextHop AdvRouter
1.1.1.1/32 1 Type2 1 192.168.4.1 2.2.2.2
Total Nets: 7
Intra Area: 2 Inter Area: 4 ASE: 1 NSSA: 0
並能ping通
[R5]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Request time out
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=252 time=5 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=252 time=5 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=252 time=11 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=252 time=25 ms
驗證NSSA不學習其他區域引進的外部路由
1.首先驗證使用RIP的原因就是驗證NSSA區域不能接受其他的ASBR發送的5類型LSA
把ospf引入RIPv2,把RIPv2引入OSPF網絡!
|
配置NSSA區域
|
配置完NSSA就學不到rip的路由了
[R5]display ospf routing
OSPF Process 1 with Router ID 5.5.5.5
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
192.168.3.0/24 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2
192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2
5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2
3.3.3.3/32 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2
2.2.2.2/32 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2
192.168.2.0/24 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2
Total Nets: 6
Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0
驗證結果:
以上的輸出表明區域間的路由是可以進入到NSSA 區域的;但是在R1 的路由表中並沒有
出現在R3 上把RIP 重分布進來的路由,因此說明LSA 類型為5 的外部路由不能在NSSA 區域中傳播,ABR 也沒有能力把類型5 的LSA 轉成類型7 的LSA
[R4-ospf-1-area-0.0.0.2] nssa default-route-advertise
怎樣讓NSSA學到其他區域引進的外部路由呢?
和上面的不一樣。這個命令可以讓nssa區域學習到區域1和0的路由,為rip單獨使用了個默認路由
|
[R5]display ip routing-table protocol ospf
Public Routing Table : OSPF
Summary Count : 7
OSPF Routing table Status : < Active>
Summary Count : 5
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_NSSA 150 1 192.168.4.1 S0/2/0
2.2.2.2/32 OSPF 10 4686 192.168.4.1 S0/2/0
3.3.3.3/32 OSPF 10 3124 192.168.4.1 S0/2/0
192.168.2.0/24 OSPF 10 4686 192.168.4.1 S0/2/0
192.168.3.0/24 OSPF 10 3124 192.168.4.1 S0/2/0
OSPF Routing table Status : < Inactive>
Summary Count : 2
Destination/Mask Proto Pre Cost NextHop Interface
5.5.5.5/32 OSPF 10 0 5.5.5.5 Loop0
192.168.4.0/24 OSPF 10 1562 192.168.4.2 S0/2/0
上面的輸出可以看出,NSSA可以學到其他區域的路由,其他區域引入的路由成了默認路由
並可以看出NSSA可以學到34類lsa,增加了帶寬使用,我們怎么解決呢?
NSSA的完全末節區域
配置NSSA的完全末節區域:所有的路由都通過默認路由出去
|
[R5]display ospf routing
OSPF Process 1 with Router ID 5.5.5.5
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
0.0.0.0/0 1563 Inter 192.168.4.1 4.4.4.4 0.0.0.2
192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2
5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2
Total Nets: 3
Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0
[R5]display ip routing-table
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 OSPF 10 1563 192.168.4.1 S0/2/0
5.5.5.5/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.4.0/24 Direct 0 0 192.168.4.2 S0/2/0
192.168.4.1/32 Direct 0 0 192.168.4.1 S0/2/0
192.168.4.2/32 Direct 0 0 127.0.0.1 InLoop0
[R5]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=252 time=10 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=252 time=1 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=252 time=5 ms
上面的輸出說明,NSSA區域已經過濾掉了3類lsa
NSSA可以引入外部路由,7轉為5類lsa
配置靜態路由並引入
|
在nssa區域中,類型是O_NSSA
<R4>display ip routing-table
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 O_ASE 150 1 192.168.3.1 S0/2/0
2.2.2.2/32 OSPF 10 3124 192.168.3.1 S0/2/0
3.3.3.3/32 OSPF 10 1562 192.168.3.1 S0/2/0
4.4.4.4/32 Direct 0 0 127.0.0.1 InLoop0
5.5.5.5/32 OSPF 10 1562 192.168.4.2 S0/2/3
10.10.10.0/24 O_NSSA 150 1 192.168.4.2 S0/2/3
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.0/24 OSPF 10 3124 192.168.3.1 S0/2/0
192.168.3.0/24 Direct 0 0 192.168.3.2 S0/2/0
192.168.3.1/32 Direct 0 0 192.168.3.1 S0/2/0
192.168.3.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.4.0/24 Direct 0 0 192.168.4.1 S0/2/3
192.168.4.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.4.2/32 Direct 0 0 192.168.4.2 S0/2/3
|
在其他區域中,類型是O_ASE
[R3]display ip routing-table
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 O_ASE 150 1 192.168.2.1 S0/2/0
2.2.2.2/32 OSPF 10 1562 192.168.2.1 S0/2/0
3.3.3.3/32 Direct 0 0 127.0.0.1 InLoop0
5.5.5.5/32 OSPF 10 3124 192.168.3.2 S0/2/2
10.10.10.0/24 O_ASE 150 1 192.168.3.2 S0/2/2
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.2.0/24 Direct 0 0 192.168.2.2 S0/2/0
192.168.2.1/32 Direct 0 0 192.168.2.1 S0/2/0
192.168.2.2/32 Direct 0 0 127.0.0.1 InLoop0
192.168.3.0/24 Direct 0 0 192.168.3.1 S0/2/2
192.168.3.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.3.2/32 Direct 0 0 192.168.3.2 S0/2/2
192.168.4.0/24 OSPF 10 3124 192.168.3.2 S0/2/2