首页/网络/网络设备配置速查/H3C 端口安全:port-mode 与入侵模式
ACL 与安全65 条

H3C 端口安全:port-mode 与入侵模式

H3C 端口安全必须先选 port-mode(autolearn/secure/userlogin 等)再限制 MAC 数量,非法接入的处理动作由 intrusion-mode 决定。

网络设备配置速查网络更新于 2026-10-13

H3C 端口安全是什么

H3C 端口安全的特点是「先选模式、再限数量、最后定动作」:用 port-security port-mode 决定准入方式(autolearn 自动学习、secure 手工绑定、userlogin 配合 802.1X),用 max-mac-count 限制允许学习的 MAC 数量,违规处理动作由 intrusion-mode 决定。只开启 enable 而不设置模式时,端口实际上处于不受限制的状态。

基本信息

适用设备H3C Comware V7/V5(对照华为 VRP、思科 IOS)
模式autolearn 自动学习、secure 手工绑定、userlogin 配合 802.1X
数量限制port-security max-mac-count N
违规动作port-security intrusion-mode,如 disableport-temporarily
恢复定时port-security timer disableport N(秒)
对照命令华为 protect-action;思科 switchport port-security violation

典型使用场景

  • 办公接入口防止私接小交换机或路由器
  • 限制单口下的终端数量,一个工位口只允许一台设备
  • 会议室、打印区等固定终端场景做 MAC 绑定
  • 违规后临时关闭端口并自动恢复,减少现场跑腿
  • 满足等保要求:非法接入可阻断、有动作记录与恢复机制

H3C Comware

H3C Comware
interface GigabitEthernet1/0/1
 port-security enable
 port-security port-mode autolearn          # 必须先选模式
 port-security max-mac-count 3
 port-security intrusion-mode disableport-temporarily
 port-security timer disableport 30         # 30 秒后自动恢复
display port-security interface GigabitEthernet1/0/1

华为 VRP

华为 VRP
interface GigabitEthernet0/0/1
 port-security enable
 port-security max-mac-num 3
 port-security protect-action shutdown      # 或 restrict 只告警不关端口
display port-security interface GigabitEthernet0/0/1

思科 IOS

思科 IOS
interface GigabitEthernet0/1
 switchport port-security
 switchport port-security maximum 3
 switchport port-security violation shutdown
switchport port-security aging time 30
show port-security interface GigabitEthernet0/1

三厂端口安全对照

操作H3C Comware华为 VRP思科 IOS
开启port-security enableport-security enableswitchport port-security
准入模式port-security port-mode autolearn 或 secure 或 userlogin无等价模式概念,靠 max-mac-num 限制开关即生效,配合 sticky 做固化
数量上限port-security max-mac-count 3port-security max-mac-num 3switchport port-security maximum 3
违规动作port-security intrusion-mode disableport-temporarilyport-security protect-action shutdown 或 restrictswitchport port-security violation shutdown 或 restrict
恢复机制port-security timer disableport 30接口 error-down 恢复机制(视版本)errdisable recovery
H3C 只执行 port-security enable 而不设置 port-mode 时,端口仍处于不限制状态:配置记录里看着「已经开了端口安全」,实际没有任何约束。配完必须用 display 核对三项生效值——模式、上限、违规动作。
「关端口 + 定时恢复」的组合价值在于把一次违规变成短时中断:既阻断了非法接入,又不需要每次都派人到现场开端口,适合无人值守的接入区域。

易错点

  • H3C 只 enable 不设 port-mode:端口处于无限制状态,看起来配了其实没有任何约束,唯一可靠的确认方式是 display 生效值
  • 数量上限设得过小(如 1):正常换网卡、IP 电话与 AP 上电时的多 MAC 行为都会触发违规,端口被关造成报障
  • 违规动作选了 shutdown 却没有自动恢复机制:一次误触发就要等现场处理,中断时长超出预期
  • 用手工 secure 模式绑定 MAC 后没做变更流程:终端换网卡或交换机更换后合法终端被拒,原因定位困难
  • 上线只测「能上网」不测违规场景:没有触发一次违规验证动作是否按设计执行,等于没验收

数据来源与参考

  • H3C Comware 端口安全(port-mode、intrusion-mode)
  • 华为 VRP port-security 命令参考
  • Cisco IOS port-security violation 说明

相关工具

​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