面對 BT、電驢、Kazaa 等 P2P 流量頻繁變換埠口,單純封鎖固定埠已失效。Cisco 提供兩大進階手段:NBAR (Network-Based Application Recognition) + PDLM 進行深度封包檢測識別協議,以及傳統 ACL + Rate-Limit (CAR) 進行埠基礎限速。本文詳細實作兩種方法配置細節。
bittorrent.pdlm、kazaa2.pdlm、emule.pdlm),可從 Cisco 官網下載。! 1. 將 PDLM 檔案上傳至路由器閃存 (via TFTP)
copy tftp flash:
Source file: bittorrent.pdlm
Destination: flash:bittorrent.pdlm
! 2. 載入 PDLM 啟用 NBAR 識別
ip nbar pdlm flash:bittorrent.pdlm
! 3. 定義 Class-map 匹配協議
class-map match-all BITTORRENT
match protocol bittorrent
! 4. 定義 Policy-map 動作 (丟棄/限速)
policy-map BLOCK-BT
class BITTORRENT
drop
! 或 police 1000000 8000 8000 conform-action transmit exceed-action drop
! 5. 套用至 WAN 介面 (雙向)
interface FastEthernet0/0
description Internal_LAN
ip address 192.168.0.1 255.255.255.0
ip nat inside
service-policy input BLOCK-BT
service-policy output BLOCK-BT
access-list 130 deny tcp any any range 6881 6890
access-list 130 deny tcp any range 6881 6890 any
interface
ip access-group 130 in
ip access-group 130 out
access-list 130 remark BT-THROTTLE
access-list 130 permit tcp any any range 6881 6890
access-list 130 permit tcp any range 6881 6890 any
rate-limit input access-group 130 712000 8000 8000 conform-action transmit exceed-action drop
rate-limit output access-group 130 712000 8000 8000 conform-action transmit exceed-action drop
rate-limit input/output access-group ACL bps burst-normal burst-max conform-action transmit exceed-action dropbps:承諾資訊率 (CIR),單位 bps (712k = 712,000)。burst-normal / burst-max:正常/最大突發位元組數 (通常設 8000~16000)。drop 直接丟棄,或 set-prec-transmit 1 重標記 DSCP 進入低優先佇列。show policy-map interface、show rate-limit 計數器,調整閾值。