这张图为实验拓扑图,其中R1-R2-R4为静态路由
[rx]ip route-static 目标网段 子网掩码 路由器下一跳地址
静态路由的配置
r1:
[r1]ip route-static 192.168.3.0 24 8.8.8.2
[r1]ip route-static 192.168.2.0 24 8.8.8.2
[r1]ip route-static 4.4.4.0 24 8.8.8.2
[r1]ip route-static 8.8.8.0 24 8.8.8.2
r2:
[r2]ip route-static 192.168.1.0 24 8.8.8.1
[r2]ip route-static 192.168.3.0 24 4.4.4.2
r4:
[r4]ip route-static 192.168.1.0 24 4.4.4.1
[r4]ip route-static 8.8.8.0 24 4.4.4.1
负载均衡和浮动路由类似(优先级越小,优先级越大,默认值为60)
负载均衡优先级和主线优先级一致;
浮动路由优先值比主线的优先级大;
r3为浮动路由时:
[r1]ip route-static 192.168.3.0 24 6.6.6.2 preference 70
[r1]ip route-static 192.168.2.0 24 6.6.6.2 preference 70
[r1]ip route-static 4.4.4.0 24 6.6.6.2 preference 70
[r1]ip route-static 8.8.8.0 24 6.6.6.2 preference 70
[r1]ip route-static 9.9.9.0 24 6.6.6.2 preference 70
[r3]ip route-static 4.4.4.0 24 9.9.9.2 preference 70
[r3]ip route-static 192.168.2.0 24 9.9.9.2 preference 70
[r3]ip route-static 192.168.3.0 24 9.9.9.2 preference 70
[r3]ip route-static 192.168.1.0 24 6.6.6.1 preference 70
r4为负载均衡时:
[r1]ip route-static 192.168.3.0 24 6.6.6.2
[r1]ip route-static 192.168.2.0 24 6.6.6.2
[r1]ip route-static 4.4.4.0 24 6.6.6.2
[r1]ip route-static 8.8.8.0 24 6.6.6.2
[r1]ip route-static 9.9.9.0 24 6.6.6.2
[r3]ip route-static 4.4.4.0 24 9.9.9.2
[r3]ip route-static 192.168.2.0 24 9.9.9.2
[r3]ip route-static 192.168.3.0 24 9.9.9.2
[r3]ip route-static 192.168.1.0 24 6.6.6.1
r3作为黑洞路由:
[r3]ip route-static 0.0.0.0 0 NULL 0