1. 程式人生 > 實用技巧 >8. OSPF的NSSA詳解

8. OSPF的NSSA詳解

1. OSPF的NSSA(not so stub area)區域

  • 不接收5類LSA,但是可以引入外部路由,引入一種新的7類的NSSA的LSA

  • 場景:一個分支現在不接收5類LSA,同時還要在本區域得到預設路由去指向執行商而不是總公司(area 0)

[SW3-ospf-1]ar
[SW3-ospf-1]area 15
[SW3-ospf-1-area-0.0.0.15]
[SW3-ospf-1-area-0.0.0.15]nssa 
Error: The specified area has been configured as a STUB area. //需要先拿掉STUB的配置,然後再配置NSSA

[R5-ospf-1-area-0.0.0.15]dis th
[V200R003C00]
#
 area 0.0.0.15 
  nssa   //該區域中所有裝置都配置nssa,否則NP位不一致,導致無法建立鄰居
  
  
  
[SW3-ospf-1-area-0.0.0.15]dis ospf peer brief 

         OSPF Process 1 with Router ID 13.13.13.13
                  Peer Statistic Information
----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.15         Vlanif30                         0.0.0.1          Full        

 0.0.0.15         Vlanif30                         5.5.5.5          Full        




[SW3]dis ip routing-table protocol ospf

Route Flags: R - relay, D - download to fib
Public routing table : OSPF
         Destinations : 13       Routes : 14       
OSPF routing table status : <Active>
         Destinations : 13       Routes : 14
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_NSSA  150  1           D   10.1.15.1       Vlanif30
                    O_NSSA  150  1           D   10.1.15.5       Vlanif30 //華為裝置上預設從ABR(s)處得到7類LSA產生的預設路由,這點在思科裝置上不會自動產生
       10.1.1.1/32  OSPF    10   1           D   10.1.15.1       Vlanif30
       10.1.1.4/32  OSPF    10   49          D   10.1.15.1       Vlanif30
       10.1.1.5/32  OSPF    10   1           D   10.1.15.5       Vlanif30
      10.1.34.0/24  OSPF    10   97          D   10.1.15.1       Vlanif30
      10.1.35.0/24  OSPF    10   2           D   10.1.15.5       Vlanif30
      10.1.56.0/24  OSPF    10   49          D   10.1.15.5       Vlanif30
       11.1.1.1/32  OSPF    10   1           D   10.1.15.1       Vlanif30
       33.1.1.1/32  OSPF    10   2           D   10.1.15.5       Vlanif30
       44.1.1.1/32  OSPF    10   49          D   10.1.15.1       Vlanif30
       55.1.1.1/32  OSPF    10   1           D   10.1.15.5       Vlanif30
       66.1.1.1/32  OSPF    10   49          D   10.1.15.5       Vlanif30
      100.1.1.1/32  O_NSSA  150  1           D   10.1.15.1       Vlanif30 //不同於STUB區域,此時NSSA區域得到了本區域引入的7類LSA產生的外部路由(其他區域引入的外部路由通過預設路由去訪問)


[R6-ospf-1]import-route direct

[SW3]dis ip routing-table protocol ospf   //NSSA內部的裝置看不到其他區域引入的外部路由,但是可以通過預設路由去訪問

Route Flags: R - relay, D - download to fib

Public routing table : OSPF
         Destinations : 13       Routes : 14       

OSPF routing table status : <Active>
         Destinations : 13       Routes : 14

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_NSSA  150  1           D   10.1.15.1       Vlanif30
                    O_NSSA  150  1           D   10.1.15.5       Vlanif30
       10.1.1.1/32  OSPF    10   1           D   10.1.15.1       Vlanif30
       10.1.1.4/32  OSPF    10   49          D   10.1.15.1       Vlanif30
       10.1.1.5/32  OSPF    10   1           D   10.1.15.5       Vlanif30
      10.1.34.0/24  OSPF    10   97          D   10.1.15.1       Vlanif30
      10.1.35.0/24  OSPF    10   2           D   10.1.15.5       Vlanif30
      10.1.56.0/24  OSPF    10   49          D   10.1.15.5       Vlanif30
       11.1.1.1/32  OSPF    10   1           D   10.1.15.1       Vlanif30
       33.1.1.1/32  OSPF    10   2           D   10.1.15.5       Vlanif30
       44.1.1.1/32  OSPF    10   49          D   10.1.15.1       Vlanif30
       55.1.1.1/32  OSPF    10   1           D   10.1.15.5       Vlanif30
       66.1.1.1/32  OSPF    10   49          D   10.1.15.5       Vlanif30
      100.1.1.1/32  O_NSSA  150  1           D   10.1.15.1       Vlanif30

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0



[SW3]ping 6.6.6.6
  PING 6.6.6.6: 56  data bytes, press CTRL_C to break
    Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=254 time=70 ms
    Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=254 time=50 ms
    Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=254 time=50 ms
    Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=254 time=50 ms
    Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=254 time=50 ms

  --- 6.6.6.6 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/54/70 ms
    
    
    
[SW3]ip route-static 0.0.0.0 0 NULL 0 //OSPF不可以通過引入預設靜態路由產生

