最新消息:点击查看大S的省钱秘笈

EIGRP不等价负载均衡与CEF快速转发

网络相关 Slyar 92浏览 0评论

文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。

拓扑如图,网段已经标出,左边端口1,右边端口2,全部启用EIGRP,在R1上配置了端口ACL用以检测负载均衡状况,R2、R3、R4当成透明就行了,文章最下面附有R1和R5部分配置。

首先看一下R1和R5上的路由表(部分)

R1#sh ip ro ei
D    192.168.0.0/24
[90/159232] via 1.3.0.2, 00:15:56, FastEthernet1/0
[90/158720] via 1.2.0.2, 00:15:56, FastEthernet0/0

可以看到R1去往192.168.0.0/24有2条路径,启用了不等价负载均衡。

R5#sh ip ro
1.0.0.0/24 is subnetted, 3 subnets
D       1.3.0.0 [90/31232] via 3.5.0.1, 01:41:25, FastEthernet1/0
D       1.2.0.0 [90/30720] via 2.5.0.1, 01:41:28, FastEthernet0/0
D       1.4.0.0 [90/33280] via 2.5.0.1, 01:41:25, FastEthernet0/0
C    192.168.0.0/24 is directly connected, Loopback1

R5的路由表很正常。

!
access-list 101 permit ip host 192.168.0.1 host 1.2.0.1
access-list 101 permit ip host 192.168.0.1 host 1.3.0.1
access-list 101 permit ip any any
!

在R1上配置ACL用以查看负载均衡流量。解释一下,匹配去往192.168.0.1回来的ICMP包。

OK,开始测试负载均衡。

R1#sh ip access-lists
Extended IP access list 101
10 permit ip host 192.168.0.1 host 1.2.0.1
20 permit ip host 192.168.0.1 host 1.3.0.1
30 permit ip any any

R1#ping 192.168.0.1 repeat 300
Type escape sequence to abort.
Sending 300, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (300/300), round-trip min/avg/max = 20/51/196 ms

R1#sh ip access-lists
Extended IP access list 101
10 permit ip host 192.168.0.1 host 1.2.0.1 (900 matches)
20 permit ip host 192.168.0.1 host 1.3.0.1
30 permit ip any any (87 matches)

看到了么,负载均衡没有实现,虽然路由表显示使用了负载均衡...

其原因在于CISCO路由器默认在端口上启用了CEF快速转发,使用sh ip int可以看到,它的功能英文解释比较好,我不翻译了。

CEF allows fast switch of packets based on a per-destination switching architecture. The first packet in a flow is routed,and the rest are switched.

如果你要使用不等价负载均衡,关闭CEF就可以了。

R1#conf t
R1(config)#no ip cef

再来看一下。

R1#clear ip access-list counters

R1#ping 192.168.0.1 repeat 300
Type escape sequence to abort.
Sending 300, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (300/300), round-trip min/avg/max = 28/49/156 ms

R1#sh ip access-lists
Extended IP access list 101
10 permit ip host 192.168.0.1 host 1.2.0.1 (380 matches)
20 permit ip host 192.168.0.1 host 1.3.0.1 (220 matches)
30 permit ip any any (20 matches)

这一次负载均衡就真正实现了。

另外还有需要注意一点的是,负载均衡的比例可以使用如下命令来查看。

R1#sh ip ro 192.168.0.1
Routing entry for 192.168.0.0/24
Known via "eigrp 1", distance 90, metric 158720, type internal
Redistributing via eigrp 1
Last update from 1.3.0.2 on FastEthernet1/0, 00:31:14 ago
Routing Descriptor Blocks:
* 1.3.0.2, from 1.3.0.2, 00:31:14 ago, via FastEthernet1/0
Route metric is 159232, traffic share count is 239
Total delay is 5200 microseconds, minimum bandwidth is 98039 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 2
1.2.0.2, from 1.2.0.2, 00:31:14 ago, via FastEthernet0/0
Route metric is 158720, traffic share count is 240
Total delay is 5200 microseconds, minimum bandwidth is 100000 Kbit
Reliability 255/255, minimum MTU 1500 bytes
Loading 1/255, Hops 2

即2条路径按照239:240来负载均衡,因此我们才需要使用300次的连续ping包来查看负载均衡流量。

R1部分端口及路由协议配置:

!
interface FastEthernet0/0
ip address 1.2.0.1 255.255.255.0
ip access-group 101 in
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 1.3.0.1 255.255.255.0
ip access-group 101 in
duplex auto
speed auto
!
interface FastEthernet2/0
ip address 1.4.0.1 255.255.255.0
duplex auto
speed auto
!
router eigrp 1
variance 2
network 1.2.0.0 0.0.0.255
network 1.3.0.0 0.0.0.255
network 1.4.0.0 0.0.0.255
no auto-summary
!

R5部分端口及路由协议配置:

!
interface Loopback1
ip address 192.168.0.1 255.255.255.0
!
interface FastEthernet0/0
ip address 2.5.0.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet1/0
bandwidth 98000
ip address 3.5.0.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet2/0
bandwidth 85000
ip address 4.5.0.2 255.255.255.0
duplex auto
speed auto
!
router eigrp 1
network 2.5.0.0 0.0.0.255
network 3.5.0.0 0.0.0.255
network 4.5.0.0 0.0.0.255
network 192.168.0.0
no auto-summary
!

转载请注明:Slyar Home » EIGRP不等价负载均衡与CEF快速转发

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (3)

  1. 路过~~看下~ 看不懂~
    Coach Outlet Online5年前 (2012-04-18)回复
  2. 观摩下
    sky6年前 (2011-06-13)回复
  3. 这是啥,,咋都看不懂
    Birkenstock Outlet6年前 (2011-06-08)回复