什么是OSPF
OSPF是链路状态路由协议。
架构介绍:花瓣形状,骨干区域为0区域,其他区域1、2、3都围绕区域0相连,
及个别的特殊情况,可以通过虚拟链路来连接
信息传递:向邻居发送是自己知道的所有状态的链路状态信息
路由标识:Router-ID是网络上唯一用于标识的一台路由器,线网用路由器的环回口
来配置Router-ID,这边的地址是32位的公网IP地址,如果没有标,通过物理口
来确认
区域规划:划分多个区域是为了优化网络性能,
OSPF实验
拓扑图
R1配置命令
<Huawei>sys
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 16.0.0.1 24
[R1-GigabitEthernet0/0/1]un sh
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/1]un sh
[R1-GigabitEthernet0/0/1]q
[R1]int loo0
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]q
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]network 12.0.0.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]network 1.1.1.1 0.0.0.0
[R1]rip 1
[R1-rip-1]version
[R1-rip-1]version 2
[R1-rip-1]un summary
[R1-rip-1]network 16.0.0.0
[[R1]ospf 1
[R1-ospf-1]import-route rip 1
R2配置命令
<Huawei>sys
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]un sh
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 23.0.0.2 24
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]int loo0
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-LoopBack0]q
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 1
[R2-ospf-1-area-0.0.0.1]network 12.0.0.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 23.0.0.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.1]q
[R2]
<R2>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 OSPF 10 1 D 12.0.0.1 GigabitEthernet
0/0/1
2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.3/32 OSPF 10 1 D 23.0.0.3 GigabitEthernet
0/0/2
4.4.4.4/32 OSPF 10 2 D 23.0.0.3 GigabitEthernet
0/0/2
5.5.5.5/32 OSPF 10 3 D 23.0.0.3 GigabitEthernet
0/0/2
6.6.6.6/32 O_ASE 150 6 D 12.0.0.1 GigabitEthernet
0/0/1
12.0.0.0/24 Direct 0 0 D 12.0.0.2 GigabitEthernet
0/0/1
12.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
16.0.0.0/24 O_ASE 150 6 D 12.0.0.1 GigabitEthernet
0/0/1
23.0.0.0/24 Direct 0 0 D 23.0.0.2 GigabitEthernet
0/0/2
23.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
34.0.0.0/24 OSPF 10 2 D 23.0.0.3 GigabitEthernet
0/0/2
45.0.0.0/24 OSPF 10 3 D 23.0.0.3 GigabitEthernet
0/0/2
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
R3配置命令
<Huawei>sys
[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 23.0.0.3 24
[R3-GigabitEthernet0/0/0]un sh
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.0.0.3 24
[R3-GigabitEthernet0/0/1]un sh
[R3-GigabitEthernet0/0/1]int loo0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3-LoopBack0]q
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 23.0.0.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]q
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]q
[R3]
R4配置命令
Huawei>sys
[Huawei]sys R4
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 34.0.0.4 24
[R4-GigabitEthernet0/0/0]un sh
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 45.0.0.4 24
[R4-GigabitEthernet0/0/1]int loo0
[R4-LoopBack0]ip add 4.4.4.4 32
[R4-LoopBack0]q
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]q
R5配置命令
<Huawei>sys
[Huawei]sys R5
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 45.0.0.5 24
[R5-GigabitEthernet0/0/0]un sh
[R5-GigabitEthernet0/0/0]int lo0
[R5-LoopBack0]ip add 5.5.5.5 32
[R5-LoopBack0]q
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 2
[R5-ospf-1-area-0.0.0.2]network 45.0.0.0 0.0.0.255
[R5-ospf-1-area-0.0.0.2]network 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.2]q
<R5>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 OSPF 10 1 D 12.0.0.1 GigabitEthernet
0/0/1
2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.3/32 OSPF 10 1 D 23.0.0.3 GigabitEthernet
0/0/2
4.4.4.4/32 OSPF 10 2 D 23.0.0.3 GigabitEthernet
0/0/2
5.5.5.5/32 OSPF 10 3 D 23.0.0.3 GigabitEthernet
0/0/2
6.6.6.6/32 O_ASE 150 6 D 12.0.0.1 GigabitEthernet
0/0/1
12.0.0.0/24 Direct 0 0 D 12.0.0.2 GigabitEthernet
0/0/1
12.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
16.0.0.0/24 O_ASE 150 6 D 12.0.0.1 GigabitEthernet
0/0/1
23.0.0.0/24 Direct 0 0 D 23.0.0.2 GigabitEthernet
0/0/2
23.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
34.0.0.0/24 OSPF 10 2 D 23.0.0.3 GigabitEthernet
0/0/2
45.0.0.0/24 OSPF 10 3 D 23.0.0.3 GigabitEthernet
0/0/2
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R6]配置命令
<Huawei>sys
[Huawei]sys R6
[R6]INT G0/0/0
[R6-GigabitEthernet0/0/0]ip add 16.0.0.6 24
[R6-GigabitEthernet0/0/0]un sh
[R6-GigabitEthernet0/0/0]int loo0
[R6-LoopBack0]ip add 6.6.6.6 32
[R6-LoopBack0]q
[R6]rip 1
[R6-rip-1]version 2
[R6-rip-1]un summary
[R6-rip-1]network 16.0.0.0
[R6-rip-1]network 6.0.0.0
[R6-rip-1]q
[R6]