如何缓解DDOS攻击

1、减少攻击面

(a) reduce the number of necessary Internet entry points,
(b) eliminate non-critical Internet entry points, 
(c) separate end user traffic from management traffic, 
(d) obfuscate necessary Internet entry points to the level that untrusted end users cannot access them, and 
(e)decouple Internet entry points to minimize the effects of attacks. 

a、减少必要的互联网入口接入点,举个例子,你的用户都是中国,那么在DNS解析的时候,国外用户就不用解析了。或者让他们解析到127.0.0.1去。根据地域的IP来做智能DNS解析;
b、消除非关键互联网入口,比如只开放80端口,只开放必须的域名对外访问,等等;
c、 不要让普通用户走你的管理网络,也就是普通通道和管理通道必须隔离开来。
d、 不可信任的用户禁止访问网络
e、 减少INTERNET接入。
在AWS里,可以创建EC2的安全组,来限制部分IP或者协议访问你的网络;还可以创建VPC的ACL来控制IP网络。最后创建VPN来管理网络。

2、 Be Ready to Scale and Absorb the Attack准备吸收DDOS攻击
 吸收DDOS攻击,有横向和纵向两个方面。
横向吸收就是增加EC2个数,纵向就是增加CPU,网卡,内存。

(1) select the appropriate instance types for your application,
(2) configure services such as Elastic Load Balancing and Auto Scaling to automatically scale, and 
(3) use the inherent scale built into the AWS global services like Amazon CloudFront and Amazon Route 53

 a、选择正确的实例类型;用来抗DDOS的EC2,AWS建立你用万兆网卡的实例。。。用半虚拟化的实例,C3, C4, R3, D2, and I2 instances。这些实例可以安装SR-IOV网卡驱动,专门来对抗DDOS。
b、创建ELB负载均衡 
 Because ELB only supports valid TCP requests, DDoS attacks such as UDP and SYN floods are not able to reach your instances.

因为ELB只支持有效的TCP请求,DDoS攻击如UDP和SYN洪水无法到达你的实例。
c、Auto Scaling,AWS很重要的一个功能
Auto Scaling helps you maintain application availability and allows you to scale your
EC2 capacity up or down automatically according to conditions you define. For example,
you can set a condition to incrementally add new instances to the Auto Scaling group
when network traffic is high (typical of DDoS attacks). You can also set a condition to
remove instances in the same increments when network traffic is low. You can use
Amazon CloudWatch to trigger scaling activities and ELB to distribute traffic to your
instances within Auto Scaling groups.
意思就是说:
Auto Scaling可以帮助您保持应用程序的可用性,并允许您扩展您的
EC2容量或根据你定义自动。例如,
您可以设置条件以增量向自动缩放组添加新实例
当网络流量大(典型的DDoS攻击)。您还可以设置条件
当网络流量较低时,删除相同的增量实例。你可以用
亚马逊CloudWatch触发缩放活动和ELB流量分发到你的
自动缩放组中的实例。 
一般EC2的计费是按24小时一计费的。所以,一般自动创建完EC2可以24小时以后再让它自动删除EC2实例。

使用 Auto Scaling有以下一些注意事项:
  How long it takes to launch and configure your servers? If you’re application
takes more than five minutes to start, we recommend having multiple instances
already running your application or low thresholds for scaling.
 一个EC2实例的自动启动大概需要五分钟时间,所以你不要等到你的CPU已经100%或者网络使用已经100%再启动你的新实例,您应该在比如50%以上就要启动新实例了。
 What metrics have the most relevance to your application's performance?
Example metrics for DDoS attacks are CPUUtilization, NetworkIn, and
StatusCheckFailed.
服务状态是否失败。
 What existing resources (such as EC2 instances or AMIs) you might want to use as
part of your Auto Scaling group? You’ll want the same type of instance or higher
capacity running the application under attack for your Auto Scaling group.
你可以设定自动创建的EC2实例,是跟以前一样或者更高配置,比如万兆网卡的实例。 
 To how many AZs do you want the Auto Scaling group to span? We recommend a
minimum of two AZs.
至少需要创建2个AZ实例组 
 How fast should you scale up and down? Keep in mind that DDoS attacks can
come in waves. You don’t want to scale down after the initial wave only to find
out you have to scale back up again.
 一般EC2的计费是按24小时一计费的。所以,一般自动创建完EC2可以24小时以后再让它自动删除EC2实例。
 What is the maximum amount of EC2 instances for the Auto Scaling group?
Additional instances may increase your costs. When you create your Auto
Scaling policy, you can set maximum number of instances. You can also set an
alarm when this maximum number has been reached. See Amazon CloudWatch
for steps on setting alarms.
 可能会造成大量的金额,不过一般只开24小时的话,花不了多少钱,当然你可以设置金额的警报。

3、Amazon CloudFront亚马逊的云服务 
CDN这块抗DDOS就不用说了, 可以把您的流量分到各地去,让攻击者无法找到您真正的原站资源。
Amazon CloudFront还具有过滤功能,以确保只有有效的TCP连接和HTTP请求而放弃无效的请求
 
4、Amazon Route 53,亚马逊的智能DNS服务 
这块我之前已经介绍过了。 你的用户都是中国,那么在DNS解析的时候,国外用户就不用解析了。或者让他们解析到127.0.0.1去。根据地域的IP来做智能DNS解析;

5、Safeguard Exposed Resources保护公开的资源 
这块主要是结合安全组以及 Amazon CloudFront。
当然AWS里有WAF防火墙模版,你可以创建WAF模版,然后在两个ELB之间连接WAF模版,将进入的数据过滤。
 

6、Learn Normal Behavior
 
 
可以根据CloudWatch监控的参数,来触发EC2实例的增加和减少。
原文地址:https://www.cnblogs.com/itfat/p/7268014.html