二层交换机一般是接入层,并且接入层是安全性最差的,因为直接和PC机相接,PC所做的都会影响sw
Switch Attack 一般交换攻击种类 1 MAC layer 2 vlan 攻击 3 spoofing 欺骗攻击 4 交换机设备 先解释mac地址的攻击原理: MAC Flooding attack
交换攻击种类 1 MAC layer 基于源mac允许流量
| Port-security
| 基于源mac限制流量
| Static :cam
|
原理一个交换机的端口可以学习到多个mac 一个攻击者(PC)一直在改变自己的mac地址,导致交换机cam表溢出,缓存溢出,内存表爆了,导致正常的mac学习不到了。 导致从别的收到的帧(正常mac地址不在cam表内)会泛洪,导致交换机性能下降
解决方案: 基于源地址允许流量 port security 端口安全
1 为授权的mac地址 2 mac地址个数限定 //这两种可能会触发端口安全
结果(行为): 采取的措施 violation action Shutdown
| 默认端口安全采取的措施,把端口置为err-disable 发送SNMP trap
| Restrict 限制
| Drop帧 并发送SNMP Trap
| Protect 保护
| Drop帧 但是不发送SNMP Trap
|
如图实验图:
r1 接sw1 的e0/0口
在e0/0口上做端口安全
1 Switchport port-security //开启端口安全 (开关) 如果接下来不做任何 定义的话 ,SW将学不到任何地址,因为任何地址都不授权
2 switchport port-security mac-address aaaa.bbbb.cccc // 授权这个mac地址
建议做端口安全的时候先shutdown //目的是清空端口的mac 表 默认是最大地址限制的个数是1个
实验效果:
sw1(config-if)#switchport port-security mac-address aaaa.bbbb.cccc // 定义授权的mac地址
Total secure mac-addresses on interface Ethernet0/0 has reached maximum limit. // 因为之间cam表中就已经有一个端口对应的mac地址 sw1(config-if)#shu //清空mac表
sw1(config-if)#switchport port-security mac-address aaaa.bbbb.cccc
sw1(config-if)#
*Sep 2 07:07:01.823: %LINK-5-CHANGED: Interface Ethernet0/0, changed state to administratively down
*Sep 2 07:07:02.831: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down
sw1(config-if)#no shu
sw1(config-if)#end
sw1#sho ma
*Sep 2 07:07:06.135: %SYS-5-CONFIG_I: Configured from console by console
sw1#sho ma
sw1#sho mac
*Sep 2 07:07:07.267: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
*Sep 2 07:07:08.275: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
sw1#sho mac
sw1#sho a
*Sep 2 07:07:12.967: %PM-4-ERR_DISABLE: psecure-violation error detected on Et0/0, putting Et0/0 in err-disable state //默认授权mac最大个数一个,并且默认采取的安全措施是shutdown,变成err-disable
sw1#sho ar
sw1#sho ar
*Sep 2 07:07:12.967: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address aabb.cc00.0100 on port Ethernet0/0.
*Sep 2 07:07:13.971: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to down\
sw1#sho port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
---------------------------------------------------------------------------
Et0/0 1 1 1 Shutdown
---------------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
sw1#sho port-security address //查看授权的mac地址
Secure Mac Address Table
-------------------------------------------------------------------
Vlan Mac Address Type Ports Remaining Age
(mins)
---- ----------- ---- ----- -------------
1 aaaa.bbbb.cccc SecureConfigured Et0/0 -
-------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 4096
err-disble 的恢复方式: 1 shutdown -> no shutdown 2 自动恢复 errdisable recovery cause security-violation 默认恢复时间是300s 但触发的时候 又会errdisable sw1#sho errdisable recovery //查看
switchport port-security maximun 4 //修改可以接收到最大地址个数
情况二: 当sw1 的e0/0口接的是移动性的pc (mac地址一直会变) 那么静态的定义授权mac地址就 不能完成合适的要求
Sticky mac address 措施 (粘地址措施) 默认粘一个 动态学习mac地址
Switchport port-security mac-address sticky
基于源mac限制流量: 全局配置: Mac-address-table static 0010.7b80.7b9b vlan 1 drop // mac地址为0010.7b80.7b9b 且为vlan1 的会被drop掉 Show mac-address-table 3550 交换机才支持
实验; 1 把mac地址收集 摘抄下来 2 全局配置
sw1(config)#mac address-table static 0000.0000.0000 vlan 1 ?
interface interface
由于web-iou 不支持 所以 实验效果不提供 可以show mac address-table 查看做的
该贴已经同步到 cuizhiliang的微博 |