组网需求
- 在R1与R3之间的链路出现故障的时候,R1的流量能够快速切换到备份链路
- 此时R1的流量通过R2进行转发
组网拓扑
配置思路
- 配置路由器基本功能以及各个接口IP地址
- 配置OSPF协议,宣告路由,设置各个接口Cost值
- 在R1上使能OSPF IP FRR功能
配置命令
配置路由器基本功能以及各个接口IP地址
R1配置
1
2
3
4
5
6
7sys
sys R1
int g0/0/0
ip add 10.1.13.1 30
int g0/0/1
ip add 10.1.12.1 30
R2配置
1
2
3
4
5
6
7sys
sys R2
int g0/0/1
ip add 10.1.12.2 30
int g0/0/2
ip add 10.1.23.2 30
R3配置
1
2
3
4
5
6
7
8
9sys
sys R3
int g0/0/0
ip add 10.1.13.2 30
int g0/0/1
ip add 10.1.34.1 30
int g0/0/2
ip add 10.1.23.1 30
R4配置
1
2
3
4
5sys
sys R4
int g0/0/1
ip add 10.1.34.2 30
配置OSPF协议,宣告路由,设置各个接口Cost值
R1配置
1
2
3
4
5
6
7
8
9
10sys
ospf 1 router-id 10.1.1.1
area 0
network 10.1.13.0 0.0.0.3
network 10.1.12.0 0.0.0.3
int g0/0/0
ospf cost 10
int g0/0/1
ospf cost 10
R2配置
1
2
3
4
5
6
7
8
9
10sys
ospf 1 router-id 10.1.2.2
area 0
network 10.1.23.0 0.0.0.3
network 10.1.12.0 0.0.0.3
int g0/0/1
ospf cost 10
int g0/0/2
ospf cost 5
R3配置
1
2
3
4
5
6
7
8
9
10
11
12
13sys
ospf 1 router-id 10.1.3.3
area 0
network 10.1.13.0 0.0.0.3
network 10.1.23.0 0.0.0.3
network 10.1.34.0 0.0.0.3
int g0/0/0
ospf cost 10
int g0/0/1
ospf cost 5
int g0/0/2
ospf cost 5
R4配置
1
2
3
4
5
6
7sys
ospf 1 router-id 10.1.4.4
area 0
network 10.1.34.0 0.0.0.3
int g0/0/1
ospf cost 5
配置OSPF IP FRR
R1配置
1
2
3
4sys
ospf 1
frr
loop-free-alternate
查看结果
配置之前R4路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19display ip routing-table protocol ospf
<R4>dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 3
OSPF routing table status : <Active>
Destinations : 3 Routes : 3
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.12.0/30 OSPF 10 3 D 10.1.34.1 GigabitEthernet
0/0/1
10.1.13.0/30 OSPF 10 2 D 10.1.34.1 GigabitEthernet
0/0/1
10.1.23.0/30 OSPF 10 2 D 10.1.34.1 GigabitEthernet
0/0/1
配置Cost之后R4路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26display ip routing-table
<R4>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.12.0/30 OSPF 10 16 D 10.1.34.1 GigabitEthernet
0/0/1
10.1.13.0/30 OSPF 10 11 D 10.1.34.1 GigabitEthernet
0/0/1
10.1.23.0/30 OSPF 10 6 D 10.1.34.1 GigabitEthernet
0/0/1
10.1.34.0/30 Direct 0 0 D 10.1.34.2 GigabitEthernet
0/0/1
10.1.34.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
10.1.34.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
配置FRR后,当链路中断后R1到R4的路由变化(路由由R1-R3-R4切换到R1-R2-R3-R4)
链路中断前路由
1
2
3
4
5
6
7
8
9
10tracert 10.1.34.2
<R1>tracert 10.1.34.2
traceroute to 10.1.34.2(10.1.34.2), max hops: 30 ,packet length: 40,press CTRL
_C to break
1 10.1.13.2 40 ms 20 ms 20 ms
2 10.1.34.2 20 ms 20 ms 20 ms
链路中断后路由
1
2
3
4
5
6
7
8
9
10
11
12tracert 10.1.34.2
<R1>tracert 10.1.34.2
traceroute to 10.1.34.2(10.1.34.2), max hops: 30 ,packet length: 40,press CTRL
_C to break
1 10.1.12.2 30 ms 10 ms 10 ms
2 10.1.23.1 20 ms 20 ms 30 ms
3 10.1.34.2 20 ms 20 ms 20 ms