萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 路由器知識 >> 路由器設定 >> Cisco 思科路由器

思科路由器流量控制與登錄防暴力破解配置指南

面對 P2P 下載佔用頻寬、惡意嘗試登錄等網絡安全挑戰,思科路由器提供了豐富的流量控制與 AAA 安全機制。本文系統梳理基於 ACL 的端口限速、NBAR 應用識別、CEF rate-limit 限速,以及登錄失敗嘗試記錄與防暴力破解的配置方法。

一、 基於 ACL 的端口封鎖與限速

1. 封鎖 BT 典型端口 (6881-6890)

! 禁止下載
access-list 130 deny tcp any any range 6881 6890
access-list 130 deny tcp any range 6881 6890 any
ip access-group 130 in/out

! 僅限速不封鎖
access-list 130 remark bt
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

缺陷: 現代 P2P 軟件支持動態端口、加密傳輸,單純封鎖固定端口效果極差,甚至誤傷正常業務(如 80/8080/2070 等常用端口)。

二、 NBAR 應用識別深度限速

NBAR (Network-Based Application Recognition) 能夠識別第 4-7 層協議特徵,不依賴固定端口,可精準識別 BT、eDonkey、KaZaA 等 P2P 流量,甚至識別 HTTP URL、DNS、VoIP (H.323/SIP) 等應用層協議。

部署步驟:

  1. 從 Cisco 官網下載 PDLM (Packet Description Language Module) 文件:bittorrent.pdlm, emule.pdlm 等
  2. 通過 TFTP 複製至路由器閃存
  3. 加載 PDLM:ip nbar pdlm flash:bittorrent.pdlm
  4. 創建類映射與策略映射:
    class-map match-all bittorrent
     match protocol bittorrent
    !
    policy-map bittorrent-policy
     class bittorrent
      drop
    !
    interface FastEthernet0/0
     service-policy input bittorrent-policy
     service-policy output bittorrent-policy

三、 CEF Rate-Limit 基於 IP 的介面限速

僅支持 CEF (Cisco Express Forwarding) 的設備可用。配置三步走:

! 1. 啟用 CEF
Router(config)# ip cef

! 2. 定義 ACL 匹配目標網段
Router(config)# access-list 111 permit ip 192.168.1.0 0.0.0.255 any

! 3. 接口應用 rate-limit (入方向限速 2Mbps)
Router(config)# interface FastEthernet 0/1
Router(config-if)# rate-limit input access-group 111 2000000 40000 60000 conform-action transmit exceed-action drop

參數詳解:

  • 2000000 : CIR (承諾信息速率) 2Mbps
  • 40000 : Bc (承諾突發大小) 字節
  • 60000 : Be (超額突發大小) 字節
  • conform-action transmit : 符合速率轉發
  • exceed-action drop : 超速丟棄

四、 登錄失敗記錄與防暴力破解 (AAA 機制)

自 IOS 12.3 起,結合 AAA 可記錄失敗嘗試並觸發防護:

Router(config)# aaa new-model
Router(config)# aaa authentication attempts login 5          ! 最大嘗試 5 次 (默認 3)
Router(config)# aaa authentication login local-policy local  ! 使用本地用戶庫
Router(config)# security authentication failure rate threshold-rate log
! threshold-rate: 每分鐘失敗閾值 (2-1024, 默認 10),觸發 syslog 並延遲 15 秒允許重試

關鍵約束: threshold-rate 必須 ≤ aaa authentication attempts login 設置值,否則連接會在記錄生成前被 AAA 斷開。

五、 總結建議

  • P2P 控制:優先部署 NBAR+PDLM,輔以 ACL 封鎖已知惡意端口
  • 帶寬保障:核心鏈路採用 CBWFQ/LLQ 調度,邊緣接入用 rate-limit 或 policing
  • 登錄安全:啟用 AAA、設置合理嘗試次數、配置 failure rate 觸發告警、強制使用 SSH 禁用 Telnet
copyright © 萬盛學電腦網 all rights reserved