做完动态路由协议负载均衡后总想测试下负载均衡效果,但是开启debug ip icmp后,简单ping 地址后发现没有实现负载均衡,可是路由表里面显示有两个下一跳路由,说明负载均衡是成功的。什么原因导致的呢?
show ip route
R 8.0.0.0/8 [120/1] via 192.168.99.1, 00:00:01, FastEthernet1/0
[120/1] via 192.168.9.1, 00:00:10, FastEthernet0/0
R 9.0.0.0/8 [120/1] via 192.168.99.1, 00:00:01, FastEthernet1/0
[120/1] via 192.168.9.1, 00:00:10, FastEthernet0/0
1.默认情况下系统是ip cef
此时数据包转发是基于目标地址的转发,只有在ping不同的ip地址时才会进行负载均衡,那ping单一的ip地址肯定不会有负载均衡的效果
例如:
Router(config)#do ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/55/104 ms
Router(config)#
*Mar 1 00:16:56.451: ICMP: echo reply rcvd, src 8.8.8.8, dst 192.168.9.2
*Mar 1 00:16:56.527: ICMP: echo reply rcvd, src 8.8.8.8, dst 192.168.9.2
*Mar 1 00:16:56.559: ICMP: echo reply rcvd, src 8.8.8.8, dst 192.168.9.2
*Mar 1 00:16:56.591: ICMP: echo reply rcvd, src 8.8.8.8, dst 192.168.9.2
*Mar 1 00:16:56.623: ICMP: echo reply rcvd, src 8.8.8.8, dst 192.168.9.2
ping 8.8.8.8 走的是192.168.9.2
Router(config)#do ping 9.9.9.9
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 9.9.9.9, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/61/108 ms
Router(config)#
*Mar 1 00:17:06.699: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:17:06.807: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:17:06.839: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:17:06.887: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:17:06.943: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
而ping 9.9.9. 走的是192.168.99.2
说明实现了负载均衡
2.若配置了Router(config)#no ip cef
则是基于数据包的转发,即使ping同一个ip地址也能看到负载均衡的效果
例如:
Router(config)#do ping 9.9.9.9
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 9.9.9.9, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/51/84 ms
Router(config)#
*Mar 1 00:22:00.503: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:22:00.567: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.9.2
*Mar 1 00:22:00.583: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
*Mar 1 00:22:00.659: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.9.2
*Mar 1 00:22:00.675: ICMP: echo reply rcvd, src 9.9.9.9, dst 192.168.99.2
ping 9.9.9.9,第一个数据包先走192.168.99.2 ,第二个走192.168.9.2,第三个再走192.168.99.2……依次循环实现负载均衡
但是要注意的是基于数据包的转发模式会大量消耗服务器资源,一般不采用此方法,而使用路由器默认的基于目的地址的转发
————————————————————————————————————————————————
以上内容是rip等价负载均衡下的结果,若是eigrp下非等价负载均衡,结果又有些不同
以下内容没有上传配套图
show ip route
D 1.1.1.0 [90/3705856] via 172.16.123.2, 00:54:56, Serial0/0
[90/3196416] via 172.16.23.2, 00:54:56, FastEthernet1/0
这是两条非等价的路由
查看去往1.1.1.1 的路由
r3#show ip route 1.1.1.1
Routing entry for 1.1.1.0/24
Known via "eigrp 1", distance 90, metric 3196416, type internal
Redistributing via eigrp 1
Last update from 172.16.23.2 on FastEthernet1/0, 00:55:56 ago
Routing Descriptor Blocks:
172.16.123.2, from 172.16.123.2, 00:55:56 ago, via Serial0/0
Route metric is 3705856, traffic share count is 69
Total delay is 80000 microseconds, minimum bandwidth is 1544 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 3
* 172.16.23.2, from 172.16.23.2, 00:55:56 ago, via FastEthernet1/0
Route metric is 3196416, traffic share count is 80
Total delay is 60100 microseconds, minimum bandwidth is 1544 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 3
在no ip cef情况下ping 1.1.1.1 走172.16.123.2的数据包数量是69个,而走172.168.23的数据包数量是80个。“*”代表首先走这条路由
在之前没有数据传输的情况下,ping 1.1.1.1 repeat 81会发现前80个debug ip icmp 包都是走的172.16.23.2,而第81个数据包走的是172.16.123.2,说明负载均衡实现了。
至于默认的ip cef情况下没能看到负载均衡的效果,但是负载均衡应该是成功的。