可限速的交换机一般都在三层或者以上的交换机,自2008年之后新出的交换机型号二层设备就可以 做到QOS限速,精确度达到1Mbps,例如Cisco 2960系列交换机。在这之后的大多数国内的标准二层交换机都可以做多限速,精确度基本能达到1Mbps,比如中兴的标准二层,H3C的标准二层都可以做 到。老式的CISCO标准二层交换机例如2950类的交换也可以做到限速,但是精确度只能达到10Mbps。2950G的交换和2950 为EI型 的交换没有太大的限速区别,因为限速和有关系,2950 系列的交换IOS版本一般都是在9.0 左右,最新的2960系列交换机 IOS 版本在 12.2 左右,高版本的IOS 提供了更强的系统功能。

运维设计的基本配置(运维工程师必备技能)(1)

下面针对一些限速的方法进行总结:

PC1接在Cisco3550 F0/1上,速率为1M;

PC1接在Cisco3550 F0/2上,速率为2M;

Cisco3550的G0/1为出口。

PC是直接接在三层交换机端口的,意思就是说限制的是三层交换机端口的上下行流量控制,同理,如果三层交换机端口不是接PC,而是一个二层交换机,那么可以对下层的设备进行上联限速。

注:每个接口每个方向只支持一个策略;一个策略可以用于多个接口。因此所有PC的下载速率的限制都应该定义。在同一个策略(在本例子当中为policy-map user-down),而PC不同速率的区分是在Class-map分别定义。

1、在交换机上启动QOS

Switch(config)#mls qos //在交换机上启动QOS

2、分别定义PC1(10.10.1.1)和PC2(10.10.2.1)访问控制列表

Switch(config)#access-list 10 permit 10.10.1.0 0.0.0.255 //控制pc1上行流量

Switch(config)#access-list 100 permit ip any 10.10.1.0 0.0.0.255 //控制pc1下行流量

Switch(config)#access-list 11 permit 10.10.2.0 0.0.0.255 //控制pc2上行流量

Switch(config)#access-list 111 permit any 10.10.2.0 0.0.0.255 //控制pc2下行流量

3、定义类,并和上面定义的访问控制列表绑定

Switch(config)# class-map user1-up //定义PC1上行的类,并绑定访问列表10

Switch(config-cmap)# match access-group 10

Switch(config-cmap)# exit

Switch(config)# class-map user2-up

Switch(config-cmap)# match access-group 11 //定义PC2上行的类,并绑定访问列表10

Switch(config-cmap)# exit

Switch(config)# class-map user1-down

Switch(config-cmap)# match access-group 100 //定义PC1下行的类,并绑定访问列表100

Switch(config-cmap)# exit

Switch(config)# class-map user2-down

Switch(config-cmap)# match access-group 111 //定义PC2下行的类,并绑定访问列表111

Switch(config-cmap)# exit

4、定义策略,把上面定义的类绑定到该策略

Switch(config)# policy-map user1-up //定义PC1上行的速率为1M

Switch(config-pmap)# class user1-up

Switch(config-pmap-c)# trust dscp

Switch(config-pmap-c)# police 1024000 1024000 exceed-action drop

Switch(config)# policy-map user2-up //定义PC2上行的速率为2M

Switch(config-pmap)# class user2-up

Switch(config-pmap-c)# trust dscp

Switch(config-pmap-c)# police 2048000 1024000 exceed-action drop

Switch(config)# policy-map user-down //定义PC1下行的速率为1M

Switch(config-pmap)# class user1-down

Switch(config-pmap-c)# trust dscp

Switch(config-pmap-c)# police 1024000 1024000 exceed-action drop

Switch(config-pmap-c)# exit

Switch(config-pmap)# class user2-down //定义PC2下行的速率为2M

Switch(config-pmap-c)# trust dscp

Switch(config-pmap-c)# police 2048000 1024000 exceed-action drop

Switch(config-pmap-c)# exit

5、在接口上运用策略

Switch(config)# interface f0/1 //进入PC1端口上联交换机端口配置模式

Switch(config-if)# service-policy input user1-up //绑定PC1上行策略为user1-up

Switch(config)# interface f0/2 //进入PC2端口上联交换机端口配置模式

Switch(config-if)# service-policy input user2-up //绑定PC2上行策略为user2-up

Switch(config)# interface g0/1 //进入交换机上联千兆端口配置模式

Switch(config-if)# service-policy input user-down //绑定交换机上联端口策略为 user-down

