How to stop DDoS attacks
A Distributed Denial of Service (DDoS) attack overwhelms a target with traffic from many sources, making the service unavailable to legitimate users. Stopping a DDoS requires detecting it quickly, filtering bad traffic before it reaches your servers, and absorbing the volume that does get through. Most modern defenses are CDN-based — edge networks like Cloudflare, AWS Shield, and Akamai absorb attacks at the edge before they reach your origin.
This guide covers the 10 most effective tactics, organized by attack type and infrastructure layer.
Types of DDoS attacks
| Type | Layer | Example | Primary defense |
|---|---|---|---|
| Volumetric | 3/4 (Network) | UDP flood, ICMP flood, DNS amplification | CDN absorption, scrubbing |
| Protocol | 3/4 (Network) | SYN flood, fragmented packet attack | Stateful firewall, SYN cookies |
| Application | 7 (HTTP) | HTTP flood, slowloris, Layer 7 DDoS | WAF rules, rate limiting, bot detection |
10 tactics to stop DDoS attacks
1. Use a CDN with built-in DDoS protection
Cloudflare, AWS CloudFront + Shield, Akamai, Fastly. They absorb volumetric attacks at the edge using massive backbone capacity (Tbps). For most sites, this single change prevents 95%+ of attacks from reaching origin.
2. Enable Web Application Firewall (WAF) rules
WAF blocks malicious request patterns at the edge — SQL injection, XSS, OWASP Top 10. For DDoS, the relevant rules block known bad bot signatures, request floods from single IPs, and unusual patterns (1000 requests/second from one IP).
3. Rate limit per IP and per session
Configure per-IP rate limits at the CDN or load balancer (e.g., 100 req/min per IP). Blocks credential stuffing, scraper bots, and small-scale Layer 7 floods. Be careful with corporate NATs (1 IP = many users).
4. Use anycast routing
Anycast spreads incoming traffic across many geographic locations. Even a 1 Tbps attack arrives split across 30+ data centers, making it absorbable per-PoP. Most CDNs use anycast.
5. Filter at the network edge with scrubbing services
For attacks too large for inline mitigation, scrubbing services (AWS Shield Advanced, Cloudflare Magic Transit, Akamai Prolexic) re-route traffic through specialized cleaning centers and forward only legitimate traffic to your origin.
6. Implement bot management
Sophisticated bot detection (Cloudflare Bot Management, DataDome, PerimeterX) uses behavioral fingerprinting to distinguish humans from bots. Blocks scraper-based floods that pass simple rate limits.
7. Use stateful SYN flood protection
SYN floods exhaust server connection tables. Solutions: SYN cookies (Linux kernel), connection rate limiting at firewall, modern TCP stacks with SYN flood detection.
8. Block traffic from suspicious geographies
If your business serves only certain countries, block all others at the edge. Significantly reduces attack surface. Be careful: legitimate users via VPN may be blocked.
9. Cache aggressively
If 95% of requests can be served from CDN cache, your origin only handles 5% — making volumetric Layer 7 attacks much less effective. Long TTLs + stale-while-revalidate for max protection.
10. Have an incident response plan
Know who to call (your CDN's emergency line, your DDoS scrubbing provider). Pre-arranged contracts let you flip mitigation on within minutes vs. hours of vendor onboarding mid-attack.
What NOT to do
- Don't try to absorb attacks at your origin. Even large servers can be saturated by 10 Gbps attacks. Edge defense is the only viable strategy.
- Don't rely on null-routing alone. Null-routing your IP makes the attack succeed (target is now unreachable). Use it only as a last resort while you scrub.
- Don't ignore Layer 7 because Layer 3/4 is mitigated. Modern attacks are increasingly application-layer (HTTP floods that look like legitimate traffic).
- Don't pay ransom. Pays incentivize more attacks; no guarantee the attack stops.
- Don't underestimate detection time. The attack is over before you fully analyze it; have automated detection + mitigation, not manual.
Test your DDoS protection
Pre-arranged load tests verify your defenses work before a real attack:
- Coordinate with your CDN. Run agreed load tests up to your protected capacity ceiling.
- Test rate limit thresholds. Verify that rate limits trigger at the right thresholds without false-positiving real users.
- Simulate Layer 7 floods. Use tools like LoadFocus to fire HTTP requests at scale and verify WAF rules catch them.
- Practice incident response. Run tabletop exercises with the team. Who decides to enable emergency mode? Who calls the vendor?
FAQ: stopping DDoS attacks
Can I stop a DDoS attack myself?
Small attacks: maybe (rate limiting, blocking IPs). Medium-large attacks (>1 Gbps): you need a CDN or scrubbing service. Massive attacks (>100 Gbps): only major CDN providers can handle.
How long do DDoS attacks last?
Average: 30-60 minutes. Some persist for days. Sophisticated attackers test your defenses, then escalate.
Will a CDN stop all DDoS attacks?
It blocks most volumetric attacks at the edge. Application-layer attacks (HTTP floods) need additional WAF rules + bot management.
What's the cost of DDoS protection?
Cloudflare's free tier provides basic DDoS protection. Pro $20/mo, Business $200/mo, Enterprise (negotiated). AWS Shield Advanced: $3,000/month + traffic. Akamai Prolexic: enterprise pricing.
How do I know if I'm under DDoS attack?
Sudden traffic spikes from many IPs, server unresponsive, error rates climbing, monitoring alerts firing across regions simultaneously. Your CDN dashboard typically shows attack volume in real-time.
Can I prevent DDoS attacks completely?
No — anyone can launch a DDoS attempt. But proper defenses make most attacks ineffective without disrupting service to real users.
Test DDoS defenses with LoadFocus
If you're validating your DDoS protection thresholds, LoadFocus runs HTTP load tests up to 12,500 VUs from 25+ cloud regions — useful for verifying WAF rules trigger correctly and rate limits hold under pressure (always coordinate with your CDN before high-volume tests). Sign up for a free tier at loadfocus.com/signup.
Related LoadFocus Tools
Put this concept into practice with LoadFocus — the same platform that powers everything you just read about.