设为首页收藏本站language 语言切换
查看: 6542|回复: 4
收起左侧

[原创] 交换机端口安全port-security 之MAC 攻击

[复制链接]
发表于 2013-9-2 16:16:55 | 显示全部楼层 |阅读模式


二层交换机一般是接入层,并且接入层是安全性最差的,因为直接和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的微博
 楼主| 发表于 2013-9-2 16:25:55 | 显示全部楼层
图忘了  r1e0/0-------e0/0sw1e0/1----r2e0/1
沙发 2013-9-2 16:25:55 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-9-2 16:35:19 | 显示全部楼层
板凳 2013-9-2 16:35:19 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-9-2 17:05:39 | 显示全部楼层
地板 2013-9-2 17:05:39 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2016-3-18 09:07:50 | 显示全部楼层
谢谢共享资料
5# 2016-3-18 09:07:50 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-5-17 20:37 , Processed in 0.082292 second(s), 24 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表