1.1 NSSA的特點:

  • 本區域可以為所欲為的引入外部路由,其他區域引入的外部路由不接受(只許州官放火不許百姓點燈)

1.2 7類NSSA的LSA

  • 為了將NSSA區域引入的外部路由釋出到其他區域,要把 7類LSA 轉為 5類LSA,以便在整個OSPF為了中通告
  • P-bit,用於告知轉化路由器,該條 7類LSA 是否需要轉化,dis ospf lsdb nssa 133.1.1.1
  • 預設情況下,轉換路由器是NSSA區域中 RID 最大的ABR
  • 只有 P-bit 置位並且 轉發地址不為 0 的7類LSA 才能轉化為 5類LSA,轉發地址用來表示傳送的某個目的地址的報文將被轉發到轉發地址所指定的地址
  • ABR產生的 7類LSA 不會置位 P-bit

1.3 7類LSA

通告者:NSSA區域的ASBR

通告範圍:僅僅在NSSA區域(更新到NSSA區域外會變成5類LSA)

內容和功能:描述NSSA區域產生的外部路由(網路字首、掩碼、度量、型別、轉發地址、tag)

[SW3]dis ospf lsdb nssa 100.1.1.1      

         OSPF Process 1 with Router ID 13.13.13.13
                         Area: 0.0.0.15
                 Link State Database 

  Type      : NSSA
  Ls id     : 100.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 1526 
  Len       : 36 
  Options   : None 
  seq#      : 80000001 
  chksum    : 0xd40
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.1 //NSSA LSA的轉發地址一般都去非0
  Tag       : 1 

  Priority  : Medium

[SW3]ip route-static 133.1.1.1 32 NULL 0
[SW3]ospf
[SW3-ospf-1]import-route static 


[SW3-ospf-1]dis ospf lsdb nssa self-originate 

         OSPF Process 1 with Router ID 13.13.13.13
                         Area: 0.0.0.15
                 Link State Database 

  Type      : NSSA
  Ls id     : 133.1.1.1
  Adv rtr   : 13.13.13.13  
  Ls age    : 37 
  Len       : 36 
  Options   :  NP    //P代表可以轉換
  seq#      : 80000001 
  chksum    : 0x806e
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Low
  
  
//預設情況下是NSSA區域的ABR(RID較大的ABR,防環的角度)進行的7-->5
<R3>dis ip routing-table 133.1.1.1    

Route Flags: R - relay, D - download to fib
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      133.1.1.1/32  O_ASE   150  1           D   10.1.35.5       GigabitEthernet0/0/0



<R3>dis ospf lsdb ase 133.1.1.1

         OSPF Process 1 with Router ID 33.1.1.1
                 Link State Database

  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 5.5.5.5 //是NSSA區域的ABR裝置做了7轉5,
  Ls age    : 318 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0xe72f
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Medium
  
  
  
  
<R3>dis ospf abr-asbr 

         OSPF Process 1 with Router ID 33.1.1.1
                 Routing Table to ABR and ASBR 
 RtType      Destination       Area       Cost  Nexthop         Type
 Intra-area  0.0.4.4           0.0.0.34   48    10.1.34.4       ABR 
 Intra-area  5.5.5.5           0.0.0.35   1     10.1.35.5       ABR/ASBR //對ASBR的進一步理解:只要產生了5類LSA就是ASBR
 Inter-area  0.0.0.1           0.0.0.35   49    10.1.35.5       ASBR 

 Inter-area  0.0.0.6           0.0.0.35   49    10.1.35.5       ASBR 

1.4 NSSA 引數

1.5 NSSA的細節:

1.5.1 no-summary 之後ABR產生3類的預設路由

ospf
  area 15 
	 nssa no-summary
	 
no-summary之後,ABR產生幾類的預設路由?3類。OSPF形式的預設路由只能以3、5、7類存在

<SW3>dis ospf routing 

         OSPF Process 1 with Router ID 13.13.13.13
                  Routing Tables 
 Routing for Network 
 Destination        Cost  Type       NextHop         AdvRouter       Area
 10.1.15.0/24       1     Transit    10.1.15.3       13.13.13.13     0.0.0.15
 0.0.0.0/0          2     Inter-area 10.1.15.1       0.0.0.1         0.0.0.15
 0.0.0.0/0          2     Inter-area 10.1.15.5       5.5.5.5         0.0.0.15

 Total Nets: 3  
 Intra Area: 1  Inter Area: 2  ASE: 0  NSSA: 0 



<SW3>dis ip rou pro ospf

Route Flags: R - relay, D - download to fib
Public routing table : OSPF
         Destinations : 1        Routes : 2        
OSPF routing table status : <Active>
         Destinations : 1        Routes : 2
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   10.1.15.5       Vlanif30
                    OSPF    10   2           D   10.1.15.1       Vlanif30

OSPF routing table status : <Inactive>

          Destinations : 0        Routes : 0

1.5.2 ABR同時也是ASBR的裝置引入外部路由,NP不置位,因為這不需要把7類再轉成5類,ASBR本身就產生了5類LSA。