利用三层交换中的strom-control(风暴控制)功能,该功能是基于端口控制单播\多播 \组播,可以精确到0.01%,但是一个近似值 。此方法是一个门限方式,限制监控时间为每秒,超过设置的门限便丢弃包,并且用户是不知情的,以为是网络终端,或者远程无响应,显然这种方式不能确保终端 用户每时每刻的网络畅通,所以本人认为此方法只适用于某些场合,或者和其它策略配合使用。

具体配置方法:

Switch(config)# interface f0/1 //进入交换机端口配置模式

Switch(config-if)# strom-control unicast/broadcast/multi level 10 //该port带宽的10%

理解风暴控制

风暴控制防止交换机的端口被局域网中的广播、多播或者一个物理端口上的单播风暴所破坏。局域网风暴发生在包在局域网中泛洪,建立的过多的流量并丧失了网络性能。协议栈中的错误或者网络配置上的错误可以导致风暴。

风暴控制(或者叫流量压制)管理进栈的流量状态,通过一段时间和对比测量带有预先设定的压制级别 门限值的方法来管理。门限值表现为该端口总的可用带宽的百分比。交换机支持单独的风暴控制门限给广播、组播和单播。如果流量类型的门限值达到了,更多这种 类型的流量就会受到压制,直到进栈流量下降到门限值级别以下。

注意:当组播的速度超出一组门限,所有的进站流量(广播组播单播)都会被丢弃,直到级别下降到门限级别以下。只有stp的包会被转发。当广播和单播门限超出的时候,只有超出门限的流量会被封闭。

当风暴控制开启了时,交换机监视通过接口的包来交换总线和决定这个包是单播,组播还是广播。交换机监视广播组播和单播的数目,每1秒钟一次,并且当某种类型流量的门限值到达了,这种流量就会被丢弃了。这个门限以可被广播使用的总的可用带宽的百分比被指定。

以下是一个接口上的一段时间内的广播流量的模型曲线图。

这个例子也可被组播和单播流量套用。在这个例子中,广播流量在T1-T2、T4-T5时间之间被转发超过配置门限值所有的该种流量都在下一个时间被丢弃。因此广播流量在T2和T5时间内是被封闭的。在下一个时断,T3,如果广播流量没有超出限制,那么它又被转发了。

风暴控制的工作是风暴控制抑制级别和每秒钟间隔控制的结合。一个更高的门限允许更多的包通过。如果把门限值设置成100%意味着将不会限制所有任何的流量。0%意味着所有的广播组播和单播流量都会被封闭。

注意:因为包不会在统一时间间隔内到达,每秒钟间隔间如果没有流量会影响风暴控制。

交换机持续监视端口的流量,而且当利用级别降到门限以下,这种被丢弃类型的流量,又会被再次转发。

你可以使用storm-control接口命令来设定门限值给每一种类型的流量。

默认的风暴控制配置:默认地,单播组播广播的风暴控制都是在交换机上关闭的,意味着:压制级别都是100%。

开启风暴控制:你在接口开启风暴控制,并输入总可用带宽的百分比来确定你要使用给该种流量;输入100%会允许所有流量。然而,因为硬件的限制以及包大小的不同的会导致偏差,门限值百分比是一个近似值。

注意:风暴控制仅支持在物理端口下使用;它不支持以太通道下使用,尽管能敲进去。

以下例子在f0/17下把组播风暴级别限制在70.5%

Switch# configure terminal

Switch(config)# interface fastethernet0/17

Switch(config-if)# storm-control multicast level 70.5 //限制组播类型的包

Switch(config-if)# end

Switch# show storm-control fastethernet0/17 multicast

Interface Filter State Level Current

--------- ------------- ------- -------

Fa0/17 Forwarding 70.50% 0.00%

这个是关闭风暴控制

Switch# configure terminal

Switch(config)# interface fastethernet0/17

Switch(config-if)# no storm-control multicast level

Switch(config-if)# end

Switch# show storm-control fastethernet0/17 multicast

Interface Filter State Level Current

--------- ------------- ------- -------

CISCO 3550-QOS的-接口限速

Building configuration...

Current configuration : 3123 bytes

version 12.1

no service pad

service timestamps debug uptime

service timestamps log datetime localtime

no service password-encryption

hostname shangwu

enable secret 5 $1$PmhU$dlsphRGumA1simUEIA87j0

enable password

ip subnet-zero

mls qos

class-map match-all user1-up

match access-group 10

