天天看點

BSCI—8-(2):OSPF的特殊區域類型與配置

一、NSSA區域:

1.隻有NSSA區域中才會現LSA7,可以存在ASBR,阻止LSA4/5

2.ABR将LSA7轉成LSA5,傳播到其他區域,這時,ABR也成為了ASBR,因為它也引入了LSA5,其它路由器看到LSA5的通告路由器是ABR。

二、實驗拓撲如下:R1到R2屬區域0,R2到R3屬區域1并配置為NSSA區域,R1與R3分别運作RIP與EIGRP模拟OSPF外部路由,接口與IP位址資訊如下所示.

步驟一:配置3台路由器及路由協定,并如圖釋出網段.

R1:

Router>

Router>en

Router#conf t

Router(config)#hostname R1

R1(config-line)#exit

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)#interface loopback 0

R1(config-if)#ip address 1.1.1.1 255.255.255.0

R1(config-if)#ip ospf network point-to-point    //防止學習32位的主機路由

R1(config-if)#int lo1

R1(config-if)#ip address 1.1.2.1 255.255.255.0

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

R1(config-router)#router-id 1.1.1.1    //指定ROUTE-ID

R1(config-router)#network 192.168.1.1 0.0.0.0 area 0    //釋出網段到區域0

R1(config-router)#exit

R1(config)#router rip     //啟用RIP路由協定

R1(config-router)#version 2     //指定版本2

R1(config-router)#no auto-summary     //不要自動彙總

R1(config-router)#network 1.1.1.0    //釋出網段

R1(config-router)#network 1.1.2.0    //同上

R1(config-router)#end

R1#

R2:

start

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)#interface f0/1

R2(config-if)#ip address 192.168.2.2 255.255.255.0

R2(config)#interface loopback 0

R2(config-if)#ip address 2.2.1.1 255.255.255.0

R2(config-if)#ip ospf network point-to-point 

R2(config-if)#int lo1

R2(config-if)#ip address 2.2.2.1 255.255.255.0

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

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)#network 192.168.2.2 0.0.0.0 area 1

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

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

R2(config-router)#end     

R2#

R3:

Router(config)#hostname R3

R3(config)#interface f0/1

R3(config-if)#ip address 192.168.2.1 255.255.255.0

R3(config-if)#no sh

R3(config-if)#exit

R3(config)#interface loopback 0

R3(config-if)#ip address 172.16.1.1 255.255.255.0

R3(config-if)#int lo1

R3(config-if)#ip address 172.16.2.1 255.255.255.0

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

R3(config-router)#router-id 3.3.3.3     //同上

R3(config-router)#network 192.168.2.1 0.0.0.0 area 1

R3(config-router)#exit 

R3(config)#router eigrp 1

R3(config-router)#no auto-summary 

R3(config-router)#network 172.16.1.0 0.0.0.255

R3(config-router)#network 172.16.2.0 0.0.0.255

R3(config-router)#end

R3#

步驟二:在R1與R3上進行路由的重釋出,使得路由器能夠互相學習外部路由.

R1(config)#router ospf 1

R1(config-router)#redistribute rip subnets    //将RIP重釋出進OSPF

R1(config)#router rip

R1(config-router)#redistribute ospf 1 metric 1     //将OSPF重釋出進RIP度量為1

R3(config)#router ospf 1

R3(config-router)#redistribute eigrp 1 subnets     //将EIGRP重釋出進OSPF

R3(config-router)#exit

R3(config-router)#redistribute ospf 1 metric 100000 5 255 1 1500

//将OSPF重釋出進EIGRP,帶寬=100000KM 廷遲=5 可靠性=255 負載=1 最大傳輸單元=1500

步驟三:将區域1配置為NSSA區域.

R2(config)#router ospf 1

R2(config-router)#area 1 nssa     //将區域1配置為NSSA

R2(config-router)#end

R3(config-router)#area 1 nssa     //将區域1配置為NSSA

