华为交换机在所有端口配置

发布时间:2024-05-03 18:28:12

一、端口配置命令语法
interface
[命令1]
[命令2]
...
二、常用端口配置命令
1. 链路配置
speed : 设置端口速率
duplex : 设置端口双工模式
autonegotiation [on/off]: 启用/禁用自动协商
2. VLAN 配置
port link-type trunk: 将端口配置为 trunk 口
port link-type access: 将端口配置为 access 口
port default vlan : 设置端口缺省 VLAN
port trunk allow-pass vlan : 允许端口 trunk 口通过指定 VLAN
3. STP 配置
spanning-tree portfast: 启用快速生成树协议
spanning-tree bpduguard: 启用 BPDU 保护功能
4. ACL 配置
acl number : 创建 ACL
rule permit/deny source [mask ] destination [mask ] service [port-range]: 创建 ACL 规则
5. QoS 配置
qos trust: 启用信任队列
qos priority [0-7]: 设置端口优先级
qos traffic-class [0-7]: 设置端口流量类
6. 其他配置
description : 设置端口描述
shutdown: 关闭端口
no : 删除已配置的命令
三、配置示例
示例 1:配置 GigabitEthernet 0/0 为 trunk 口,并允许通过 VLAN 10 和 VLAN 20
interface gigabitethernet 0/0
port link-type trunk
port trunk allow-pass vlan 10 20
示例 2:配置 GigabitEthernet 0/1 为 access 口,缺省 VLAN 为 VLAN 100
interface gigabitethernet 0/1
port link-type access
port default vlan 100
示例 3:配置 GigabitEthernet 0/2 为快速生成树协议端口
interface gigabitethernet 0/2
spanning-tree portfast