class-map match-all user1-down

match access-group 100

policy-map user1-up

class user1-up

police 800000 800000 exceed-action drop

trust dscp

spanning-tree extend system-id

interface FastEthernet0/1

no ip address

duplex full

speed 100

interface FastEthernet0/2

no ip address

duplex full

speed 100

interface FastEthernet0/3

no ip address

duplex full

speed 100

interface FastEthernet0/4

no ip address

duplex full

speed 100

interface FastEthernet0/5

no ip address

duplex full

speed 100

interface FastEthernet0/6

no ip address

duplex full

speed 100

interface FastEthernet0/7

no ip address

duplex full

speed 100

interface FastEthernet0/8

no ip address

duplex full

speed 100

interface FastEthernet0/9

no ip address

duplex full

speed 100

interface FastEthernet0/10

no ip address

duplex full

speed 100

interface FastEthernet0/11

no ip address

duplex full

speed 100

interface FastEthernet0/12

no ip address

duplex full

speed 100

interface FastEthernet0/13

no ip address

service-policy input user1-up

interface FastEthernet0/14

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/15

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/16

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/17

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/18

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/19

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/20

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/21

no ip address

duplex full

service-policy input user1-up

interface FastEthernet0/22

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/23

no ip address

duplex full

speed 100

service-policy input user1-up

interface FastEthernet0/24

description wan interface

switchport mode access

no ip address

duplex full

speed 100

interface GigabitEthernet0/1

no ip address

interface GigabitEthernet0/2

no ip address

interface Vlan1

ip address ********255.255.255.0

ip default-gateway ********

ip classless

ip http server

logging trap debugging

logging source-interface FastEthernet0/24

logging ***********

access-list 10 permit *********.0 0.0.0.255

access-list 100 permit ip any ********.0 0.0.0.255

line con 0

exec-timeout 0 0

line vty 0 4

password

login

line vty 5 15

password

login

end

交换机的主机名、进入enable模式的密码、远程登陆的用户名和密码及设置、管理vlan的 IP地址、交换机的默认网关、交换机的端口、SNMP服务、交换机时间设置等。这些和之前的2950交换机都是一样的, 2960交换机和2950相比增加了限速等功能,由于今后客户新上架除了签署了流量合同的其他都要在交换机的端口上做限速。

首先也是十分重要的一点就是,在交换机的配置没有完成前,特别是VTP模式的配置(一般情况下VTP的初始模式因配置为transparent模式)没有完成前禁止将交换机接入网络,以免使网络中的VLAN信息发生改变,因当使用console线对其进行配置。

在刚开始配置2950的时候由于还没有设置密码,处于安全方面的考虑不要将其接入网络,因使用 console口对其进行配置。交换机刚加电启动时所有的端口会进行自检,开始时每个端口上的指示灯会呈琥珀色经过一段时间后熄灭。系统的指示等默认情况 下会亮在SYST和 STAT两个灯上。

交换机启动后使用console线对其进行设置。Console线使用的是串行接口,串行口与电 脑的串行口相连(如电脑没有串行口可以使用转接器连接),RJ-45的接头和交换机的console口相连。线连好后在windows上点击 开始→程序→附件→通讯→超级终端,在跳出新建连接对话框后在名称一栏中填入想要新建的连接名称,然后确定。接着所连接的COM口,在COM1属性里波特 率选择"9600",数据位选择"8",奇偶效验选择"无",停止位选择"1",流量控制选择"无";或直接点击"还原默认值",确定进入2950配置界 面。

2950如第一次启动会出现对话配置模式选项,选择yes进入对话配置模式,选择no进入CLI命令行界面。以下配置都在CLI模式下进行。

在CLI模式下交换机显示:switch>

在此输入命令 switch> 用户模式

switch>enable 进入特权模式

switch# configure terminal 进入配置模式

switch(config)# 配置模式

设置主机名 switch(config)#hostname 主机名 一般情况下主机名的设置规则是switch后面跟交换机编号,如switch20、switch21等

设置enable密码 switch(config)#enable secret 密码 设置密码时使用secret命令,因为它比password命令有更好的安全性,密码用Password Agent软件随机生成12位包含数字和大小写字母的密码

设置远程登陆的 switch(config)# username 用户名privilege 权限 secret 密码

用户名、权限和密码 在设置权限参数时一般填0(最低权限),用户名统一为netmaster,密码用Password Agent软件随机生成12位包含数字和大小写字母的密码

