技术论坛
FAQ-S交换机配置本机防攻击案例
更新时间:2022-09-07
组网需求
如图1所示,位于不同网段的用户通过Switch接入Internet。由于接入了大量用户,因此Switch的CPU会处理大量收到的协议报文。如果存在恶意用户发送大量攻击报文,会导致CPU使用率过高,影响正常业务。
· 管理员希望能够实时了解CPU的安全状态。当确定CPU受到攻击时,Switch能够及时通知管理员,并采取一定的安全措施来保护CPU。
· 管理员发现Switch收到了大量的ARP Request报文,因处理这些ARP Request报文导致CPU使用率大幅度提高,希望能够降低CPU使用率,防止影响正常业务。
· 管理员发现Net1网段中的用户经常会发生攻击行为,希望能够阻止该网段用户接入网络。
· 管理员需要以FTP方式上传文件到Switch,希望管理员主机与Switch之间FTP数据能够可靠、稳定地传输。
图1 配置本机防攻击示例组网图
配置思路
采用如下的思路在Switch上配置本机防攻击:
1. 配置攻击溯源检查、告警和惩罚功能,使设备在检测到攻击源时通过告警方式通知管理员,并能够对攻击源自动实施惩罚。
2. 配置端口防攻击检查阈值(端口防攻击缺省情况下已使能,这里无需再次使能),使设备基于端口维度对超出检查阈值的协议报文进行限速并以日志方式通知管理员,防止某个端口下存在攻击者发送大量恶意攻击报文,挤占其他端口协议报文上送CPU处理的带宽。
3. 配置ARP Request报文的CPCAR值,将ARP Request报文上送CPU处理的速率限制在更小的范围内,减少CPU处理ARP Request报文对正常业务的影响。
4. 将Net1网段中的攻击者列入黑名单,禁止Net1网段用户接入网络。
5. 配置FTP协议建立连接时FTP报文上送CPU的速率限制(FTP协议的动态链路保护功能缺省情况下已使能,这里无需再次使能),实现管理员主机与Switch之间文件数据传输的可靠性和稳定性。
操作步骤
配置上送CPU报文的过滤规则
# 定义ACL规则。
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] acl number 2001
[Switch-acl-basic-2001] rule permit source 1.1.1.0 0.0.0.255
[Switch-acl-basic-2001] quit
配置防攻击策略
# 创建防攻击策略。
[Switch] cpu-defend policy policy1
# 配置攻击溯源检查功能。
[Switch-cpu-defend-policy-policy1] auto-defend enable
# 使能攻击溯源告警功能。
[Switch-cpu-defend-policy-policy1] auto-defend alarm enable
# 配置攻击溯源惩罚措施为丢弃攻击报文。
说明:
在配置攻击溯源惩罚措施之前,请确保设备受到了非法攻击,避免因误丢弃大量正常协议报文而影响正常业务。
[Switch-cpu-defend-policy-policy1] auto-defend action deny
# 配置端口防攻击检查阈值为40pps。(端口防攻击缺省情况下已使能,这里无需再次使能)
[Switch-cpu-defend-policy-policy1] auto-port-defend protocol arp-request threshold 40
# 配置网络侧接口GE0/0/1为端口防攻击白名单,避免网络侧的协议报文得不到CPU及时处理而影响正常业务。
[Switch-cpu-defend-policy-policy1] auto-port-defend whitelist 1 interface gigabitethernet 0/0/1
# 配置ARP Request报文的CPCAR值为120kbit/s。
[Switch-cpu-defend-policy-policy1] car packet-type arp-request cir 120
# 配置CPU防攻击黑名单。
[Switch-cpu-defend-policy-policy1] blacklist 1 acl 2001
# 配置FTP协议建立连接时FTP报文上送CPU的速率限制为5000kbit/s。
[Switch-cpu-defend-policy-policy1] linkup-car packet-type ftp cir 5000
[Switch-cpu-defend-policy-policy1] quit
全局应用防攻击策略
[Switch] cpu-defend-policy policy1 global
[Switch] quit
验证配置结果
# 查看攻击溯源的配置信息。
<Switch> display auto-defend configuration
----------------------------------------------------------------------------
Name : policy1
Related slot : <0>
auto-defend : enable
auto-defend attack-packet sample : 16
auto-defend threshold : 128 (pps)
auto-defend alarm : enable
auto-defend alarm threshold : 128 (pps)
auto-defend trace-type : source-mac source-ip source-portvlan
auto-defend protocol : arp icmp dhcp igmp ttl-expired tcp telnet
auto-defend action : deny (Expired time : 300 s)
----------------------------------------------------------------------------
# 查看端口防攻击的配置信息。
<Switch> display auto-port-defend configuration
----------------------------------------------------------------------------
Name : policy1
Related slot : 0
Auto-port-defend : enable
Auto-port-defend sample : 5
Auto-port-defend aging-time : 300 second(s)
Auto-port-defend arp-request threshold : 40 pps(enable)
Auto-port-defend arp-reply threshold : 30 pps(enable)
Auto-port-defend dhcp threshold : 30 pps(enable)
Auto-port-defend icmp threshold : 30 pps(enable)
Auto-port-defend igmp threshold : 60 pps(enable)
Auto-port-defend ip-fragment threshold : 30 pps(enable)
--------------------------------------------------------------------------------
# 查看配置的防攻击策略的信息。
<Switch> display cpu-defend policy policy1
Related slot : <0>
Configuration :
Blacklist 1 ACL number : 2001
Car packet-type arp-request : CIR(120) CBS(22560)
Linkup-car packet-type ftp : CIR(5000) CBS(940000)
# 查看配置的CPCAR的信息。
<Switch> display cpu-defend configuration packet-type arp-request
Car configurations on slot 0.
----------------------------------------------------------------------
Packet Name Status Cir(Kbps) Cbs(Byte) Queue Port-Type
---------------------------------------------------------------------- arp-request Enabled 120 22560 3 UNI
----------------------------------------------------------------------