Catalyst 2960 系列作為經典接入層交換機,通過 MQC (Modular QoS CLI) 實現精細的流量限速。本文提供針對單 IP、多 IP、全端口的上/下行限速完整配置腳本,並解析 police 參數含義與應用方向陷阱。
class-map match-all <name> ! 分類:匹配流量特徵 (ACL/協議/CoS/DSCP)
policy-map <name> ! 策略:定義動作 (police/shape/bandwidth)
service-policy {input|output} <name> ! 應用:綁定到接口方向
! 1. ACL 匹配目標流量 (目標 IP 10.10.10.100)
access-list 101 permit ip any host 10.10.10.100
! 2. 類映射
class-map match-all down1
match access-group 101
! 3. 策略映射 (police 單速率雙桶)
policy-map down
class down1
police 5000000 1000000 exceed-action drop
! CIR=5Mbps, Bc=1MB, 超速丟棄
! 4. 應用到上聯口 入方向
interface GigabitEthernet0/2
service-policy input down
access-list 101 permit ip any host 10.10.10.100
access-list 102 permit ip any host 10.10.10.101
class-map match-all down1
match access-group 101
class-map match-all down2
match access-group 102
policy-map down
class down1
police 5000000 1000000 exceed-action drop
class down2
police 5000000 1000000 exceed-action drop
interface GigabitEthernet0/2
service-policy input down

access-list 101 permit ip host 10.10.10.100 any
class-map match-all output-class
match access-group 101
policy-map 5m-up
class output-class
police 5000000 1000000 exceed-action drop
interface FastEthernet0/1
service-policy input 5m-up ! 注意:下聯口限上傳用 input
policy-map 5m-port
class class-default
police 5000000 1000000 exceed-action drop
interface FastEthernet0/1
service-policy input 5m-port
| 參數 | 含義 | 單位 | 建議值 |
|---|---|---|---|
cir (第一個數值) | 承諾信息速率 | bps | 業務帶寬 (如 5000000 = 5Mbps) |
bc (第二個數值) | 承諾突發字節數 | bytes | CIR/8 ~ CIR/4 (如 1MB) |
be (可選第三個) | 超額突發字節數 | bytes | 通常等於 Bc 或 0 |
conform-action | 符合速率動作 | - | transmit (轉發) / set-dscp-transmit |
exceed-action | 超出速率動作 | - | drop (丟棄) / set-dscp-transmit (降級) |
violate-action | 雙桶超出 Be 動作 | - | drop (雙速率三色時) |
input / 下聯口 outputoutput / 下聯口 inputservice-policy input 處理「進入接口」的報文show policy-map interface g0/2
show class-map
show access-lists 101
show mls qos interface g0/2 statistics
2960 系列不支持 shape (整形),僅支持 police (監管/拋棄)。如需緩衝排隊整形,需上 3560/3750/3850/9000 系列支持 MQC 全功能的平台。