静态路由+默认路由+浮动路由

在这里插入图片描述
第一步配置IP地址
R1:
undo terminal monitor
[Huawei] user-interface console 0
[Huawei]idle-timeout 0 0
[Huawei]sysname R1
[R1]int LoopBack 0
[R1-LoopBack0]ip address 172.16.1.1 24
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24

R2:
undo terminal monitor
[Huawei] user-interface console 0
[Huawei]idle-timeout 0 0
[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.2.1 24

R3:
undo terminal monitor
[Huawei] user-interface console 0
[Huawei]idle-timeout 0 0
[Huawei]sysname R3
[R3]int LoopBack 0
[R3-LoopBack0]ip address 172.16.2.1 24
[R3]int g0/0/0
[R3-GigabitEthernet0/0/1]ip address 192.168.2.2 24

第二步添加静态路由:
R1:
[R1]ip route-static 192.168.2.0 24 192.168.1.2
[R1]ip route-static 172.16.2.0 24 192.168.1.2
R2:
[R2]ip route-static 172.16.1.0 24 192.168.1.1
[R2]ip route-static 172.16.2.0 24 192.168.2.2

R3:
[R3]ip route-static 192.168.1.0 24 192.168.2.1
[R3]ip route-static 172.16.1.0 24 192.168.2.1

默认路由
默认路由是静态路由的一种特殊方式,它属于静态路由的一种。
使用条件:只能使用在末梢网络中使用
R1:
[R1]ip route-static 192.168.2.0 24 192.168.1.2
[R1]ip route-static 172.16.2.0 24 192.168.1.2
可以将俩条路由合并成一条默认路由,减少路由条目

1先删除这俩条静态路由
[R1]undo ip route-static 172.16.2.0 255.255.255.0 192.168.1.2
[R1]undo ip route-static 192.168.2.0 255.255.255.0 192.168.1.2

2修改为默认路由
在这里插入图片描述
即:[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
R3:
[R3]ip route-static 192.168.1.0 24 192.168.2.1
[R3]ip route-static 172.16.1.0 24 192.168.2.1

可以将俩条路由合并成一条默认路由,减少路由条目
1先删除这俩条静态路由
[R3]undo ip route-static 192.168.1.0 24 192.168.2.1
[R3]undo ip route-static 172.16.1.0 24 192.168.2.1

2修改为默认路由
在这里插入图片描述
浮动路由
在这里插入图片描述
[R1]int e0/0/0
[R1-Ethernet0/0/0]ip address 192.168.3.1 24

[R2]int e0/0/0
[R2-Ethernet0/0/0]ip address 192.162.3.2 24

[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.3.2 preference 61
设置这条路由的优先级为61(静态路由优先级为60)所以链路正常时不会走这条路
[R2]ip route-static 0.0.0.0 0.0.0.0 192.168.3.1 preference 61
效果:
[R1]tracert 172.16.2.1

traceroute to 172.16.2.1(172.16.2.1), max hops: 30 ,packet length: 40,press CT
RL_C to break

1 192.168.1.2 30 ms 50 ms 30 ms

2 192.168.2.2 80 ms 80 ms 40 ms

当g0/0/0这条链路不正常时

在这里插入图片描述
[R1]tracert 172.16.2.1

traceroute to 172.16.2.1(172.16.2.1), max hops: 30 ,packet length: 40,press CT
RL_C to break

1 192.168.3.2 50 ms 30 ms 40 ms

2 192.168.2.2 70 ms 60 ms 60 ms

猜你喜欢

转载自blog.csdn.net/weixin_49226813/article/details/107499931