
R1#conf t
R1(config)#inter f0/0
R1(config-if)#ip add 192.168.34.254 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#inter s0/0
R1(config-if)#ip add 192.34.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#inter s0/1
R1(config-if)#ip add 192.134.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#network 192.168.34.0 0.0.0.255 area 0
R1(config-router)#network 192.34.1.0 0.0.0.255 area 0
R1(config-router)#network 192.134.1.0 0.0.0.255 area 0
R1(config-router)#end
R2#conf t
R2(config)#inter s0/0
R2(config-if)#ip add 192.34.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#inter f0/0
R2(config-if)#ip add 192.34.2.254 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#inter f0/1
R2(config-if)#ip add 192.234.1.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#network 192.34.1.0 0.0.0.255 area 0
R2(config-router)#network 192.34.2.0 0.0.0.255 area 0
R2(config-router)#network 192.234.1.0 0.0.0.255 area 0
R2(config-router)#end
R3#conf t
R3(config)#inter s0/1
R3(config-if)#ip add 192.134.1.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#inter f0/1
R3(config-if)#ip add 192.234.1.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#inter f0/0
R3(config-if)#ip add 192.134.2.254 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#router ospf 1
R3(config-router)#network 192.134.1.0 0.0.0.255 area 0
R3(config-router)#network 192.234.1.0 0.0.0.255 area 0
R3(config-router)#network 192.134.2.0 0.0.0.255 area 0
R3(config-router)#end
PC1> ping 192.134.2.1
192.134.2.1 icmp_seq=1 timeout
84 bytes from 192.134.2.1 icmp_seq=2 ttl=62 time=93.601 ms
84 bytes from 192.134.2.1 icmp_seq=3 ttl=62 time=93.600 ms
84 bytes from 192.134.2.1 icmp_seq=4 ttl=62 time=187.201 ms
84 bytes from 192.134.2.1 icmp_seq=5 ttl=62 time=93.601 ms
PC1> trace 192.134.2.1
trace to 192.134.2.1, 8 hops max, press Ctrl+C to stop
1 192.168.34.254 46.800 ms 46.801 ms 46.800 ms
2 192.134.1.2 46.800 ms 46.800 ms 46.801 ms
3 *192.134.2.1 78.000 ms (ICMP type:3, code:3, Destination port unreachable)
R1(config)#inter s0/0
R1(config-if)#bandwidth 6000
R2(config)#inter s0/0
R2(config-if)#bandwidth 6000
PC1> trace 192.134.2.1
trace to 192.134.2.1, 8 hops max, press Ctrl+C to stop
1 192.168.34.254 46.800 ms 46.800 ms 46.800 ms
2 192.34.1.2 46.800 ms 46.800 ms 93.600 ms
3 192.234.1.2 124.800 ms 140.400 ms 187.200 ms
4 *192.134.2.1 187.200 ms (ICMP type:3, code:3, Destination port unreachable)
可以看到修改了带宽为6000以后,PC-1 trace PC-3 走的路线为 192.168.34.254 -> 192.34.1.2 -> 192.234.1.2 -> 192.134.2.1(目的地)。在未修改前走的是 192.168.34.254 -> 192.134.1.2 -> 192.134.2.1(目的地)。
为什么修改带宽?把路线调整一下,然后通过配置策略路由使效果生效。
R1(config-if)#access-list 100 permit ip any 192.34.0.0 0.0.255.255
R1(config)#route-map thrfur permit 10
R1(config-route-map)#match ip address 100
R1(config-route-map)#set ip next-hop 192.34.1.2
R1(config-route-map)#exit
R1(config)#route-map thrfur permit 20
R1(config-route-map)#set ip next-hop 192.134.1.2
R1(config-route-map)#exit
R1(config)#inter f0/0
R1(config-if)#ip policy route-map thrfur
PC1> trace 192.134.2.1
trace to 192.134.2.1, 8 hops max, press Ctrl+C to stop
1 192.168.34.254 46.799 ms 31.199 ms 31.200 ms
2 192.134.1.2 109.198 ms 124.798 ms 77.998 ms
3 *192.134.2.1 140.398 ms (ICMP type:3, code:3, Destination port unreachable)
PC1>