一台 Router 有幾個 OSPF Router ID ?


    在設定 OSPF 的時候,Router ID 是 OSPF 用來識別 Router 用的。要成功的讓 OSPF 交換路由,必須先建立 neighbor relationship。要成功的建立 OSPF neighbor,每個 Router 必須要有唯一的 Router ID,是其中的一個條件。

    我們來複習 OSPF Router ID (RID) 的選擇方式:

    1. OSPF process 會檢查是否有使用 router-id 這個指令手動設定 RID。
    2. 如果沒有手動設定 RID,OSPF process 會看是否有 active (up/up) 的 Loopback 介面。如果有,則挑選 Loopback interface 中最高的 IP address,將之設定為 RID。
    3. 如果 Router 中沒有 Loopback interface (或都被 shutdown),則會選擇 active (up/up) 的實體介面(Physical interfaces)中最高的 IP address,將之設定為 RID。
    4. 如果也都沒有 active 的實體介面,或 active 的實體介面都沒有設定 IP address,那麼 OSPF 將無法設定。(如下例)
    Router#show ip int brief
    Interface IP-Address OK? Method Status Protocol

    FastEthernet0/0 unassigned YES manual administratively down down

    FastEthernet0/1 unassigned YES manual administratively down down

    Vlan1 unassigned YES manual administratively down down
    Router#conf t
    Enter configuration commands, one per line. End with CNTL/Z.
    Router(config)#router ospf 100
    OSPF process 100 cannot start. There must be at least one “up” IP interface
    Router(config-router)#end
    %SYS-5-CONFIG_I: Configured from console by console
    Router#
    show ip ospf
    %OSPF: Router process 100 is not running, please configure a router-id
    Router#

    我們再來看這個例子:
    2009-09-20_101306
    R1:

    interface Loopback1
    ip address 1.1.1.1 255.255.255.255
    !
    interface Loopback2
    ip address 2.2.2.1 255.255.255.255
    !
    interface Loopback3
    ip address 3.3.3.1 255.255.255.255
    !
    interface FastEthernet0/0
    ip address 10.1.1.1 255.255.255.0
    !

    router ospf 100
    log-adjacency-changes
    network 10.1.1.0 0.0.0.255 area 0


    R2:

    interface Loopback1
    ip address 1.1.1.2 255.255.255.255
    !
    interface Loopback2
    ip address 2.2.2.2 255.255.255.255
    !
    interface Loopback3
    ip address 3.3.3.2 255.255.255.255
    !
    interface FastEthernet0/0
    ip address 10.1.1.2 255.255.255.0
    !

    router ospf 100
    log-adjacency-changes
    network 10.1.1.0 0.0.0.255 area 0

    當 OSPF 成功建立起 neighbor 之後我們可以從 R2 看到,R1 的 RID 是 3.3.3.1,合乎上述的選擇方式。
    R2#show ip ospf neighbor
    Neighbor ID Pri State Dead Time Address Interface
    3.3.3.1 1 FULL/BDR 00:00:30 10.1.1.1 FastEthernet0/0
    R2#

    但也因此,很多人都以為每一台 Router 都只有“一個”唯一的 Router ID。
    如果,我想在 R2 上面看到 R1 的 RID 是 2.2.2.1,而且不能使用 router-id 指令,也不能將 Loopback 介面 shutdown,該怎麼做呢?
    要解這個問題,必須先了解:在一台 Router 之中,可以啟動多個 OSPF process。而每一個 OSPF process 都會使用一個唯一的 Router ID。
    所以上面這個問題,我只需要在 R1 上面先設定一個 OSPF process,讓它選定 3.3.3.1 為 RID,但不下任何 network 指令。再設定一個要與 R2 建 neighbor 的 OSPF process,讓它選定 2.2.2.1 為 RID。

    R1:
    R1#show run
    router ospf 100
    log-adjacency-changes
    !
    router ospf 200
    log-adjacency-changes
    network 10.1.1.0 0.0.0.255 area 0

    R1#show ip ospf
    Routing Process “ospf 100” with ID 3.3.3.1
    Supports only single TOS(TOS0) routes
    Supports opaque LSA
    SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
    Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
    Number of external LSA 0. Checksum Sum 0x000000
    Number of opaque AS LSA 0. Checksum Sum 0x000000
    Number of DCbitless external and opaque AS LSA 0
    Number of DoNotAge external and opaque AS LSA 0
    Number of areas in this router is 0. 0 normal 0 stub 0 nssa
    External flood list length 0
    Routing Process “ospf 200” with ID 2.2.2.1
    Supports only single TOS(TOS0) routes
    Supports opaque LSA
    SPF schedule delay 5 secs, Hold time between two SPFs 10 secs
    Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs
    Number of external LSA 0. Checksum Sum 0x000000
    Number of opaque AS LSA 0. Checksum Sum 0x000000
    Number of DCbitless external and opaque AS LSA 0
    Number of DoNotAge external and opaque AS LSA 0
    Number of areas in this router is 1. 1 normal 0 stub 0 nssa
    External flood list length 0
    Area BACKBONE(0)
    Number of interfaces in this area is 1
    Area has no authentication
    SPF algorithm executed 2 times
    Area ranges are
    Number of LSA 4. Checksum Sum 0x01969f
    Number of opaque link LSA 0. Checksum Sum 0x000000
    Number of DCbitless LSA 0
    Number of indication LSA 0
    Number of DoNotAge LSA 0
    Flood list length 0

    R2:
    R2#show ip ospf neighbor
    Neighbor ID Pri State Dead Time Address Interface
    2.2.2.1 1 FULL/BDR 00:00:35 10.1.1.1 FastEthernet0/0