一、MAC地址攻击
概念:
攻击者不断修改自己的MAC地址,交换机进行大量学 习,导致交换机mac地址表缓存溢出,不能再学习其他的Mac地址信息, 此时交换机将工作在hub状态
解决方案:
1.静态MAC地址写入
静态MAC地址写书:
sw1(config)#mac address-table static 000a.000b.000c vlan 1 interface ethernet 2/0
查看:
sw1#sho mac address-table static
结果:
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 000a.000b.000c STATIC Et2/0
Total Mac Addresses for this criterion: 1
2.基于MAC地址过滤
sw1(config)#mac address-table static 00a.00b.00c vlan 1 drop
3.端口安全
设置接口接收的MAC地址数量以及接收授权Mac地址
默认启用了端口安全之后,接收MAC地址数据只有1个,授权学习到的第一个MAC地址.
- 开启端口安全
sw1(config-if)#switchport port-security
- 设置支持的MAC地址数量(默认为1)
sw1(config-if)#switchport port-security maximum 1
- 指定授权的合法的MAC地址
sw1(config-if)#switchport port-security mac-address ?
H.H.H 48 bit mac address
sticky Configure dynamic secure addresses as sticky
sticky表示粘滞,把接口学习到的第一个mac地址粘滞成一条命令
结果
sw1#sho run int e2/0
Building configuration...
Current configuration : 197 bytes
!
interface Ethernet0/0
switchport mode access
switchport port-security
switchport port-security mac-address sticky
switchport port-security mac-address sticky 0203.e900.0200
duplex auto
end
- 选择触发端口安全惩罚方式
若触发了端口安全: 1.shutdown(默认) 2.protect(保护) 3.restrict(限制)
sw1(config-if)#switchport port-security violation ?
protect Security violation protect mode
restrict Security violation restrict mode
shutdown Security violation shutdown mode
默认:由于触发了端口安全,导致接口error-disable (shutdown),不能自动恢复,保护和限制都会丢弃未授权mac地址的数据帧
- 查看接口授权MAC地址
sw1#sho port-security address
Secure Mac Address Table
-------------------------------------------------------------------
Vlan Mac Address Type Ports Remaining Age
(mins)
---- ----------- ---- ----- -------------
1 0203.e900.0500 SecureSticky Et2/0 -
-------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 4096
默认模式由于触发了端口安全,导致接口error-disable (shutdown),不能自动恢复,则有两种启用方式:
1.shutdown接口,然后no shutdown
2.开启err-disable针对端口安全导致的自动恢复
sw1(config)#errdisable recovery cause psecure-violation
设置恢复间隔(默认自动恢复300s)
sw1(config)#errdisable recovery interval 30
查看(部分)
sw1#sho errdisable recovery
Recovery Status Timer Status
--------------- ------------
psecure-violation Enabled
Timer interval: 30 seconds
查看
sw1#sho port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action
(Count) (Count) (Count)
---------------------------------------------------------------------------
Et2/0 1 1 0 Shutdown
---------------------------------------------------------------------------
Total Addresses in System (excluding one mac per port) : 0
Max Addresses limit in System (excluding one mac per port) : 4096
二、VLAN 间攻击
概念:
默认交换机接口模式为auto或desirable ,主机模拟交换机发送DTP协商帧,建立trunk链路。 学习交换网络中的某些重要信息,发送 VTP/BPDU等信息干涉交换网络工作
解决方案:
将连接用户的接口设置为 access 接口
sw1(config-if)#switchport mode access
在trunk 链路中针对Native 打标记.
sw1(config)#vlan dot1q tag native
私有VLAN
Private VLAN :私有
Primary VLAN :主VLAN(可以有n个辅助VLAN)
Secondary VLAN :辅助VLAN 辅助VLAN分为两种:1.团体VLAN 2.孤立VLAN
主VLAN可以与辅助VLAN通信,辅助VLAN之间不能通信,孤立VLAN之间不能通信,团体VLAN内的用户可以通信
主VLAN : 混杂接口
团体VLAN :团体主机接口
孤立VLAN:孤立主机接口
配置时团体和孤立VLAN的接口统一为主机接口
使用私有VLAN , VTP模式必须为透明模式。
配置
设置为透明模式
sw1(config)#vtp mode transparent
创建两个辅助VLAN501为团体VLAN,502为孤立VLAN
sw1(config)#vlan 501
sw1(config-vlan)#private-vlan community
sw1(config-vlan)#exi
sw1(config)#vlan 502
sw1(config-vlan)#private-vlan isolated
sw1(config-vlan)#exi
创建VLAN100为主VLAN
sw1(config)#vlan 100
sw1(config-vlan)#private-vlan primary
将VLAN501和502关联到主VLAN100
sw1(config-vlan)#private-vlan association 501-502
将接口划入主VLAN
1.定义接口为混杂接口
sw1(config)#int e2/1
sw1(config-if)#switchport mode private-vlan promiscuous
2.接口划入VLAN
sw1(config-if)#switchport private-vlan mapping 100 501-502
将接口划入辅助VLAN501
1.定义接口为主机接口
sw1(config)#int range ethernet 2/2-3
sw1(config-if-range)#switchport mode private-vlan host
2.接口划入VLAN
sw1(config-if-range)#switchport private-vlan host-association 100 501
将接口划入辅助VLAN502
1.定义接口为主机接口
sw1(config)#int range ethernet 2/4-5
sw1(config-if-range)#switchport mode private-vlan host
2.接口划入VLAN
sw1(config-if-range)#switchport private-vlan host-association 100 502
查看:
sw1#sho vlan private-vlan
Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
100 501 community Et2/1, Et2/2, Et2/3
100 502 isolated Et2/1, Et2/4, Et2/5
三、DHCP 欺骗攻击
概念:
DHCP 欺骗攻击(spoofing),攻击者模拟为DHCP服务器,下发不正确的IP地址和网关
现象:
R3(config-if)#do sho ip int b
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 20.1.1.2 YES DHCP up up
接口重新shutdown no shutdown之后 重新获取地址
R3(config-if)#do sho ip int b
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 10.1.1.2 YES DHCP up up
解决方案:
DHCP snooping
信任接口:接收offer ack(由服务器发送) 转发discover request(由主机发送)
非信任接口:接收discover request (由主机发送) 转发 offer ack(由服务器发送)
将连接DHCP server接口设置为信任端口,其他为非信任接口。
将交换机设置为路由器信任的中继代理。
部署:
开启DHCP snooping
SW1(config)#ip dhcp snooping
针对某些VLAN开启snooping
SW1(config)#ip dhcp snooping vlan 1
设置接口为信任接口
SW1(config)#int e2/1
SW1(config-if)#ip dhcp snooping trust
在DHCP sever上开启针对DHCP中继信息信任
R1(config)#ip dhcp relay information trust-all
查看
SW1#sho ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- ------------
000a.0000b.000c 10.1.1.2 86342 dhcp-snooping 1 Ethernet2/1
Total number of bindings: 1
由于二层交换机解析高层(dhcp使用udp协议,应用层)性能较弱,攻击者会向交换机发送高频率的discovery报文,导致交换机瘫痪
解决办法:定义非信任接口接收dhcp消息包的频率
SW1(config)#int range e2/2-3
SW1(config-if-range)#ip dhcp snooping limit rate 2
若超过此速率,会导致接口error-disable (shutdown)
四、ARP欺骗攻击
概念:
主机发送大量IP地址变化的无故ARP,使网段中所有主机学习大量IP地址 的ARP映射都为攻击者,导致网络瘫痪
解决方案:
1.静态ARP映射(临时解决方案)
2.DAI(Dynamic ARP Intercept 动态ARP截取 )
必须依赖DHCP snooping 中所产生DHCP Snooping binding表.
若攻击者的IP地址和DHCP Snooping binding表中mac地址所对应的IP地址不一致,则shutdown该接口
部署:
全局启用ARP截取
SW1(config)#ip arp inspection vlan 1
连接网关、server 等设备设置为信任接口
SW1(config)#int e2/1
SW1(config-if)#ip arp inspection trust