[R1-ospf-1]import-route static
[R1-ospf-1]dis ospf lsdb nssa self-originate 

         OSPF Process 1 with Router ID 0.0.0.1
                         Area: 0.0.0.0
                 Link State Database 
    
                         Area: 0.0.0.15
                 Link State Database 

  Type      : NSSA
  Ls id     : 100.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 16 
  Len       : 36 
  Options   : None 
  seq#      : 80000001 
  chksum    : 0xd40
  Net mask  : 255.255.255.255             
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.1 
  Tag       : 1 
  Priority  : Low




[R1-ospf-1]dis ospf lsdb ase self-originate 

         OSPF Process 1 with Router ID 0.0.0.1
                 Link State Database

  Type      : External
  Ls id     : 100.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 46 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0xbea9
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 

  Priority  : Low

1.5.3 translator-always Set NSSA translator role always //總是進行7轉5的操作

translator-always         Set NSSA translator role always //總是進行7轉5的操作
R1上配置該命令,結果
<R4>dis ospf lsdb ase 133.1.1.1 //開始看到的情況R1和R5都做了轉換

         OSPF Process 1 with Router ID 0.0.4.4
                 Link State Database


  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 5.5.5.5  
  Ls age    : 825 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0xe72f
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Medium

  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 36 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x78b1
  Net mask  : 255.255.255.255             
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Medium
<R4>dis ospf lsdb ase 133.1.1.1

         OSPF Process 1 with Router ID 0.0.4.4
                 Link State Database


  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 175 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x78b1
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Medium
<R5>dis ospf lsdb ase 133.1.1.1 self-originate //R5不在做7轉5的轉換

         OSPF Process 1 with Router ID 5.5.5.5
                 Link State Database

-----------------------


1.5.4 no-import-route //ABR如果做了引入外部路由,由於NSSA內部裝置可以通過預設路由訪問外部,我們可以不需要該路由

<SW3>dis ip rou pro ospf

Route Flags: R - relay, D - download to fib
Public routing table : OSPF
         Destinations : 2        Routes : 3        
OSPF routing table status : <Active>
         Destinations : 2        Routes : 3
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   10.1.15.5       Vlanif30
                    OSPF    10   2           D   10.1.15.1       Vlanif30
      100.1.1.1/32  O_NSSA  150  1           D   10.1.15.1       Vlanif30 //預設進入NSSA




[R1-ospf-1-area-0.0.0.15]nssa translator-always no-summary no-import-route 


<SW3>dis ip rou pro ospf

Route Flags: R - relay, D - download to fib
Public routing table : OSPF
         Destinations : 1        Routes : 2        
OSPF routing table status : <Active>
         Destinations : 1        Routes : 2
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   10.1.15.5       Vlanif30
                    OSPF    10   2           D   10.1.15.1       Vlanif30

1.5.5 ABR轉換為5類LSA後轉發地址為全0

[R1-ospf-1-area-0.0.0.15]nssa translator-always no-summary no-import-route suppress-forwarding-address 


<R4>dis ospf lsdb ase 133.1.1.1

         OSPF Process 1 with Router ID 0.0.4.4
                 Link State Database

  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 100 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x78b1
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.15.3 
  Tag       : 1 
  Priority  : Medium
  
  
  
<R4>dis ospf lsdb ase 133.1.1.1 //配置完畢之後的結果

         OSPF Process 1 with Router ID 0.0.4.4
                 Link State Database

  Type      : External
  Ls id     : 133.1.1.1
  Adv rtr   : 0.0.0.1  
  Ls age    : 54 
  Len       : 36 
  Options   :  E  
  seq#      : 80000002 
  chksum    : 0xe38
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 

  Priority  : Medium

1.5.6 default-route-advertise ASBR上完成

  • ASBR上完成,不要在ABR上實施。還有一個條件,裝置上存在其他形式的預設路由
[SW3]ip route-static 0.0.0.0 0.0.0.0 NULL 0
[SW3-ospf-1-area-0.0.0.15]nssa default-route-advertise 


[R5]dis ip rou pro ospf

Route Flags: R - relay, D - download to fib
Public routing table : OSPF
         Destinations : 12       Routes : 13       
OSPF routing table status : <Active>
         Destinations : 11       Routes : 12
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_NSSA  150  1           D   10.1.15.1       GigabitEthernet0/0/2 //是拿掉R1的no-summary引數得到的NSSA的ABR產生的預設路由
                    O_NSSA  150  1           D   10.1.15.3       GigabitEthernet0/0/2 //是SW3上實施通告預設路由後產生的OSPF的7類的預設路由

1.6 LSA總結

LSA,計算路由的材料,不是最終的路由

劃分區域後----->LSA的分類

1、2類:只在一個城市小打小鬧

3類:把生意做到了其他省份

5類LSA:到全世界(除了一些特殊國家)

4類LSA:中間人或者國外的代理商

7類LSA:特殊國家

作業:

1.在R1完成引入路由,但是不允許這些外部路由進入NSSA區域

2.SW3上引入外部路由,R1上完成7類轉5類LSA的操作