Port Security feature 防止MAC和 MAC/CAM 攻击
1. 技术简介
利用Port Security feature防止MAC和MAC/CAM攻击,通过配置Port Security可以控制:
端口上最大可以通过的MAC地址数量
端口上学习或通过哪些MAC地址
对于超过规定数量的MAC处理进行违背处理
端口上学习或通过哪些MAC地址,可以通过静态手工定义,也可以让交换机自动学习。交换机动态学习端口MAC,直到达到指定的MAC地址数量,但交换机关机后重新学习。目前较新的技术是Sticky Port Security,交换机将学到的MAC地址写到端口配置中,交换机重启后配置仍然存在。
对于超过规定数量的MAC处理进行处理一般有三种方式(针对交换机型号会有所不同):
Shutdown,这种方式保护能力最强,但是对于一些情况可能会为管理带来麻烦,如某台设备中了病毒,病毒间断性伪造源MAC在网络中发送报文。
Protect,丢弃非法流量,不报警。
Restrict,丢弃非法流量,报警,对比上面会是交换机 CPU 利用率上升但是不影响交换机的正常使用。推荐使用这种方式。
2. 配置
2.1 port-security 配置选项:
Switch(config-if)# switchport port-security ?
aging Port-security aging commands
mac-address SecureMACaddress
maximum Max secure addresses
violation Security violation mode
2.2 配置 port-security 最大MAC数目,违背处理方式,恢复方法
Cat4507(config)#int fastEthernet 3/48
Cat4507 (config-if)#switchport port-security
Cat4507 (config-if)#switchport port-security maximum 2
Cat4507 (config-if)#switchport port-security violation shutdown
Cat4507 (config)#errdisable recovery cause psecure-violation
Cat4507 (config)#errdisable recovery interval 30
2.3 通过配置 sticky port-security学得的MAC
interface FastEthernet3/29
switchport mode access
switchport port-security
switchport port-security maximum 5
switchport port-security mac-address sticky
switchport port-security mac-address sticky 000b.db1d.6ccd
switchport port-security mac-address sticky 000b.db1d.6cce
switchport port-security mac-address sticky 000d.6078.2d95
switchport port-security mac-address sticky 000e.848e.ea01