CCNP實戰教程之 OSPF中爲何將環回口通告爲主機路由?


課題內容:網絡

OSPF中爲何將環回口通告爲主機路由?ide


實驗拓撲:oop

image


基本IP地址配置及OSPF宣告配置   測試


R1(config)#interface loopback 0
  R1(config-if)#ip address 11.1.1.1 255.255.255.0
  R1(config-if)#ip ospf 110 area 0
  R1(config-if)#interface e0/0
  R1(config-if)#ip address 12.1.1.1 255.255.255.252
  R1(config-if)#no shutdown
  R1(config-if)#ip ospf 110 area 0                 
  R1(config-if)#end
this


R2(config)#interface loopback 0
R2(config-if)#ip address 22.1.1.1 255.255.255.0
R2(config-if)#ip ospf 110 area 0
R2(config-if)#interface e0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.252
R2(config-if)#no shutdown
R2(config-if)#ip ospf 110 area 0
R2(config-if)#end
spa


觀察現象:翻譯

R1#show ip route ospf | begin Gateway
Gateway of last resort is not set
設計

      22.0.0.0/32 is subnetted, 1 subnets
O        22.1.1.1 [110/11] via 12.1.1.2, 00:01:28, Ethernet0/0
orm


R2#show ip route ospf | begin Gateway
Gateway of last resort is not set
router

      11.0.0.0/32 is subnetted, 1 subnets
O        11.1.1.1 [110/11] via 12.1.1.1, 00:01:42, Ethernet0/0


// R1 和 R2 的環回接口配置了24位長度的子網掩碼,然而在路由表中卻顯示爲 32位的主機路由 //


衆所周知,OSPF的路由是由LSDB中的計算而來,咱們來看下LSA的具體內容

 

R1#show ip ospf database router self-originate

            OSPF Router with ID (11.1.1.1) (Process ID 110)

                Router Link States (Area 0)

  LS age: 359
   Options: (No TOS-capability, DC)
   LS Type: Router Links
   Link State ID: 11.1.1.1
   Advertising Router: 11.1.1.1
   LS Seq Number: 80000003
   Checksum: 0x527B
   Length: 48
   Number of Links: 2

    Link connected to: a Stub Network
      (Link ID) Network/subnet number: 11.1.1.1
      (Link Data) Network Mask: 255.255.255.255

       Number of MTID metrics: 0
        TOS 0 Metrics: 1

    Link connected to: a Transit Network
      (Link ID) Designated Router address: 12.1.1.2
      (Link Data) Router Interface address: 12.1.1.1
       Number of MTID metrics: 0
        TOS 0 Metrics: 10

//注意下劃線標註的位置,R1在將環回口的鏈路狀態收集爲LSA內容的時候就已經標記爲了 32 位的子網掩碼; //


那麼,OSPF爲何要這樣作呢?

咱們在RFC 2328中尋找答案:

image


Section 9.1節選

Loopback
In this state, the router’s interface to the network is looped back. The interface may be looped back in hardware or software. The interface will be unavailable for regular data traffic. However, it may still be desirable to gain information on the quality of this interface, either through sending ICMP pings to the interface or through something like a bit error test. For this reason, IP packets may still be addressed to an interface in Loopback state. To facilitate this, such interfaces are advertised in router-LSAs as single host routes, whose destination is the IP interface address.

翻譯:

在此狀態下,路由器與網絡的接口將被環回。 接口能夠在硬件或軟件中循環。 該接口將沒法用於常規數據流量。 可是,仍然須要得到有關此接口質量的信息,方法是將ICMP ping發送到接口或經過比特錯誤測試。 所以,IP數據包仍能夠尋址到Loopback狀態的接口。 爲此,這些接口在Router-LSA中做爲單個主機路由通告,其目的地是IP接口地址。


看起來,OSPF僅僅把環回口看成測試須要而設計;

然而在現現在主流的MPLS+IP的解決方案中,環回口的子網掩碼則很是重要。在MPLS環境中,OSPF的環回口子網掩碼若是配置的不是32位,則會形成標籤斷裂,從而形成×××流量被丟棄。(有關詳細內容,歡迎關注乾頤堂達叔的博客更新,以及CCIE理論課哦)


關於解決方案:

不一樣的廠商解決方案也不一樣;

在cisco的設備上,將環回口的OSPF網絡類型修改成點到點,將可以在LSA中真實反應出實際配置的子網掩碼;


R1>enable
R1#conf t
R1(config)#interface loopback 0
R1(config-if)#ip ospf network point-to-point
R1(config-if)#end


驗證:

R1#show ip ospf database router self-originate

            OSPF Router with ID (11.1.1.1) (Process ID 110)

                Router Link States (Area 0)

  LS age: 28
   Options: (No TOS-capability, DC)
   LS Type: Router Links
   Link State ID: 11.1.1.1
   Advertising Router: 11.1.1.1
   LS Seq Number: 80000006
   Checksum: 0x4289
   Length: 48
   Number of Links: 2

    Link connected to: a Stub Network
      (Link ID) Network/subnet number: 11.1.1.0
      (Link Data) Network Mask: 255.255.255.0

       Number of MTID metrics: 0
        TOS 0 Metrics: 1

    Link connected to: a Transit Network
      (Link ID) Designated Router address: 12.1.1.2
      (Link Data) Router Interface address: 12.1.1.1
       Number of MTID metrics: 0
        TOS 0 Metrics: 10


R2#show ip route ospf | begin Gateway
Gateway of last resort is not set

     11.0.0.0/24 is subnetted, 1 subnets
O        11.1.1.0 [110/11] via 12.1.1.1, 00:00:57, Ethernet0/0




謝謝你們!我是達叔。

相關文章
相關標籤/搜索