交换机常用命令
查看当前运行配置
display current-configuration
#简写
dis cur
基础查看命令
# 查看单个端口详细信息(最常用)
display interface GigabitEthernet 0/0/1
# 查看端口简要状态
display interface brief
# 查看端口描述信息
display interface description
# 查看光模块信息(光纤口)
display transceiver interface GigabitEthernet 0/0/1
display transceiver diagnosis interface GigabitEthernet 0/0/1
#查看接口IP简要信息
display ip interface brief
dis ip int br
#查看全局路由表
display ip routing-table
#查看某条路由详细信息
display ip routing-table x.x.x.x verbose
进入视图
system-view
查询vlan
display port vlan GigabitEthernet 0/0/45
display port vlan GigabitEthernet 1/0/45
全局含 45 口 VLAN
display port vlan | include 45
进入45口
interface GigabitEthernet 0/0/45
interface GigabitEthernet 1/0/45
设定Access 口
#设定Access 口
port link-type access
#划定指定vlan
port default vlan 216
设定Trunk 口
#设定Trunk 口
port link-type trunk
# 允许单个VLAN
port trunk allow-pass vlan 216
# 允许多个连续VLAN
port trunk allow-pass vlan 10 to 20
# 允许所有VLAN
port trunk allow-pass vlan all
修改 Trunk 缺省 VLAN(PVID)
#PVID 是 Trunk 口处理无标签数据的默认 VLAN
#默认情况下,交换机所有 Trunk 口 PVID=VLAN 1,修改就是把默认 1 改成其他 VLAN(如 VLAN10、VLAN20)
port trunk pvid vlan 10
设定Hybrid 口
port link-type hybrid
# 带标签转发
port hybrid tagged vlan 10 20
# 不带标签转发
port hybrid untagged vlan 30
保存配置
save
快速示例
#45 口改成 Access、归 VLAN 20:
sys
int g0/0/45
port link-type access
port default vlan 20
#45 口改成 Trunk、放行 VLAN 10 30:
sys
int g0/0/45
port link-type trunk
port trunk allow-pass vlan 10 30
LACP 静态聚合
# 进入系统视图
system-view
# 创建聚合组1,启用LACP静态模式
interface Eth-Trunk 1
mode lacp-static # 开启LACP协商,两端必须一致
trunkport GigabitEthernet 0/0/1 to 0/0/2 # 批量加入1、2口
port link-type trunk # 互联链路设为trunk
port trunk allow-pass vlan all # 放行所有VLAN(堆叠互联必配)
max active-linknumber 2 # 2条链路同时转发
lacp preempt enable # 开启端口抢占,故障恢复自动切回
lacp preempt delay 10 # 抢占等待10秒防震荡
quit
默认手工聚合
system-view
# 创建聚合组2,默认手工模式,无需配置lacp
interface Eth-Trunk 2
trunkport GigabitEthernet 0/0/3 to 0/0/4
port link-type trunk
port trunk allow-pass vlan all
# mode manual load-balance # 默认模式,可省略,写出来便于维护
quit
链路接口查看
display eth-trunk 1 # 查看LACP聚合组1状态
display eth-trunk 2 # 查看手工聚合组2状态
display eth-trunk brief # 所有聚合组概览
查询接口位置
根据mac查询
dis mac-address F0D4-E2EB-0E0C
dis mac-address F0D4-E2EB-0E0D
#f0d4-e2eb-0e0d 3021/-/- Eth-Trunk26 dynamic
dis mac-address F0D4-E2EB-0E0E
#f0d4-e2eb-0e0e 1/-/- GE0/0/12 dynamic
dis mac-address F0D4-E2EB-0E0F
#f0d4-e2eb-0e0f 217/-/- GE1/0/12 dynamic
查 Eth‑Trunk 链路聚合逻辑口
dis eth-trunk
dis eth-trunk 26
#看流量统计,判断流量实际跑在 Eth‑Trunk 哪一个物理口
dis eth-trunk 26 verbose
查 Eth‑Trunk 链路聚合MAC
dis mac-address Eth-Trunk 26
#详细包括看到vlan
dis mac-address Eth-Trunk 26 verbose
通过IP查MAC
dis arp | include 10.201.6.3
创建链路聚合
| 命令 | 说明 |
|---|---|
| interface Eth-Trunk 1 | 创建聚合组 |
| trunkport GigabitEthernet 0/0/1 to 0/0/2 | 将端口加入聚合组 |
| port link-type trunk | 设置聚合组模式 |
| display eth-trunk 1 | 查看聚合状态 |
| undo eth‑trunk 1 | 删除聚合 |
示例:
system-view
# 1、创建聚合组Eth‑Trunk 23
interface Eth‑Trunk 23
mode lacp-static # LACP模式;静态聚合写 mode manual load-balance
port link-type trunk # 设置为Trunk口
port trunk allow-pass vlan all # 放行所有vlan;生产建议写具体vlan,例如 port trunk allow-pass vlan 10 20
quit
# 2、把G0/0/12加入Eth‑Trunk23
interface GigabitEthernet 0/0/12
eth‑trunk 23
quit
# 3、把G1/0/12加入Eth‑Trunk23
interface GigabitEthernet 1/0/12
eth‑trunk 23
quit
接口原配置清除
#直接恢复接口出厂默认(推荐)
interface GigabitEthernet 0/0/12
clear configuration this
#手动逐条删除旧配置
interface GigabitEthernet 0/0/12
display this
undo port link-type
undo port trunk allow-pass vlan all
undo port trunk allow-pass vlan xxx
undo port default vlan xxx
undo shutdown
退出链路聚合
sys
interface GigabitEthernet 1/0/12
undo eth‑trunk 23
quit