静态路由分析可看,管理员配置的路由条目比较多,当网络环境比较大时,路由条目就非常复杂,尤其是部署在企业出口的路由器,不可能明细化配置复杂的静态路由信息,一般在边界路由器配置默认路由,也是静态路由的一种方式。
默认路由格式:
【H3C】ip route-static 0.0.0.0 0.0.0.0 下一跳IP地址 #目标网段与掩码中的“0”,表示任何值都可以,所以配置0.0.0.0能与任何目的的地址匹配成功,形成默认路由要求的效果。
注:配置默认静态路由,掩码0.0.0.0 可以简写为0。
AR2上是无法配置默认路由的,因为AR2上配置默认路由有两条(指向两个地址),当数据包到达AR2是,AR2并不清楚到底如何转发,会导致通信中断。
AR2与AR3之间两台路由配置的优先级不一样,路由器选择优先级最高(pre数值越小越优先)的路由来转发报文,当路由优先级最高主路断开后,则备用线路激活,不影响数据转发。正常情况下高优先的状态是alive(激活状态),其他处于inactive(非激活状态),当高优先级的路由断开后,处于非激活状态就会自动变为激活active,当高优先级的路由恢复后,依然处于主路,准发数据。
步骤①、配置接口地址
AR2路由配置
<AR2>sys
System View: return to User View with Ctrl+Z.
[AR2]interface GigabitEthernet 0/2
[AR2-GigabitEthernet0/2]ip address 192.168.50.2 24
[AR2-GigabitEthernet0/2]quit
[AR2]quit
<AR2>save
The current configuration will be written to the device. Are you sure? [Y/N]:Y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:Y
Validating file. Please wait...
Configuration is saved to device successfully.
<AR2>
AR3 路由器
<AR3>sys
System View: return to User View with Ctrl+Z.
[AR3]interface GigabitEthernet 0/2
[AR3-GigabitEthernet0/2]ip address 192.168.50.3 24
[AR3-GigabitEthernet0/2]quit
[AR3]quit
<AR3>save
The current configuration will be written to the device. Are you sure? [Y/N]:Y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:Y
Validating file. Please wait...
Configuration is saved to device successfully.
<AR3>
步骤②、增加静态路由
[AR2]ip route-static 30.30.30.3 32 192.168.50.3 [AR2]ip route-sattic 192.168.40.0 24 192.168.50.3
[AR3]ip route-sattic 10.10.10.1 32 192.168.50.2
[AR3]ip route-static 10.10.10.1 32 192.168.50.2
[AR3]ip route-static 192.168.10.0 24 192.168.50.2
[AR3]ip route-static 192.168.30.0 24 192.168.50.2
步骤③、查看路由表
步骤④、修改优先级
通过修改AR2与AR3之间静态路由的优先级别来区分主线路与备用线路。默认静态路由优先级是60,将主链路静态路由优先级手动修改为50。
AR2路由器
[AR2]ip route-static 30.30.30.3 32 192.168.50.3 preference 50
Route has been modified.
[AR2]ip route-static 192.168.40.0 24 192.168.50.3 preference 50
Route has been modified.
AR3路由器
[AR3]ip route-static 192.168.10.0 24 192.168.20.2 preference 50
Route has been modified.
[AR3]ip route-static 10.10.10.1 32 192.168.50.2 preference 50
Route has been modified.
[AR3]ip route-static 192.168.10.0 24 192.168.50.2 preference 50
Route has been modified.
[AR3]ip route-static 192.168.30.0 24 192.168.50.2 preference 50
Route has been modified.
[AR3]
步骤⑤、重新查看路由表
进入AR2 G0/2 接口 关闭接口 就可以看得到主线路、备用线路的切换。