端口安全功能的详细配置方式
端口安全功能通过限制端口接入设备的MAC地址数量和类型,防止未经授权设备的访问。以下是主流厂商的详细配置方式及核心知识点:
启用端口安全功能
[设备] port-security enable # 全局或接口下开启[1]()[5]()
配置最大安全MAC地址数
interface GigabitEthernet0/0/1 port-security max-mac-num 2 # 限制端口允许的MAC地址数量[1]()[7]()
选择端口安全模式
port-security mac-address 00-11-22-33-44-55 vlan 10 # 绑定指定MAC和VLAN[3]()[6]()
port-security mac-address sticky # 启用Sticky MAC功能[5]()[10]()
配置违例处理方式
port-security violation { protect | restrict | shutdown } # protect:仅丢弃非法流量;restrict:丢弃并告警;shutdown:关闭端口[8]()[11]()
port-security port-mode autoLearn
port-security timer disable-port 30 # 违例后30秒恢复[1]()
switchport mode access switchport port-security # 启用端口安全[2]()[9]()
switchport port-security mac-address 0060.5C5B.3152 ip-address 192.168.2.2[2]()
port default vlan 10 # 接口绑定VLAN[5]()
display port-security
安全MAC地址类型
老化时间设置
port-security timer autolearn aging 1440 # 安全MAC地址24小时后老化[1]()
恢复关闭端口
errdisable recovery cause psecure-violation
timer disable-port
功能 | 命令示例 | 作用 |
---|---|---|
查看端口安全状态 |
show port-security |
显示端口安全状态及违例计数25 |
查看绑定MAC地址 |
show port-security address |
列出所有安全MAC地址68 |
检查端口状态 |
display interface brief |
确认端口是否因违例被关闭5 |
通过以上配置,可有效控制网络接入设备,防范ARP欺骗、MAC泛洪等攻击。实际部署时需根据网络拓扑选择模式,并定期审查安全MAC地址表。