OSPF配置实验
实验拓扑图
实验需求
1.配置IP地址
2.分区域配置OSPF,实现全网互通
3.为了路由结构稳定,要求路由器使用环回口作为Router-id,ABR的环回口宣告进骨干区域
实验配置
1.配置IP地址
R1:
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]sysname R1
[R1]interface GigabitEthernet 0/0
[R1-GigabitEthernet0/0]ip address 100.1.1.1 24
[R1-GigabitEthernet0/0]quit
[R1]interface GigabitEthernet 0/1
[R1-GigabitEthernet0/1]ip address 100.3.3.1 24
[R1-GigabitEthernet0/1]quit
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]quit
R2:
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]sysname R2
[R2]interface GigabitEthernet 0/0
[R2-GigabitEthernet0/0]ip address 100.1.1.2 24
[R2-GigabitEthernet0/0]quit
[R2]interface GigabitEthernet 0/1
[R2-GigabitEthernet0/1]ip address 100.2.2.2 24
[R2-GigabitEthernet0/1]quit
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]quit
R3:
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]sysname R3
[R3]interface GigabitEthernet 0/0
[R3-GigabitEthernet0/0]ip address 100.2.2.3 24
[R3-GigabitEthernet0/0]quit
[R3]interface GigabitEthernet 0/1
[R3-GigabitEthernet0/1]ip address 100.4.4.3 24
[R3-GigabitEthernet0/1]quit
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]quit
R4:
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]sysname R4
[R4]interface GigabitEthernet 0/0
[R4-GigabitEthernet0/0]ip address 100.3.3.4 24
[R4-GigabitEthernet0/0]quit
[R4]interface LoopBack 0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]quit
R5:
<H3C>system-view
System View: return to User View with Ctrl+Z.
[H3C]sysname R5
[R5]interface GigabitEthernet 0/0
[R5-GigabitEthernet0/0]ip address 100.4.4.5 24
[R5-GigabitEthernet0/0]quit
[R5]interface LoopBack 0
[R5-LoopBack0]ip address 5.5.5.5 32
[R5-LoopBack0]quit
2.分区域配置OSPF,实现全网互通
注意:实现全网互通,每台路由器都需要宣告本地的所有直连网段,包括环回口所在的网段。要求ABR的环回口宣告进骨干区域,即区域0,同时,每台路由器手动配置各自环回口的IP地址作为Router-id
在路由器上分别配置ospf,按区域宣告所有直连网段和环回口
R1:
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]area 1
[R1-ospf-1-area-0.0.0.1]network 100.3.3.0 0.0.0.255
R2:
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 100.1.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 100.2.2.0 0.0.0.255
R3:
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[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]network 100.2.2.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]area 2
[R3-ospf-1-area-0.0.0.2]network 100.4.4.0 0.0.0.255
R4:
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 1
[R4-ospf-1-area-0.0.0.1]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.1]network 100.3.3.0 0.0.0.255
R5:
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 2
[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]network 100.4.4.0 0.0.0.255
3.检查是否全网互通
检查ospf是否全网互通,一个是检查邻居关系表,看邻居关系是否正常;另一个是检查路由表,看是否学习到全网路由
检查R1的邻居关系表
[R1]display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 100.1.1.2 1 33 Full/BDR GE0/0
Area: 0.0.0.1
Router ID Address Pri Dead-Time State Interface
4.4.4.4 100.3.3.4 1 30 Full/BDR GE0/1
可以看到,R1 分别和 R2 和 R4 建立了邻接关系,状态为 FULL,邻居关系正常
检查R1的路由表
[R1]display ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 O_INTRA 10 1 100.1.1.2 GE0/0
3.3.3.3/32 O_INTRA 10 2 100.1.1.2 GE0/0
4.4.4.4/32 O_INTRA 10 1 100.3.3.4 GE0/1
5.5.5.5/32 O_INTER 10 3 100.1.1.2 GE0/0
100.1.1.0/24 Direct 0 0 100.1.1.1 GE0/0
100.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
100.1.1.255/32 Direct 0 0 100.1.1.1 GE0/0
100.2.2.0/24 O_INTRA 10 2 100.1.1.2 GE0/0
100.3.3.0/24 Direct 0 0 100.3.3.1 GE0/1
100.3.3.1/32 Direct 0 0 127.0.0.1 InLoop0
100.3.3.255/32 Direct 0 0 100.3.3.1 GE0/1
100.4.4.0/24 O_INTER 10 3 100.1.1.2 GE0/0
可以看到,R1已经学到了全网所有网段的路由信息
可以自行测试接口是否连通