对所设置的密码 switch(config)# service password-encryption 进行加密

设置管理vlan和 switch(config)# interface vlan1 进入管理vlan的配置

默认网关 switch(config-if)# ip address IP地址 子网掩码 设置管理vlan的IP,远程登陆使用此IP

switch(config-if)#no shutdown 启用管理vlan

switch(config-if)#exit 退出管理vlan的配置

switch(config)# ip default-gateway IP地址 设置默认网关

设置交换机端口 switch(config)# interface FastEthernet 0/1 进入交换机的1号端口

switch(config-if)# description uplink port 对端口进行描述,默认时交换机1号口为上连口

switch(config-if)# switchport mode trunk 将上连口设为trunk模式

switch(config-if)# speed 100 设置端口速率

switch(config-if)# duplex full 端口设为全双工模式

switch(config-if) interface range fastEthernet 0/2 -24

进入端口2至端口24的配置

switch(config-if-range)#shutdown 关闭这些端口,到使用时再打开

设置SNMP服务 switch(config)#snmp-server community 字符串LgB96G0o RO

命令允许读访问到任何提交community string为字符串的软件,字符串设置要符合长度8位以上、需包含大小写字母和数字

关闭http服务 switch(config)#no ip http server 由于开启http服务在全全上存在隐患,因关闭

设置vty switch(config)#line vty 0 4 设置telnet为0至4共5条线路

switch24(config-line)# login local 使系统在远程登录时使用本地设置的用户名和密码进行验证

设置timestamps switch(config)# service timestamps debug datetime

switch(config)# service timestamps log datetime 默认时debug/log为uptime,改为datetime

设置VTP模式 switch#vlan database 进入VTP的设置

switch (vlan)#vtp transparent 将VTP模式设置为transparent模式

设置交换机时间 switch#clock set hh:mm:ss

保存交换机的设置 switch#copy running-config startup-config

查看交换机设置 switch#show running-config 查看交换机的配置

端口流量的限制

交换机端口流量的限制是用policy-map来实现的。

switch (config)#ip access-list standard name // 建立标准的命名访问控制列表,name为ACL的名称

Switch (config-std-nacl)# permit any // 匹配任何ip

Switch (config)#class-map name //设置QoS Class Map

Switch (config-cmap)#match access-group name name // 绑定ACL列表

Switch (config)#policy-map name // 设置策略名称

Switch (config-pmap)#class name // 绑定class-map

Switch (config-pmap-c)#police 3000000 100000 exceed-action drop 定义策略正常速率为每秒3Mbit,允许超出的范围是100KByte,超出范围的数据包就drop

Switch (config)#interface range fastEthernet 0/1 – 24 // 进入1-24端口,默认交换机除了上联口外都要做限速

Switch (config-if)#service-policy input name //在端口上进的方向绑定策略

Switch (config) #mls qos //启用mls qos使策略生效

端口绑定MAC地址

进入配置模式后用以下命令绑定:

Switch(config-if )switchport port-security mac-address MAC(主机的MAC地址)

解除绑定

Switch(config-if )no switchport port-security mac-address MAC(主机的MAC地址)

二层交换机如何限速?

使用cisco 2950 交换机,每个端口都是二层接入,如何限速?

使用service-policy可以进行端口限速:

可以先定义class,然后

Switch(config)# policy-map policy1

Switch(config-pmap)# class class1

Switch(config-pmap-c)# police 1000000 65536 exceed-action drop

然后在接口下配置:

Switch(config)# interface gigabitethernet0/17

Switch(config-if)# service-policy input plcmap1

可以限速,但是不精确。。。。。。

给个6500上的限速例子:

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

permit ip any x.x.x.x 0.0.0.255

inter g0/1

service-policy input rate-limit-uplink

总结:Cisco交换机端口限速常用配置,以前端口限速的工作都是由上级部门来做,最近由于分公司自己的内部客户需求,我们要为其提供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方向才能引 用策略,所以同时对上行和下载作限速需要在上联和下载两方向的端口上做,其次,我们中间有很多弯路,说来给大家提个醒,开始我们用的测试设备性能很低,所 以始终测试不出理想的结果,很泄气,无意中拿了最好的一台电脑去测试,结果居然出人意料,后来又找了一台高性能设备进行测试,结果非常理想,在此提醒大 家,低性能的设备在测试高带宽的时候要特别注意。

华为的2层交换机,是直接进端口后,用line-rate对上下行进行限速,不过好像是要双向做

下面是偶看到的 你试试看

