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