步驟四:在R1,R2與R3上分别驗證

檢視R1路由表:

R1#show ip route 

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     1.0.0.0/24 is subnetted, 2 subnets

C       1.1.1.0 is directly connected, Loopback0

C       1.1.2.0 is directly connected, Loopback1

     2.0.0.0/24 is subnetted, 2 subnets

O       2.2.1.0 [110/2] via 192.168.1.2, 00:08:29, FastEthernet0/0

O       2.2.2.0 [110/2] via 192.168.1.2, 00:08:29, FastEthernet0/0

     172.16.0.0/24 is subnetted, 2 subnets

O E2    172.16.1.0 [110/20] via 192.168.1.2, 00:07:34, FastEthernet0/0

O E2    172.16.2.0 [110/20] via 192.168.1.2, 00:07:34, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/0

O IA 192.168.2.0/24 [110/2] via 192.168.1.2, 00:08:04, FastEthernet0/0

R1#     

//R1上可以學習到所有路由,因為它是正常區域,沒有做任何配置,可以學習是以類型的LSA

檢視R2路由表:

R2#show ip route 

O E2    1.1.1.0 [110/20] via 192.168.1.1, 00:04:19, FastEthernet0/0

O E2    1.1.2.0 [110/20] via 192.168.1.1, 00:04:19, FastEthernet0/0

C       2.2.1.0 is directly connected, Loopback0

C       2.2.2.0 is directly connected, Loopback1

O N2    172.16.1.0 [110/20] via 192.168.2.1, 00:04:19, FastEthernet0/1

O N2    172.16.2.0 [110/20] via 192.168.2.1, 00:04:19, FastEthernet0/1

C    192.168.2.0/24 is directly connected, FastEthernet0/1

//有人肯定會說NSSA區域不是不會學習5類LSA嗎,怎麼多了2條E2的路由?

因為R2是NSSA的ABR,它所要做的事情就是将7類型LSA轉成5類LSA并傳播到區域間每個路由器,還有NSSA區域可以學習本區域引入的外部路由,上面兩條N2的路由為從R3上EIGRP所學的外部路由.

檢視R3路由表:

R3#show ip route 

O IA    2.2.1.0 [110/2] via 192.168.2.2, 00:13:21, FastEthernet0/1

O IA    2.2.2.0 [110/2] via 192.168.2.2, 00:13:21, FastEthernet0/1

C       172.16.1.0 is directly connected, Loopback0

C       172.16.2.0 is directly connected, Loopback1

O IA 192.168.1.0/24 [110/2] via 192.168.2.2, 00:13:21, FastEthernet0/1

//R3屬于NSSA區域内,而非NSSA區域ABR,是以它就驗證了NSSA區域不能學習其它區域引入的外部路由。

疑問:為什麼在R2上面會發生7類LSA轉5類LSA?

我們來看看R2的OSPF鍊路狀态資料庫:

R2#show ip ospf database

                Type-7 AS External Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Tag

172.16.1.0      3.3.3.3         1501        0x80000001 0x00C09F 0

172.16.2.0      3.3.3.3         1501        0x80000001 0x00B5A9 0

                Type-5 AS External Link States

1.1.1.0         1.1.1.1         483         0x80000002 0x00A3F4 0

1.1.2.0         1.1.1.1         484         0x80000002 0x0098FE 0

172.16.1.0      2.2.2.2         1495        0x80000001 0x0073FA 0

172.16.2.0      2.2.2.2         1495        0x80000001 0x006805 0

注:前面說過,隻有NSSA區域存放7類LSA,是以7類LSA傳播到其它區域根本就不識别,仔細看R2上5類與7類LSA的摘要,都存放了172.16.1.0與172.16.2.0,是以這就7類變5類LSA的轉折點.

總結:相信通過這兩篇文章,大家對OSPF的特殊區域有個比較好的認識與掌握.

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