hostname SW-CORE-01
enable secret cisco123 // 加密特權密碼 (最高優先)
enable password cisco // 明文密碼 (舊版相容)
no ip domain-lookup // 關閉域名解析防輸入錯誤卡頓
line vty 0 15
password class
login
transport input ssh // 僅允許 SSH
line console 0
logging synchronous // 防日志打斷輸入
exec-timeout 10 0
service password-encryption // 全域加密明文密碼
interface vlan 10
ip address 192.168.10.2 255.255.255.0
no shutdown
ip default-gateway 192.168.10.254
ip name-server 8.8.8.8 114.114.114.114
ip domain-name corp.local
注意: SVI (VLAN 介面) IP 僅供管理,不影響數據平面轉發。若為三層交換機,建議用 Loopback 做管理環回口。
interface range GigabitEthernet1/0/1 - 24
description ACCESS_USER_PORT
speed 1000
duplex full
spanning-tree portfast // 端口直進 Forwarding,跳過 Listening/Learning
spanning-tree bpduguard enable // 收到 BPDU 自動 Err-disable,防私接交換機
switchport mode access
switchport access vlan 10
switchport nonegotiate // 強制 Access,不發 DTP
authentication port-control auto // 802.1X/MAB 準入 (可選)
no shutdown
interface TenGigabitEthernet1/1/1
description UPLINK_TO_CORE
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan 10,20,30,100 // 僅允許必要 VLAN,減少廣播洪泛
switchport trunk native vlan 999 // 原生 VLAN 改非預設,防 VLAN Hopping
channel-group 1 mode active // LACP 聚合
spanning-tree link-type point-to-point
| 目的 | 指令 |
|---|---|
| 查看介面狀態/速率/錯誤計數 | `show interfaces status` / `show interfaces gi1/0/1 counters errors` |
| 查看 VLAN 簡介/端口隸屬 | `show vlan brief` / `show interfaces trunk` |
| 查看生成樹狀態/根橋 | `show spanning-tree` / `show spanning-tree root` |
| 查看鄰居/拓撲 | `show cdp neighbors detail` / `show lldp neighbors` |
| 即時抓封包 (嵌入式 Wireshark) | `monitor capture CAP1 interface gi1/0/1 both` → `monitor capture CAP1 start` → `show monitor capture CAP1 buffer brief` |