思科交换机端口限速实战

  CISCO3550交换机作为我们单位的核心网络交换机,已经稳定运行了多年,功能上也能满足我们的需求,但是其端口限速功能却不像其它的一些交换机那样容易实现,好在最近找到了实现的办法,配置完成后,配合iperf这款测速软件进行验证,结果证明这个方法是行之有效的,下面是具体实现步骤。

  一、创建ACL

  由于这是一台三层交换机,所以虽然是对端口进行限速,但是还要考虑这个端口上通过的网络地址,本例中,我们选择对CISCO3550交换机的第22口进行限速,该端口属于VLAN66,IP地址段为10.66/16,所以首先要创建一个ACL,如下所示:

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#access-list 15 permit 10.66.0.0 0.0.255.255

  二、创建class-map

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#class-map dkxs

  3550(config-cmap)#match access-group 15

  这一步操作的主要目的就是创建了一个class-map,在这里面引用了我们事先创建好的ACL 15,方便我们以后对22端口进行操作。

  三、创建policy-map

  出于测试的需要,我们创建了多个policy-map,分别设置不同的限制带宽,如80k,1m,5m,10m,分别如下:

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#policy-map 80k

  3550(config-pmap)#class dkxs

  3550(config-pmap-c)# police 80000 8000 exceed-action drop

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#policy-map 1m

  3550(config-pmap)#class dkxs

  3550(config-pmap-c)# police 1000000 100000 exceed-action drop

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#policy-map 5m

  3550(config-pmap)#class dkxs

  3550(config-pmap-c)# police 5000000 500000 exceed-action drop

  3550#conf t

  Enter configuration commands, one per line. End with CNTL/Z.

  3550(config)#policy-map 10m

  3550(config-pmap)#class dkxs

  3550(config-pmap-c)# police 10000000 1000000 exceed-action drop

  四、查看配置信息

  3550#show run

  policy-map 5m

  class dkxs

  police 5000000 500000 exceed-action drop

  policy-map 1m

  class dkxs

  police 1000000 100000 exceed-action drop

  policy-map 80k

  class dkxs

  police 80000 8000 exceed-action drop

  policy-map 10m

  class dkxs

  police 10000000 1000000 exceed-action drop

  五、通过iperf软件进行验证

  即先在一台服务器上运行iperf的服务器端,命令如下:

  F:tools>iperf -s

  ————————————————————

  Server listening on TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  然后在交换机的22口上分别应用表示不同速率的policy-map,每应用一次,通过一台连接到22端口的笔记本电脑运行iperf的客户端,进行端口速率测试,结果分别如下:

  (交换机设置)

  3550(config-if)#service-policy input 80k

  (IPERF客户端测试结果)

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1147 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-12.5 sec 104 KBytes 68.3 Kbits/sec

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1151 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-12.0 sec 104 KBytes 70.8 Kbits/sec

  (交换机设置)

  3550(config-if)#service-policy input 1m

  (IPERF客户端测试结果)

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1155 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.5 sec 1.08 MBytes 860 Kbits/sec

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1159 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.0 sec 1.09 MBytes 910 Kbits/sec

  (交换机设置)

  3550(config-if)#service-policy input 5m

  (IPERF客户端测试结果)

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1163 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.5 sec 5.84 MBytes 4.67 Mbits/sec

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1167 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.7 sec 5.98 MBytes 4.68 Mbits/sec

  (交换机设置)

  3550(config-if)#service-policy input 10m

  (IPERF客户端测试结果)

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1171 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.1 sec 11.8 MBytes 9.83 Mbits/sec

  F:tools>iperf -c 10.66.66.8

  ————————————————————

  Client connecting to 10.66.66.8, TCP port 5001

  TCP window size: 8.00 KByte (default)

  ————————————————————

  [1912] local 10.66.123.66 port 1175 connected with 10.66.66.8 port 5001

  [ ID] Interval Transfer Bandwidth

  [1912] 0.0-10.2 sec 12.0 MBytes 9.87 Mbits/sec

  为了使测试的结果更准确,每种速率下都进行了两次测试,从测试的结果看,端口限速确实生效了。

  以前端口限速的工作都是由上级部门来做,最近由于分公司自己的内部客户需求,我们要为其提供50M的带宽.

  为此我们可是煞费苦心作了两天的测试,先来说说我们测试的设备连接情况:

  思科3560端口0/47(模拟用户)——————思科6509端口0/1、0/2(模拟局端,两条路有上联,热备)

  测试方法在3560及6509上分别起ftp进行测速

  重点来了,来说说6509上的命令吧:

  mls qos aggregate-policer test 50000000 100000 conform-action transmit exceed-action drop

  mls qos

  class-map match-any test_limite

  match access-group name test_addr

  !

  !

  policy-map rate-limit-uplink

  class test_limite

  police aggregate test

  ip access-list extended test_addr (因为上下行都引用策略一样因此不单独做acl)

  permit ip any x.x.x.x 0.0.0.3 (分配给用户的互联网地址段A)

  permit ip x.x.x.x 0.0.0.3 any

  permit ip any x.x.x.x 0.0.0.3 (分配给用户的互联网地址段B)

  permit ip x.x.x.x 0.0.0.3 any

  inter f0/1

  ip addre x.x.x.x 255.255.255.252

  service-policy input test_uplink限制上传

  inter f0/2

  ip addre x.x.x.x 255.255.255.252

  service-policy input test_uplink限制上传

  inter g0/47

  service-policy input rate-limit-uplink限制下载

  经过测试,这个方案成功了!!哈哈,庆祝庆祝,有几点需要解释一下,因为35和65只有在input方向才能引用策略,所以同时对上行和下载作限速需要在上联和下载两方向的端口上做

  其次,我们中间有很多弯路,说来给大家提个醒,开始我们用的测试设备性能很低,所以始终测试不出理想的结果,很泄气,无意中拿了班上最好的一台 电脑去测试,结果居然出人意料,后来又找了一台高性能设备进行测试,结果非常理想,在此提醒大家,低性能的设备在测试高带宽的时候要特别注意。

发表回复