萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 網路應用技術 >> 應用程式教學

以太網交換機端口鏡像 (SPAN/RSPAN) 配置全攻略:從原理到多廠商命令實戰

核心概念

  • SPAN (Switched Port Analyzer):本地端口鏡像,源端口/源 VLAN 流量複製到同一設備的目的端口 (連接分析儀/IDS/IPS)。
  • RSPAN (Remote SPAN):跨設備鏡像,專用 RSPAN VLAN 在 Trunk 上傳遞鏡像流量,遠端設備再導出到分析端口。

典型應用場景

  • 協議分析 (Wireshark 抓包排查疑難雜癥)
  • 流量審計/計費/行為分析
  • 入侵檢測系統 (IDS/IPS) 旁路部署
  • 合規審計 (全流量留存)

主流廠商 CLI 配置速查

Cisco CatOS (6500/4000/2900XL 老款)

! 本地 SPAN
set span 6/1 7/1-2    ! 源 6/1 → 目的 7/1-2 (同 VLAN 限制)

! RSPAN
set vlan 900 rspan
set rspan source 4/1-2 900
set rspan destination 4/19 900

Cisco IOS (2950/3550/3560/3750/4500/6500-IOS)

! 本地 SPAN Session 1
monitor session 1 source interface Fa0/17 both   ! both/rx/tx
monitor session 1 destination interface Fa0/19

! RSPAN Session 1 (源端設備)
vlan 900
 remote-span
monitor session 1 source interface Fa0/17 both
monitor session 1 destination remote vlan 900 reflector-port Fa0/20

! RSPAN Session 2 (目的端設備)
monitor session 2 source remote vlan 900
monitor session 2 destination interface Fa0/19

Cisco 1900 (菜單/CLI 混合)

monitor-port monitored 0/17
monitor-port monitored 0/18
monitor-port port 0/19
monitor-port        ! 啟動

RSPAN 部署關鍵點 (避坑指南)

  1. 專用 RSPAN VLAN:必須創建 remote-span 類型 VLAN,不可用於正常業務。
  2. Trunk 允許 RSPAN VLAN 通過:switchport trunk allowed vlan add 900。
  3. VTP Pruning 必須處理:若 VTP 域啟用 Pruning,RSPAN VLAN 可能被修剪導致鏡像中斷。解決:vtp pruning 全域關閉,或手動 switchport trunk pruning vlan remove 900。
  4. 反射端口:IOS RSPAN 源端必須指定一個物理端口作為 reflector-port (不參與正常轉發),用於將鏡像流封裝進 RSPAN VLAN。
  5. 帶寬風險:鏡像流量 = 源端口總流量 (雙向時 2x)。千兆源鏡像可產生 2Gbps 鏡像流,必須確保 Trunk/RSPAN VLAN 路徑無阻塞,否則影響業務流量 (文中 300Mbps RSPAN 流量阻塞 Trunk 案例)。

安全警示

SPAN/RSPAN 賦予「竊聽全網流量」能力。嚴格管控配置權限,防止駭客通過佈署 SPAN 竊取敏感數據。建議:

  • AAA 授權命令審計。
  • 定期審計 show monitor session。
  • 物理安全:分析端口所在機柜加鎖。
copyright © 萬盛學電腦網 all rights reserved