access-list 2 permit any

mls qos

class-map match-all input-class

match access-group 2

class-map match-all output-class

match ip dscp 0

policy-map output-policy-2M

class output-class

police 2000000 200000 exceed-action drop

policy-map input-policy-2M

class input-class

police 2000000 200000 exceed-action drop

policy-map output-policy-5M

class output-class

police 5000000 500000 exceed-action drop

policy-map input-policy-5M

class input-class

police 5000000 500000 exceed-action drop

policy-map output-policy-10M

class output-class

police 10000000 1000000 exceed-action drop

policy-map input-policy-10M

class input-class

police 10000000 1000000 exceed-action drop

policy-map output-policy-20M

class output-class

police 20000000 1000000 exceed-action drop

policy-map input-policy-20M

class input-class

police 20000000 1000000 exceed-action drop

interface FastEthernet ?/?

service-policy input input-policy-5M

service-policy output output-policy-5M

系列智能以太网交换机

Cisco Catalyst 2960系列智能以太网交换机是一个全新的、固定配置的独立设备系列,提供桌面快速以太网和千兆以太网连接,可为入门级企业、中型市场和分支机构网络提供 增强LAN服务。Catalyst2960系列具有集成安全特性,包括网络准入控制(NAC)、高级服务质量(QoS)和永续性,可为网络边缘提供智能服 务。

Cisco Catalyst 2960系列提供:为网络边缘提供了智能特性,如先进的访问控制列表 (ACL)和增强安全特性双介质上行链路端口提供了千兆以太网上行链路灵活性,可以使用铜缆或光纤上行链路端口—每个介质上行链路端口都有一个 10/100/1000以太网端口和一个小型可插拔(SFP)千兆以太网端口,在使用时其中一个端口激活,但不能同时使用这两个端口。通过高级QoS、精 确速率限制、ACL和组播服务,实现了网络控制和带宽优化。通过多种验证方法、数据加密技术和基于用户、端口和MAC地址的网络准入控制,实现了网络安全 性,通过思科网络助理,简化了网络配置、升级和故障诊断,使用Smartports自动配置特定应用

Cisco Catalyst 2960-24TT:24个10/100以太网端口和2个10/100/1000固定以太网上行链路端口;1机架单元(RU)

Cisco Catalyst 2960-48TT:48个10/100以太网端口和2个10/100/1000固定以太网上行链路端口;1 RU

Cisco Catalyst 2960-24TC:24个10/100以太网端口和2个双介质上行链路端口;1 RU

Cisco Catalyst 2960-48TC:48个10/100以太网端口和2个双介质上行链路端口;1 RU

Cisco Catalyst 2960G-24TC:20个10/100/1000以太网端口,其中4个为双介质端口;1 RU

CiscoCatalyst2960系列软件镜像提供了一系列丰富的智能服务,包括高级QoS、 速率限制和ACL。SFP千兆以太网端口可安装多种SFP收发器,包括Cisco1000BASE-SX、1000BASE-LX、1000BASE- BX、1000BASE-ZX、100BASE-FX、100BASE-LX10、100BASE-BX和粗波分多路复用 (CWDM) SFP收发器。

高级QoS:

提供了802.1p CoS和DSCP现场分类,可以利用源和目的地IP地址、源和目的地MAC地址或者第四层TCP/UDP端口号

进行基于单个分组的标记和重新分类。

所有端口上的思科控制平面和数据平面QoS ACL可以确保在单个分组的基础上进行正确的标记。每个端口的4个输出队列让用户可以对堆叠中最多四种流量类型进行不同的管理。

SRR调度确保了用户可以通过智能化地服务于输入和输出队列,为数据流量提供不同的优先级。加权队尾丢弃(WTD)可以在发生中断之前,为输入和输出队列提供拥塞避免功能。

严格优先级排序可以确保优先级最高的分组先于所有其他流量获得服务。

高度精确的QoS功能不会对性能造成任何影响。

精确的速率限制:

思科CIR功能能够以低达1Mbps的精确度保障带宽。

速率限制基于源和目的地IP地址、源和目的地MAC地址、第四层TCP/UDP信息或者这些字段的任意组合,并利用QoS 、ACL(IP ACL或者MAC ACL)、级别图和策略图提供。

利用输入策略控制和输出整形,可以方便地管理来自于基站或者上行链路的异步上行和下行数据流。 每个快速以太网或者千兆以太网端口最多可以支持64个汇总或者单独策略控制器。

,