启用策略路由:
要求:
访问新浪网络1.1.1.1时,电信用户5.5.5.5走电信线,网通用户55.55.55.55走网通线。
电信线路坏掉时自动切换到网通线路,网通线路坏掉时自动切换到电信线路,做一个冗余备份。
只能在网吧的R3路由器上操作。
基本IP规划(略)
全在192.168.0.0内
启用RIP路由协议(略)
R3
r3#show ip route
Gateway of last resort is not set
R 192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:16, Serial0/2
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/2] via 192.168.34.4, 00:00:11, Serial0/1
[120/2] via 192.168.23.2, 00:00:16, Serial0/2
R 192.168.14.0/24 [120/1] via 192.168.34.4, 00:00:11, Serial0/1
55.0.0.0/24 is subnetted, 1 subnets
R 55.55.55.0 [120/1] via 192.168.35.5, 00:00:14, Serial0/3
5.0.0.0/24 is subnetted, 1 subnets
R 5.5.5.0 [120/1] via 192.168.35.5, 00:00:14, Serial0/3
C 192.168.23.0/24 is directly connected, Serial0/2
C 192.168.34.0/24 is directly connected, Serial0/1
C 192.168.35.0/24 is directly connected, Serial0/3
可见去往1.1.1.1的是负载均衡
启用Route map
R3
r3(config)#access-list 5 permit 5.5.5.0 0.0.0.255
r3(config)#access-list 55 permit 55.55.55.0 0.0.0.255
r3(config)#route-map ABC permit 10 策略1
r3(config-route-map)#match ip address 5
r3(config-route-map)#set ip next-hop 192.168.23.2 定制下一条为R2
r3(config)#route-map ABC permit 20 策略2
r3(config-route-map)#match ip address 55
r3(config-route-map)#set ip next-hop 192.168.34.4 定制下一条为R4
r3(config)#route-map ABC permit 30 空map,留作放行动作
r3(config-route-map)#end
r3(config)#int s0/3 接口下调用route-map
r3(config-if)#ip policy route-map ABC
r3(config-if)#end
R5
r5#traceroute 1.1.1.1 sou 5.5.5.5
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 192.168.35.3 80 msec 92 msec 92 msec
2 192.168.23.2 36 msec 144 msec 136 msec
3 192.168.12.1 56 msec 184 msec *
r5#tr
r5#traceroute 1.1.1.1 sou 55.55.55.55
Type escape sequence to abort.
Tracing the route to 1.1.1.1
1 192.168.35.3 72 msec 92 msec 56 msec
2 192.168.34.4 20 msec 120 msec 100 msec
3 192.168.14.1 20 msec 144 msec *
可见5.5.5.5去往1.1.1.1走R2,55.55.55.55去往1.1.1.1走R4
断开R3的S0/2接口(模拟电信线路坏掉)
R3
r3(config)#int s0/2
r3(config-if)#shut
r3(config-if)#end
R5
r5#ping 1.1.1.1 sou 5.5.5.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
可见会自动做冗余备份线路。