违例动作决定超限怎么处理
端口安全限制一个端口能学习到的 MAC 数量,超过限制就触发违例。违例动作有三种典型处置:静默丢弃超限流量、丢弃并记录告警、直接关闭端口。名字在三家设备上各不相同,语义也有细微差别,选错了后果截然不同——选静默丢弃是悄悄丢包难以发现,选关端口则可能在接入侧一次误插交换机后把上行级联口关死,整段网络掉线。
基本信息
| 适用平台 | 华为 VRP、思科 IOS、H3C Comware 交换机 |
|---|---|
| 前提配置 | 启用端口安全并设置最大 MAC 数量或绑定表 |
| 命令族 | 华为 port-security protect-action,思科 switchport port-security violation,H3C port-security intrusion-mode |
| 权限要求 | system-view / 接口视图 |
| 默认值差异 | 思科默认 shutdown,华为默认 protect,上线前需显式核对 |
典型使用场景
- 会议室与打印区端口:限制可接入的终端数量,防止私接小交换机
- IP 电话与 PC 串联场景:允许端口学习两个 MAC,超出即触发违例
- 宿舍与访客区:结合端口隔离限制横向通信
- 接入层防环路:配合 BPDU 保护避免用户私接设备引发环路
- 排障复盘:端口无故 err-disabled 时确认是否由端口安全触发
三厂违例动作用词对照
| 处理动作 | 华为 | 思科 | H3C |
|---|---|---|---|
| 静默丢弃 | protect | violation protect | intrusion-mode blockmac |
| 丢弃并告警 | restrict | violation restrict | blockmac 配合日志上送 |
| 关闭端口 | shutdown | violation shutdown | intrusion-mode disableport |
| 临时关闭并自动恢复 | shutdown 配合恢复时间 | shutdown 配合 errdisable recovery | intrusion-mode disableport-temporarily |
华为 VRP
华为 VRP
[Huawei] interface GigabitEthernet0/0/1
[Huawei-GigabitEthernet0/0/1] port-security enable
[Huawei-GigabitEthernet0/0/1] port-security max-mac-num 2
[Huawei-GigabitEthernet0/0/1] port-security protect-action restrict # 丢弃并告警
<Huawei> display port-security interface GigabitEthernet0/0/1思科 IOS
思科 IOS
SW-CORE-01(config)# interface GigabitEthernet0/1
SW-CORE-01(config-if)# switchport mode access
SW-CORE-01(config-if)# switchport port-security
SW-CORE-01(config-if)# switchport port-security maximum 2
SW-CORE-01(config-if)# switchport port-security violation restrict
SW-CORE-01# show port-security interface GigabitEthernet0/1
! 关端口后自动恢复:errdisable recovery cause psecure-violationH3C Comware
H3C Comware
[H3C] interface GigabitEthernet1/0/1
[H3C-GigabitEthernet1/0/1] port-security max-mac-count 2
[H3C-GigabitEthernet1/0/1] port-security intrusion-mode blockmac
<H3C> display port-security interface GigabitEthernet1/0/1思科的违例动作默认是 shutdown,误关端口是现场最常见的意外;华为默认 protect,属于静默丢弃,问题会被隐藏。无论哪个厂商,上线前都要显式写清违例动作并核准一次。上行级联口、连服务器的端口不要纳入端口安全范围。