萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 路由器知識 >> 路由器基礎

Catalyst 3550 交換機 VLAN 配置完整指南:創建、修改、刪除、端口分配、Trunk 封裝

Cisco Catalyst 3550 作為經典二三層交換機,其 VLAN 配置命令具有代表性。本文系統梳理正常範圍/擴展範圍 VLAN 創建、修改、刪除、Access 端口分配、Trunk 封裝與允許列表配置,附帶實戰命令示例。

一、VLAN 基礎知識

  • 支持數量: 250 個活動 VLAN。
  • 編號範圍: 1-4094。
      • 1、1002-1005:系統保留 (默認 VLAN 1、FDDI/Token Ring 相關),不可刪除。
      • 2-1001:正常範圍 VLAN,配置存入 vlan.dat (NVRAM)。
      • 1006-4094:擴展範圍 VLAN,**需交換機處於 VTP Transparent 模式**才能創建,不存入 vlan.dat,不隨 VTP 宣告。
  • VTP 模式: Server/Client/Transparent。Server 可增刪改 VLAN 並宣告;Client 僅學習;Transparent 僅本地有效,不參與 VTP 同步 (配置擴展 VLAN 必須)。
  • 生成樹: 支持 PVST (Per-VLAN Spanning Tree),最多 128 棵實例。
  • Trunk 封裝: ISL (Cisco 私有) / IEEE 802.1Q (標準,現主流)。

二、正常範圍 VLAN (2-1001) 配置

方法 A:全局配置模式 (推薦,現代 IOS)

Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# exit
Switch(config)# end
Switch# write memory

no vlan 20 刪除;no name/no mtu 恢復默認。

方法 B:VLAN 數據庫模式 (舊版 IOS)

Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit
APPLY completed.

no vlan 20 刪除。

三、擴展範圍 VLAN (1006-4094) 配置

Switch# configure terminal
Switch(config)# vtp mode transparent   ! 必須先設為透明模式
Switch(config)# vlan 2000
Switch(config-vlan)# name ext-vlan
Switch(config-vlan)# exit
Switch(config)# end

⚠️ 不能在 VTP Server/Client 模式下創建擴展 VLAN。

四、刪除 VLAN 注意事項

  • VTP Server 刪除 → 整個 VTP 域同步刪除。
  • VTP Transparent 刪除 → 僅本機刪除。
  • 刪除後,原屬該 VLAN 的端口變為 **inactive (非激活)**,需重新分配 VLAN 才能恢復 Up。

五、Access 端口分配到 VLAN

Switch# configure terminal
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
  • switchport mode access 強制為接入模式 (不協商 DTP)。
  • switchport access vlan 2 指定所屬 VLAN,若 VLAN 不存在會自動創建 (正常範圍)。
  • default interface fa0/1 恢復默認 (VLAN 1, 動態望遠)。

六、Trunk 端口配置與允許 VLAN 列表

1. 啟用 Trunk 並選擇封裝

Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport trunk encapsulation dot1q   ! 或 isl
Switch(config-if)# switchport mode trunk
Switch(config-if)# end

2. 限制 Trunk 允許通過的 VLAN

默認允許所有 (1-4094)。

! 移除 VLAN 2
Switch(config-if)# switchport trunk allowed vlan remove 2

! 僅允許 10,20,30
Switch(config-if)# switchport trunk allowed vlan 10,20,30

! 添加 40
Switch(config-if)# switchport trunk allowed vlan add 40

! 恢復允許所有
Switch(config-if)# no switchport trunk allowed vlan

3. 原生 VLAN (Native VLAN) 設置

Switch(config-if)# switchport trunk native vlan 99   ! 防止 VLAN 跳躍攻擊,建議不用 1

七、驗證命令

  • show vlan brief — 顯示所有 VLAN、端口歸屬、狀態。
  • show interfaces trunk — 顯示 Trunk 端口、封裝、允許列表、原生 VLAN、活動 VLAN。
  • show interfaces fa0/1 switchport — 顯示單端口詳細開關模式、VLAN、Trunk 參數。
  • show vtp status — 確認 VTP 模式、域名、版本號。

VLAN 配置核心口訣:先定 VTP 模式 → 創建/修改 VLAN → 劃分 Access/Trunk → Access 指定單一 VLAN → Trunk 精準允許列表 + 修改 Native VLAN → 驗證雙端一致。Catalyst 3550 命令邏輯通用於主流 Cisco 交換機 (2960/3560/3750/4500/9000 等),熟練掌握受益終身。

copyright © 萬盛學電腦網 all rights reserved