Note: Each interface supports only one policy, and one policy can be used for multiple interfaces. Therefore, the download rate limit for the network segment under the port should be defined in the same policy
1. Start QoS on the switch
Switch (config) #mls QoS//Start QoS on the switch
2. Define Access Control List
Switch (config) #access-list permit 59.215.45.0 0.0.0.127
Control the upload traffic of the 59.215.45.0 network segment under this port
Switch (config) #access-list permit 59.215.45.0 0.0.0.127
Control the download traffic of the 59.215.45.0 network segment under this port
3. Define the class and bind to the Access control list defined above
Switch (config) # Class-map Rate-limit-uplink/define the upstream class. And Bind access list 10
Switch (config-cmap) # match Access-group 10
Switch (Config-cmap) # exit
Switch (config) # Class-map Rate-limit-downlink/define the Downlink class. And bind access list 100
Switch (config-cmap) # match Access-group 100
Switch (Config-cmap) # exit
4. Define the policy, bind the defined class to the policy
Switch (config) # Policy-map Rate-limit-uplink//define uplink rate of 30M
Switch (CONFIG-PMAP) # class Rate-limit-uplink
Switch (config-pmap-c) # Trust DSCP
Switch (config-pmap-c) # police 30000000 1000000 exceed-action drop//30M cannot be written 30720000
Otherwise, the following error will be reported:%error:policer rate should be multiples of 1000000.
Please choose either 3000000 or 4000000 (bits per second) as the policer rate
As for the definition of the number 100000, we'll explain it later.
Switch (config) # Policy-map Rate-limit-downlink//define the downlink rate to 30M
Switch (CONFIG-PMAP) # class Rate-limit-downlink
Switch (config-pmap-c) # Trust DSCP
Switch (config-pmap-c) # police 30000000 1000000 exceed-action drop
Switch (config-pmap-c) # exit
5. Apply on the interface
Switch (config) # interface F0/1 (the same port)
Switch (config-if) # Service-policy input Rate-limit-uplink
Interface: Users want to flow control of the port, can be Ethernet can also be serial port, but the different types of interface in the following input output on the selection of different, need to pay attention to
Input|output: This is the direction that defines the data traffic
Switch (config) # interface G0/20 (Allied port)
Switch (config-if) # Service-policy input Rate-limit-downlink
Comments:
Police bps | Burst-normal Burst-max |conform-action Action |exceed-action action
BPS: User wants the rate limit of the flow, the unit is BPS
Burst-normal Burst-max: This refers to the size of the token bucket, generally used 8000,16000,32000 these values, depending on the size of the BPS value depends.
Conform-action: The handling strategy for traffic below the rate limit.
Exceed-action: The processing strategy for traffic exceeding the rate limit.
Action: Process policies, including the following:
Transmit: Transmission
Drop: Discarding