1 案例:熟悉OSPF数据库
1.1 问题
- 如图配置 IP 和OSPF
- 查看并熟悉OSPF数据库
- 分析多区域带来的好处
1.2 方案
搭建实验环境,如图-1所示。
图-1
1.3 步骤
实现此案例需要按照如下步骤进行。[hidecontent type=”payshow”]
1)配置IP地址,设置OSPF区域
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ip add 192.168.12.1 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ip add 192.168.12.2 24
- [R2–GigabitEthernet0/0/1]quit
- [R2]interface GigabitEthernet 0/0/0
- [R2–GigabitEthernet0/0/0]ip add 192.168.23.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.12]quit
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip add 192.168.23.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/0
- [R3–GigabitEthernet0/0/0]ip add 192.168.34.3 24
- [R3–GigabitEthernet0/0/0]quit
- [R3]ospf 1 router–id 3.3.3.3
- [R3–ospf-1]area 0
- [R3–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R4
- [R4]interface GigabitEthernet 0/0/1
- [R4–GigabitEthernet0/0/1]ip add 192.168.34.4 24
- [R4–GigabitEthernet0/0/1]quit
- [R4]interface GigabitEthernet 0/0/0
- [R4–GigabitEthernet0/0/0]ip add 192.168.45.4 24
- [R4–GigabitEthernet0/0/0]quit
- [R4]ospf 1 router–id 4.4.4.4
- [R4–ospf-1]area 0
- [R4–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R5
- [R5]interface GigabitEthernet 0/0/1
- [R5–GigabitEthernet0/0/1]ip add 192.168.45.5 24
- [R5–GigabitEthernet0/0/1]quit
- [R5]interface GigabitEthernet 0/0/0
- [R5–GigabitEthernet0/0/0]ip add 192.168.56.5 24
- [R5–GigabitEthernet0/0/0]quit
- [R5]ospf 1 router–id 5.5.5.5
- [R5–ospf-1]area 56
- [R5–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.56]quit
- [R5–ospf-1]area 0
- [R5–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R6
- [R6]interface GigabitEthernet 0/0/1
- [R6–GigabitEthernet0/0/1]ip add 192.168.56.6 24
- [R6–GigabitEthernet0/0/1]quit
- [R6]ospf 1 router–id 6.6.6.6
- [R6–ospf-1]area 56
- [R6–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]quit
2)查看 R1 的 OSPF 数据库
- [R1]display ospf lsdb
- OSPF Process 1 with Router ID 1.1.1.1
- Link State Database
- Area: 0.0.0.12
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 2.2.2.2 2.2.2.2 78 36 80000005 1
- Router 1.1.1.1 1.1.1.1 78 36 80000004 1
- Network 192.168.12.2 2.2.2.2 79 32 80000002 0
- Sum–Net 192.168.45.0 2.2.2.2 71 28 80000001 3
- Sum–Net 192.168.23.0 2.2.2.2 116 28 80000001 1
- Sum–Net 192.168.56.0 2.2.2.2 36 28 80000001 4
- Sum–Net 192.168.34.0 2.2.2.2 71 28 80000001 2
3)查看 R2(ABR)的数据库
- [R2]display ospf lsdb
- OSPF Process 1 with Router ID 2.2.2.2
- Link State Database
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 4.4.4.4 4.4.4.4 88 48 80000007 1
- Router 2.2.2.2 2.2.2.2 122 36 80000004 1
- Router 5.5.5.5 5.5.5.5 87 36 80000004 1
- Router 3.3.3.3 3.3.3.3 120 48 80000006 1
- Network 192.168.23.3 3.3.3.3 120 32 80000002 0
- Network 192.168.34.3 3.3.3.3 124 32 80000002 0
- Network 192.168.45.5 5.5.5.5 87 32 80000002 0
- Sum–Net 192.168.56.0 5.5.5.5 126 28 80000001 1
- Sum–Net 192.168.12.0 2.2.2.2 167 28 80000001 1
- Area: 0.0.0.12
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 2.2.2.2 2.2.2.2 129 36 80000005 1
- Router 1.1.1.1 1.1.1.1 131 36 80000004 1
- Network 192.168.12.2 2.2.2.2 130 32 80000002 0
- Sum–Net 192.168.45.0 2.2.2.2 121 28 80000001 3
- Sum–Net 192.168.23.0 2.2.2.2 167 28 80000001 1
- Sum–Net 192.168.56.0 2.2.2.2 86 28 80000001 4
- Sum–Net 192.168.34.0 2.2.2.2 121 28 80000001 2
4)查看R3(骨干区域设备)的OSPF数据库
- [R3]display ospf lsdb
- OSPF Process 1 with Router ID 3.3.3.3
- Link State Database
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 4.4.4.4 4.4.4.4 140 48 80000007 1
- Router 2.2.2.2 2.2.2.2 175 36 80000004 1
- Router 5.5.5.5 5.5.5.5 139 36 80000004 1
- Router 3.3.3.3 3.3.3.3 172 48 80000006 1
- Network 192.168.23.3 3.3.3.3 172 32 80000002 0
- Network 192.168.34.3 3.3.3.3 175 32 80000002 0
- Network 192.168.45.5 5.5.5.5 139 32 80000002 0
- Sum–Net 192.168.56.0 5.5.5.5 178 28 80000001 1
- Sum–Net 192.168.12.0 2.2.2.2 220 28 80000001 1
2 案例:熟悉1/2类LSA数据库
2.1 问题
- 如图配置 IP 和OSPF
- 配置区域12为点到点网络
- 分析区域12中的1类LSA
- 分析区域56中的1类和2类LSA
2.2 方案
搭建实验环境,如图-2所示。
图-2
2.3 步骤
实现此案例需要按照如下步骤进行。
1)配置IP地址,设置OSPF区域
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ip add 192.168.12.1 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ip add 192.168.12.2 24
- [R2–GigabitEthernet0/0/1]quit
- [R2]interface GigabitEthernet 0/0/0
- [R2–GigabitEthernet0/0/0]ip add 192.168.23.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.12]quit
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip add 192.168.23.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/0
- [R3–GigabitEthernet0/0/0]ip add 192.168.34.3 24
- [R3–GigabitEthernet0/0/0]quit
- [R3]ospf 1 router–id 3.3.3.3
- [R3–ospf-1]area 0
- [R3–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R4
- [R4]interface GigabitEthernet 0/0/1
- [R4–GigabitEthernet0/0/1]ip add 192.168.34.4 24
- [R4–GigabitEthernet0/0/1]quit
- [R4]interface GigabitEthernet 0/0/0
- [R4–GigabitEthernet0/0/0]ip add 192.168.45.4 24
- [R4–GigabitEthernet0/0/0]quit
- [R4]ospf 1 router–id 4.4.4.4
- [R4–ospf-1]area 0
- [R4–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R5
- [R5]interface GigabitEthernet 0/0/1
- [R5–GigabitEthernet0/0/1]ip add 192.168.45.5 24
- [R5–GigabitEthernet0/0/1]quit
- [R5]interface GigabitEthernet 0/0/0
- [R5–GigabitEthernet0/0/0]ip add 192.168.56.5 24
- [R5–GigabitEthernet0/0/0]quit
- [R5]ospf 1 router–id 5.5.5.5
- [R5–ospf-1]area 56
- [R5–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.56]quit
- [R5–ospf-1]area 0
- [R5–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R6
- [R6]interface GigabitEthernet 0/0/1
- [R6–GigabitEthernet0/0/1]ip add 192.168.56.6 24
- [R6–GigabitEthernet0/0/1]quit
- [R6]ospf 1 router–id 6.6.6.6
- [R6–ospf-1]area 56
- [R6–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]quit
2)修改区域12的网络为点到点网络
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ospf network–type p2p
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ospf network–type p2p
3)查看 区域12 中的1类LSA
- [R1]display ospf lsdb router 1.1.1.1
- OSPF Process 1 with Router ID 1.1.1.1
- Area: 0.0.0.12
- Link State Database
- Type : Router
- Ls id : 1.1.1.1
- Adv rtr : 1.1.1.1
- Ls age : 10
- Len : 48
- Options : E
- seq# : 80000008
- chksum : 0x89b6
- Link count: 2
- * Link ID: 2.2.2.2
- Data : 192.168.12.1
- Link Type: P-2–P
- Metric : 1
- * Link ID: 192.168.12.0
- Data : 255.255.255.0
- Link Type: StubNet
- Metric : 1
- Priority : Low
- [R1]display ospf lsdb router 2.2.2.2
- OSPF Process 1 with Router ID 1.1.1.1
- Area: 0.0.0.12
- Link State Database
- Type : Router
- Ls id : 2.2.2.2
- Adv rtr : 2.2.2.2
- Ls age : 48
- Len : 48
- Options : ABR E
- seq# : 8000000b
- chksum : 0x2611
- Link count: 2
- * Link ID: 1.1.1.1
- Data : 192.168.12.2
- Link Type: P-2–P
- Metric : 1
- * Link ID: 192.168.12.0
- Data : 255.255.255.0
- Link Type: StubNet
- Metric : 1
- Priority : Low
4)查看区域56中的1类LSA和2类LSA
- <R6>display ospf lsdb router 5.5.5.5
- OSPF Process 1 with Router ID 6.6.6.6
- Area: 0.0.0.56
- Link State Database
- Type : Router
- Ls id : 5.5.5.5
- Adv rtr : 5.5.5.5
- Ls age : 516
- Len : 36
- Options : ABR E
- seq# : 80000006
- chksum : 0x5186
- Link count: 1
- * Link ID: 192.168.56.5
- Data : 192.168.56.5
- Link Type: TransNet
- Metric : 1
- <R6>display ospf lsdb router 6.6.6.6
- OSPF Process 1 with Router ID 6.6.6.6
- Area: 0.0.0.56
- Link State Database
- Type : Router
- Ls id : 6.6.6.6
- Adv rtr : 6.6.6.6
- Ls age : 540
- Len : 36
- Options : E
- seq# : 80000003
- chksum : 0x16bc
- Link count: 1
- * Link ID: 192.168.56.5
- Data : 192.168.56.6
- Link Type: TransNet
- Metric : 1
- <R6>display ospf lsdb network 192.168.56.5
- OSPF Process 1 with Router ID 6.6.6.6
- Area: 0.0.0.56
- Link State Database
- Type : Network
- Ls id : 192.168.56.5
- Adv rtr : 5.5.5.5
- Ls age : 559
- Len : 32
- Options : E
- seq# : 80000002
- chksum : 0x72ff
- Net mask : 255.255.255.0
- Priority : Low
- Attached Router 5.5.5.5
- Attached Router 6.6.6.6
3 案例:熟悉3类LSA数据库
3.1 问题
- 如图配置 IP 和OSPF
- 分析区域0和 区域56中的3类LSA
- 熟悉基于LSA计算路由的过程
3.2 方案
搭建实验环境,如图-3所示。
图-3
3.3 步骤
实现此案例需要按照如下步骤进行。
1)配置IP地址,设置OSPF区域
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ip add 192.168.12.1 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ip add 192.168.12.2 24
- [R2–GigabitEthernet0/0/1]quit
- [R2]interface GigabitEthernet 0/0/0
- [R2–GigabitEthernet0/0/0]ip add 192.168.23.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.12]quit
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip add 192.168.23.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/0
- [R3–GigabitEthernet0/0/0]ip add 192.168.34.3 24
- [R3–GigabitEthernet0/0/0]quit
- [R3]ospf 1 router–id 3.3.3.3
- [R3–ospf-1]area 0
- [R3–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R4
- [R4]interface GigabitEthernet 0/0/1
- [R4–GigabitEthernet0/0/1]ip add 192.168.34.4 24
- [R4–GigabitEthernet0/0/1]quit
- [R4]interface GigabitEthernet 0/0/0
- [R4–GigabitEthernet0/0/0]ip add 192.168.45.4 24
- [R4–GigabitEthernet0/0/0]quit
- [R4]ospf 1 router–id 4.4.4.4
- [R4–ospf-1]area 0
- [R4–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R5
- [R5]interface GigabitEthernet 0/0/1
- [R5–GigabitEthernet0/0/1]ip add 192.168.45.5 24
- [R5–GigabitEthernet0/0/1]quit
- [R5]interface GigabitEthernet 0/0/0
- [R5–GigabitEthernet0/0/0]ip add 192.168.56.5 24
- [R5–GigabitEthernet0/0/0]quit
- [R5]ospf 1 router–id 5.5.5.5
- [R5–ospf-1]area 56
- [R5–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.56]quit
- [R5–ospf-1]area 0
- [R5–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R6
- [R6]interface GigabitEthernet 0/0/1
- [R6–GigabitEthernet0/0/1]ip add 192.168.56.6 24
- [R6–GigabitEthernet0/0/1]quit
- [R6]ospf 1 router–id 6.6.6.6
- [R6–ospf-1]area 56
- [R6–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]quit
2)查看区域0中R3的LSDB以及3类LSA
- <R3>display ospf lsdb
- OSPF Process 1 with Router ID 3.3.3.3
- Link State Database
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 4.4.4.4 4.4.4.4 773 48 80000007 1
- Router 2.2.2.2 2.2.2.2 808 36 80000004 1
- Router 5.5.5.5 5.5.5.5 772 36 80000004 1
- Router 3.3.3.3 3.3.3.3 805 48 80000006 1
- Network 192.168.23.3 3.3.3.3 805 32 80000002 0
- Network 192.168.34.3 3.3.3.3 808 32 80000002 0
- Network 192.168.45.5 5.5.5.5 772 32 80000002 0
- Sum–Net 192.168.56.0 5.5.5.5 811 28 80000001 1
- Sum–Net 192.168.12.0 2.2.2.2 853 28 80000001 1
- <R3>display ospf lsdb summary 192.168.12.0
- OSPF Process 1 with Router ID 3.3.3.3
- Area: 0.0.0.0
- Link State Database
- Type : Sum–Net
- Ls id : 192.168.12.0
- Adv rtr : 2.2.2.2
- Ls age : 915
- Len : 28
- Options : E
- seq# : 80000001
- chksum : 0x3db
- Net mask : 255.255.255.0
- Tos 0 metric: 1
- Priority : Low
3)查看区域56中的R6的LSDB 以及3类LSA
- <R6>display ospf lsdb
- OSPF Process 1 with Router ID 6.6.6.6
- Link State Database
- Area: 0.0.0.56
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 6.6.6.6 6.6.6.6 913 36 80000003 1
- Router 5.5.5.5 5.5.5.5 909 36 80000006 1
- Network 192.168.56.5 5.5.5.5 909 32 80000002 0
- Sum–Net 192.168.45.0 5.5.5.5 960 28 80000001 1
- Sum–Net 192.168.23.0 5.5.5.5 923 28 80000001 3
- Sum–Net 192.168.34.0 5.5.5.5 923 28 80000001 2
- Sum–Net 192.168.12.0 5.5.5.5 923 28 80000001 4
- <R6>display ospf lsdb summary 192.168.12.0
- OSPF Process 1 with Router ID 6.6.6.6
- Area: 0.0.0.56
- Link State Database
- Type : Sum–Net
- Ls id : 192.168.12.0
- Adv rtr : 5.5.5.5
- Ls age : 955
- Len : 28
- Options : E
- seq# : 80000001
- chksum : 0xc609
- Net mask : 255.255.255.0
- Tos 0 metric: 4
- Priority : Low
4 案例:熟悉4/5类LSA
4.1 问题
- 如图配置 IP 和 OSPF
- R6配置静态路由,访问 PC-3
- 确保PC-1和PC-2可以访问PC-3
- 分类5类LSA,熟悉路由计算过程
4.2 方案
搭建实验环境,如图-4所示。
图-4
4.3 步骤
实现此案例需要按照如下步骤进行。
1)配置IP地址,设置OSPF区域
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ip add 192.168.12.1 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]interface GigabitEthernet 0/0/2
- [R1–GigabitEthernet0/0/2]ip add 192.168.1.254 24
- [R1–GigabitEthernet0/0/2]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]network 192.168.1.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ip add 192.168.12.2 24
- [R2–GigabitEthernet0/0/1]quit
- [R2]interface GigabitEthernet 0/0/0
- [R2–GigabitEthernet0/0/0]ip add 192.168.23.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.12]quit
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip add 192.168.23.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/0
- [R3–GigabitEthernet0/0/0]ip add 192.168.34.3 24
- [R3–GigabitEthernet0/0/0]quit
- [R3]ospf 1 router–id 3.3.3.3
- [R3–ospf-1]area 0
- [R3–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R4
- [R4]interface GigabitEthernet 0/0/1
- [R4–GigabitEthernet0/0/1]ip add 192.168.34.4 24
- [R4–GigabitEthernet0/0/1]quit
- [R4]interface GigabitEthernet 0/0/0
- [R4–GigabitEthernet0/0/0]ip add 192.168.45.4 24
- [R4–GigabitEthernet0/0/0]quit
- [R4]ospf 1 router–id 4.4.4.4
- [R4–ospf-1]area 0
- [R4–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R5
- [R5]interface GigabitEthernet 0/0/1
- [R5–GigabitEthernet0/0/1]ip add 192.168.45.5 24
- [R5–GigabitEthernet0/0/1]quit
- [R5]interface GigabitEthernet 0/0/0
- [R5–GigabitEthernet0/0/0]ip add 192.168.56.5 24
- [R5–GigabitEthernet0/0/0]quit
- [R5]ospf 1 router–id 5.5.5.5
- [R5–ospf-1]area 56
- [R5–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.56]quit
- [R5–ospf-1]area 0
- [R5–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R6
- [R6]interface GigabitEthernet 0/0/0
- [R6–GigabitEthernet0/0/0]ip add 192.168.67.6 24
- [R6–GigabitEthernet0/0/0]quit
- [R6]interface GigabitEthernet 0/0/1
- [R6–GigabitEthernet0/0/1]ip add 192.168.56.6 24
- [R6–GigabitEthernet0/0/1]quit
- [R6]interface GigabitEthernet 0/0/2
- [R6–GigabitEthernet0/0/2]ip add 192.168.2.254 24
- [R6–GigabitEthernet0/0/2]quit
- [R6]ospf 1 router–id 6.6.6.6
- [R6–ospf-1]area 56
- [R6–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]network 192.168.2.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R7
- [R7]interface GigabitEthernet 0/0/1
- [R7–GigabitEthernet0/0/0]ip add 192.168.67.7 24
- [R7–GigabitEthernet0/0/0]quit
- [R7]interface GigabitEthernet 0/0/2
- [R7–GigabitEthernet0/0/2]ip add 192.168.3.254 24
- [R7–GigabitEthernet0/0/2]quit
- [R7]ip route–static 192.168.0.0 16 192.168.67.6
2)配置 R6 与 R7 之间的互通路由,并引入 OSPF
- [R6]ip route–static 192.168.3.0 24 192.168.67.7
- [R6]ospf 1
- [R6–ospf-1]import–route static
3)查看 R1 的 OSPF 数据库,确认 192.168.3.0/24 的路由信息
- <R1>display ospf lsdb
- OSPF Process 1 with Router ID 1.1.1.1
- Link State Database
- Area: 0.0.0.12
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 2.2.2.2 2.2.2.2 1353 48 8000000B 1
- Router 1.1.1.1 1.1.1.1 1352 48 80000008 1
- Sum–Net 192.168.45.0 2.2.2.2 1800 28 80000001 3
- Sum–Net 192.168.23.0 2.2.2.2 46 28 80000002 1
- Sum–Net 192.168.56.0 2.2.2.2 1765 28 80000001 4
- Sum–Net 192.168.34.0 2.2.2.2 1800 28 80000001 2
- Sum–Asbr 6.6.6.6 2.2.2.2 5 28 80000001 4
- AS External Database
- Type LinkState ID AdvRouter Age Len Sequence Metric
- External 192.168.3.0 6.6.6.6 9 36 80000001 1
4)查看表示 192.168.3.0/24 的 5类LSA
- <R1>display ospf lsdb ase 192.168.3.0
- OSPF Process 1 with Router ID 1.1.1.1
- Link State Database
- Type : External
- Ls id : 192.168.3.0
- Adv rtr : 6.6.6.6
- Ls age : 26
- Len : 36
- Options : E
- seq# : 80000001
- chksum : 0x77d4
- Net mask : 255.255.255.0
- TOS 0 Metric: 1
- E type : 2
- Forwarding Address : 0.0.0.0
- Tag : 1
- Priority : Low
4)查看表示 ASBR 信息的4类LSA
- <R1>display ospf lsdb asbr 6.6.6.6
- OSPF Process 1 with Router ID 1.1.1.1
- Area: 0.0.0.12
- Link State Database
- Type : Sum–Asbr
- Ls id : 6.6.6.6
- Adv rtr : 2.2.2.2
- Ls age : 63
- Len : 28
- Options : E
- seq# : 80000001
- chksum : 0x3404
- Tos 0 metric: 4
5)确保PC-1/2 与 PC3之间的互通
- PC-1>ping 192.168.3.1
- Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
- — 192.168.3.1 ping statistics —
- 5 packet(s) transmitted
- PC-2>ping 192.168.3.1
- Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
- — 192.168.3.1 ping statistics —
- 5 packet(s) transmitted
5 案例:OSPF路由选路
5.1 问题
- 如图配置 VLAN、IP和OSPF
- R1/R2配置静态路由,访问PC-2
- 确保 PC-1与PC-2可以互相访问
- PC-1的网关配置在 SW1 上
- R1是主出口设备,R2是备份出口设备
- 要求数据转发是最优路径
5.2 方案
搭建实验环境,如图-5所示。
图-5
5.3 步骤
实现此案例需要按照如下步骤进行。
1)配置终端设备
- PC-1:
- 192.168.6.1
- 255.255.255.0
- 192.168.6.254
- PC-2:
- 192.168.2.1
- 255.255.255.0
- 192.168.2.254
2)配置交换机
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname SW1
- [SW1]vlan batch 6 10 20
- [SW1]interface GigabitEthernet 0/0/1
- [SW1–GigabitEthernet0/0/1]port link–type access
- [SW1–GigabitEthernet0/0/1]port default vlan 10
- [SW1–GigabitEthernet0/0/1]quit
- [SW1]interface GigabitEthernet 0/0/2
- [SW1–GigabitEthernet0/0/2]port link–type access
- [SW1–GigabitEthernet0/0/2]port default vlan 20
- [SW1–GigabitEthernet0/0/2]quit
- [SW1]interface GigabitEthernet 0/0/3
- [SW1–GigabitEthernet0/0/3]port link–type access
- [SW1–GigabitEthernet0/0/3]port default vlan 6
- [SW1–GigabitEthernet0/0/3]quit
- [SW1]interface Vlanif 6
- [SW1–Vlanif6]ip address 192.168.6.254 24
- [SW1–Vlanif6]quit
- [SW1]interface Vlanif 10
- [SW1–Vlanif10]ip address 192.168.10.1 24
- [SW1–Vlanif10]quit
- [SW1]interface Vlanif 20
- [SW1–Vlanif20]ip address 192.168.20.1 24
- [SW1–Vlanif20]quit
3)配置路由器
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface gi0/0/0
- [R1–GigabitEthernet0/0/0]ip address 192.168.10.2 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]interface gi0/0/1
- [R1–GigabitEthernet0/0/1]ip address 192.168.13.1 24
- [R1–GigabitEthernet0/0/1]quit
- [R1]ip route–static 0.0.0.0 0 192.168.13.3
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface gi0/0/0
- [R2–GigabitEthernet0/0/0]ip address 192.168.20.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]interface gi0/0/2
- [R2–GigabitEthernet0/0/2]ip address 192.168.23.2 24
- [R2–GigabitEthernet0/0/2]quit
- [R2]ip route–static 0.0.0.0 0 192.168.23.3
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip address 192.168.13.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/2
- [R3–GigabitEthernet0/0/2]ip address 192.168.23.3 24
- [R3–GigabitEthernet0/0/2]quit
- [R3]interface gi0/0/0
- [R3–GigabitEthernet0/0/0]ip address 192.168.2.254 24
- [R3–GigabitEthernet0/0/0]quit
4)配置基本的OSPF
- [SW1]ospf 1 router–id 6.6.6.6
- [SW1–ospf-1]area 0
- [SW1–ospf-1–area-0.0.0.0]network 192.168.6.0 0.0.0.255
- [SW1–ospf-1–area-0.0.0.0]network 192.168.10.0 0.0.0.255
- [SW1–ospf-1–area-0.0.0.0]network 192.168.20.0 0.0.0.255
- [SW1–ospf-1–area-0.0.0.0]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 0
- [R1–ospf-1–area-0.0.0.0]network 192.168.10.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.20.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
5)配置OSPF默认路由
- [R1]ospf 1
- [R1–ospf-1]default–route–advertise
- [R2]ospf 1
- [R2–ospf-1]default–route–advertise cost 2
6)配置浮动静态路由
- [R3]ip route–static 192.168.6.0 24 192.168.13.1
- [R3]ip route–static 192.168.6.0 24 192.168.23.2 preference 100
7)测试 PC-1和 PC-2 之间的连通性
- PC-1>ping 192.168.2.1
- Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.2.1: bytes=32 seq=1 ttl=125 time=47 ms
- From 192.168.2.1: bytes=32 seq=2 ttl=125 time=47 ms
- From 192.168.2.1: bytes=32 seq=3 ttl=125 time=32 ms
- From 192.168.2.1: bytes=32 seq=4 ttl=125 time=31 ms
- From 192.168.2.1: bytes=32 seq=5 ttl=125 time=47 ms
- — 192.168.2.1 ping statistics —
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round–trip min/avg/max = 31/40/47 ms
- PC-2>ping 192.168.6.1
- Ping 192.168.6.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.6.1: bytes=32 seq=1 ttl=125 time=47 ms
- From 192.168.6.1: bytes=32 seq=2 ttl=125 time=31 ms
- From 192.168.6.1: bytes=32 seq=3 ttl=125 time=62 ms
- From 192.168.6.1: bytes=32 seq=4 ttl=125 time=63 ms
- From 192.168.6.1: bytes=32 seq=5 ttl=125 time=62 ms
- — 192.168.6.1 ping statistics —
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round–trip min/avg/max = 31/53/63 ms
6 案例:配置 OSPF 特殊区域
6.1 问题
- 如图,配置设备 IP 地址和 OSPF 区域
- R6 与 R7 之间不运行 OSPF,通过静态路由互通
- 区域 12 没有外部路由
- 确保 PC-1 与 PC-3 可以互通
6.2 方案
搭建实验环境,如图-6所示。
图-6
6.3 步骤
实现此案例需要按照如下步骤进行。
1)配置IP地址,设置OSPF区域
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R1
- [R1]interface GigabitEthernet 0/0/0
- [R1–GigabitEthernet0/0/0]ip add 192.168.12.1 24
- [R1–GigabitEthernet0/0/0]quit
- [R1]interface GigabitEthernet 0/0/2
- [R1–GigabitEthernet0/0/2]ip add 192.168.1.254 24
- [R1–GigabitEthernet0/0/2]quit
- [R1]ospf 1 router–id 1.1.1.1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]network 192.168.1.0 0.0.0.255
- [R1–ospf-1–area-0.0.0.12]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R2
- [R2]interface GigabitEthernet 0/0/1
- [R2–GigabitEthernet0/0/1]ip add 192.168.12.2 24
- [R2–GigabitEthernet0/0/1]quit
- [R2]interface GigabitEthernet 0/0/0
- [R2–GigabitEthernet0/0/0]ip add 192.168.23.2 24
- [R2–GigabitEthernet0/0/0]quit
- [R2]ospf 1 router–id 2.2.2.2
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]network 192.168.12.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.12]quit
- [R2–ospf-1]area 0
- [R2–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R2–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R3
- [R3]interface GigabitEthernet 0/0/1
- [R3–GigabitEthernet0/0/1]ip add 192.168.23.3 24
- [R3–GigabitEthernet0/0/1]quit
- [R3]interface GigabitEthernet 0/0/0
- [R3–GigabitEthernet0/0/0]ip add 192.168.34.3 24
- [R3–GigabitEthernet0/0/0]quit
- [R3]ospf 1 router–id 3.3.3.3
- [R3–ospf-1]area 0
- [R3–ospf-1–area-0.0.0.0]network 192.168.23.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R3–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R4
- [R4]interface GigabitEthernet 0/0/1
- [R4–GigabitEthernet0/0/1]ip add 192.168.34.4 24
- [R4–GigabitEthernet0/0/1]quit
- [R4]interface GigabitEthernet 0/0/0
- [R4–GigabitEthernet0/0/0]ip add 192.168.45.4 24
- [R4–GigabitEthernet0/0/0]quit
- [R4]ospf 1 router–id 4.4.4.4
- [R4–ospf-1]area 0
- [R4–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]network 192.168.34.0 0.0.0.255
- [R4–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R5
- [R5]interface GigabitEthernet 0/0/1
- [R5–GigabitEthernet0/0/1]ip add 192.168.45.5 24
- [R5–GigabitEthernet0/0/1]quit
- [R5]interface GigabitEthernet 0/0/0
- [R5–GigabitEthernet0/0/0]ip add 192.168.56.5 24
- [R5–GigabitEthernet0/0/0]quit
- [R5]ospf 1 router–id 5.5.5.5
- [R5–ospf-1]area 56
- [R5–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.56]quit
- [R5–ospf-1]area 0
- [R5–ospf-1–area-0.0.0.0]network 192.168.45.0 0.0.0.255
- [R5–ospf-1–area-0.0.0.0]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R6
- [R6]interface GigabitEthernet 0/0/0
- [R6–GigabitEthernet0/0/0]ip add 192.168.67.6 24
- [R6–GigabitEthernet0/0/0]quit
- [R6]interface GigabitEthernet 0/0/1
- [R6–GigabitEthernet0/0/1]ip add 192.168.56.6 24
- [R6–GigabitEthernet0/0/1]quit
- [R6]interface GigabitEthernet 0/0/2
- [R6–GigabitEthernet0/0/2]ip add 192.168.2.254 24
- [R6–GigabitEthernet0/0/2]quit
- [R6]ospf 1 router–id 6.6.6.6
- [R6–ospf-1]area 56
- [R6–ospf-1–area-0.0.0.56]network 192.168.56.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]network 192.168.2.0 0.0.0.255
- [R6–ospf-1–area-0.0.0.56]quit
- <Huawei>undo terminal monitor
- <Huawei>system–view
- [Huawei]sysname R7
- [R7]interface GigabitEthernet 0/0/1
- [R7–GigabitEthernet0/0/0]ip add 192.168.67.7 24
- [R7–GigabitEthernet0/0/0]quit
- [R7]interface GigabitEthernet 0/0/2
- [R7–GigabitEthernet0/0/2]ip add 192.168.3.254 24
- [R7–GigabitEthernet0/0/2]quit
- [R7]ip route–static 192.168.0.0 16 192.168.67.6
2)配置 R6 与 R7 之间的互通路由,并引入 OSPF
- [R6]ip route–static 192.168.3.0 24 192.168.67.7
- [R6]ospf 1
- [R6–ospf-1]import–route static
3)配置区域12 为特殊区域
- [R1]ospf 1
- [R1–ospf-1]area 12
- [R1–ospf-1–area-0.0.0.12]stub
- [R1–ospf-1–area-0.0.0.12]quit
- [R2]ospf 1
- [R2–ospf-1]area 12
- [R2–ospf-1–area-0.0.0.12]stub
- [R2–ospf-1–area-0.0.0.12]quit
3)确保PC-1/2 与 PC3之间的互通
- PC-1>ping 192.168.3.1
- Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
- — 192.168.3.1 ping statistics —
- 5 packet(s) transmitted
- PC-2>ping 192.168.3.1
- Ping 192.168.3.1: 32 data bytes, Press Ctrl_C to break
- From 192.168.3.1: bytes=32 seq=1 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=2 ttl=125 time=31 ms
- From 192.168.3.1: bytes=32 seq=3 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=4 ttl=125 time=16 ms
- From 192.168.3.1: bytes=32 seq=5 ttl=125 time=31 ms
- — 192.168.3.1 ping statistics —
- 5 packet(s) transmitted[/hidecontent]