一、搭建实验环境
R1配置
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 202.100.1.1 255.255.255.0
quit
[R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]ip add 202.100.2.1 255.255.255.0
quit
[R1-GigabitEthernet0/0/1]int lo 0 //创建环回接口
[R1-LoopBack0]ip add 1.1.1.1 255.255.255.255
[R1-LoopBack0]quit
[R1]display current-configuration interface //显示接口信息
R2配置
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip add 202.100.1.2 255.255.255.0
[R2-GigabitEthernet0/0/1]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 202.100.3.2 255.255.255.0
[R2-GigabitEthernet0/0/0]int lo 0
[R2-LoopBack0]ip ad 2.2.2.2 255.255.255.255
[R2-LoopBack0]quit
R3配置
[R3]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 202.100.2.3 255.255.255.0
[R3-GigabitEthernet0/0/2]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 202.100.3.3 255.255.255.0
[R3-GigabitEthernet0/0/0]int lo 0
[R3-LoopBack0]ip add 3.3.3.3 255.255.255.255
R1可以ping通202.100.1.2 和202.100.2.3
二、配置静态路由
[R1]ip route-static 3.3.3.3 255.255.255.255 202.100.2.3 ===添加静态路由
[R1]ip route-static 202.100.3.0 255.255.255.0 202.100.2.3
R1可以ping通 3.3.3.3和202.100.3.3
三、配置浮动路由
配置备份静态路由,当 R1 与 R3 之间链路出现故障时,可走 R2。
1.配置R1到R2、3的路由
[R2]ip route-static 3.3.3.3 255.255.255.255 202.100.3.3
[R1]ip route-static 202.100.3.0 24 202.100.1.2 preference 80
[R1]ip route-static 3.3.3.3 32 202.100.1.2 preference 80
[R3]ip route-static 202.100.1.0 255.255.255.0 202.100.3.2
配置完毕R1可以tracert 202.100.3.3和3.3.3.3
2.模拟R1与R3之间链路出现故障时
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]shutdown
R1还可以tracert 202.100.3.3和3.3.3.3
[R1]interface g0/0/2
[R1-GigabitEthernet0/0/2]undo shutdown
[R2]ip route-static 0.0.0.0 0.0.0.0 202.100.3.3 ====添加默认路由
R2可以ping 202.100.2.1
四、配置默认路由
配置备份默认路由,当 R2 与 R3 之间链路出现故障时,可走 R1。
[R2]ip route-static 0.0.0.0 0.0.0.0 202.100.1.1 preference 80
[R3]ip route-static 0.0.0.0 0.0.0.0 202.100.2.1 preference 80
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]shut
[R2-GigabitEthernet0/0/0]
R2可以tracert 202.100.2.3