CCNP—OSPF

Introduce

1. 全名: Open Shortest Path First(OSPF)。

2. 類型: IGP。

3. 演算法: 最短路(Dijkstra)。

4. AD: 110。

5. Multicast address: 224.0.0.5, 224.0.0.6。

6. 特性: ECMP, Link-State, MD5 authentication。

Component

1. Router ID: 每台 OSPF 路由器的唯一識別碼。

2. Area: 網路區域,主幹為 Area 0。

3. LSA: 鏈路狀態通告,OSPF 傳遞路由資訊的單位。

4. LSDB: 每台 OSPF 路由器的 LSA 資料庫,用來產生 SPF 樹。

5. DR(Designated Router)/BDR(Backup DR): 在廣播網路中選出 DR/BDR,減少交換訊息數量。

Packet Type

1. Hello: 建立與維持鄰居關係。

2. DBD(Database Description): 交換 LSDB。

3. LSR: 請求缺少的LSA。

4. LSU: 傳送 LSA 資訊。

5. LSAck: 確認收到 LSU。

OSPF neighbor establishment

1. DOWN: 初始狀態,尚未收到對方 Hello 封包。

2. INIT: 收到對方 Hello,但對方還沒認同自己為鄰居。

3. TWO-WAY: 雙方在 Hello 封包中看到對方,鄰居關係正式建立(廣播網段選 DR/BDR)。

4. EX-START: 開始協商誰是主,準備資料庫交換。

5. EX-EXCHANGE: 使用 DBD(Database Description)封包交換摘要。

6. LOADING: 請求缺少的 LSA(用 LSR → LSU → LSAck)。

7. FULL: LSDB 同步完成,鄰居關係完全建立。

OSPF-NetworkType

1. Broadcast: 自動選DR/BDR, 使用224.0.0.5傳送hello, 自動建立鄰居。

2. Non-Broadcast(NBMA): 支援DR/BDR, 使用Unicast, 手動指定鄰居。

3. P2P: 不選DR/BDR, 使用224.0.0.5傳送hello, 自動建立鄰居。

4. P2MP: 不選DR/BDR, 使用224.0.0.5傳送hello, HUB-AND-SPOKE單獨鄰居。

OSPF-PacketType

type 1 - Router LSA:  
    每台路由器會產生,描述它自己的連線(介面、鄰居等)只在Area內傳播。

type 2 - Network LSA:
    由DR產生,描述該廣播網段上的所有路由器只在區域內傳播。

type 3 - Summary LSA (ABR):  
    ABR 產生,用來告訴其他區域關於不同區域的網段資訊(類似 route summary)在多區域 OSPF 中傳播。

type 4 - ASBR Summary LSA:  
    ABR 產生,用來告訴其他區域 ASBR 的位置(為了轉送外部路由)。

type 5 - External LSA (AS-External):
    由 ASBR 產生,用來宣告從 OSPF 區域外學到的路由(例如從 BGP 或靜態匯入的)。

type 7 - NSSA External LSA:
    由 ASBR 發出,類似 Type 5,但用在 NSSA 區域(Not-So-Stubby Area)中,只能在 NSSA 內傳播。

Configuration - 1. interface

en
conf t
    int e 0/0
        ip address 192.168.1.1 255.255.255.0
        ip ospf 10 area 0
        exit

    int e 0/1
        ip address 192.168.10.1 255.255.255.0
        ip ospf 10 area 0
        exit

    router ospf 10
        # setup RID
        router-id 1.1.1.1

        # summary
        area 0 range 192.168.0.0 255.255.0.0
    end
wr

Configuration - 2. process

en
conf t
    router ospf 10
        # setup RID
        router-id 1.1.1.1

        # setup network
        network 192.168.1.0 0.0.0.255 area 0
        network 192.168.10.0 0.0.0.255 area 0

        # summary
        area 40 range 192.168.0.0 255.255.0.0

    end
wr

Configuration - 3. setup priority, passive interface, network type, 刷新process

en
conf t
    int e 0/0
        ip ospf priority 255
        exit

    int e 0/1
        ip ospf network point-to-point
        exit

    router ospf 10
        # setup passive interface
        passive-interface e 0/0

    end

# 重跑OSPF process
clear ip ospf process
wr

Check

show ip ospf 

show ip ospf neighbor

show ip route [ospf]

debug ip ospf adj

debug ip ospf hello

debug ip ospf events