No products in the cart.
Looking for a comprehensive solution on how to defend against DDoS attacks? This nanny-level guide provides detailed tutorials and practical solutions, covering every step from infrastructure optimization to CDN deployment. Learn how to effectively respond to DDoS attacks to ensure safe and stable business operation. Check out the complete guide to improve your online security now!
Based on years of practical protection experience and technical documentation from global top security vendors, this article compiles a highly actionable defense system. The following content covers the entire process from basic configurations to hybrid attack mitigation, suitable for IT operations teams, security engineers, and enterprise technical decision-makers.
Of course, the best approach is to integrate CDN5's Advanced Anti-DDoS CDN, where CDN5 engineers and AI bots will handle acceleration and protection for you.
1. Bandwidth Expansion & Traffic Scrubbing
Log into the CDN5 console and navigate to the High-Protection IP service page.
Select Purchase New Instance, choose a Game Protection or Web Protection plan based on business needs.
Configure port forwarding rules (example):
# Map High-Protection IP port 80 to origin server 10.0.0.1:8080
add forwarding-rule 80 TCP 10.0.0.1 8080
CDN5’s AI bot automatically activates Intelligent Scheduling to switch scrubbing nodes and routes.
2. Blackhole Routing & Rate Limiting (Linux Server Implementation)
Dynamic IP Blocking:
# Block IPs with 1000+ new connections in 1 minute (based on [HK InfoSec Guidelines](https://www.infosec.gov.hk/en/best-practices/business/defending-against-ddos-attack))
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --
set
iptables -I INPUT -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 60 --hitcount 1000 -j DROP
Bandwidth Throttling (for UDP Flood Attacks):
# Limit UDP port to 1000 packets/sec (ref: [CDN5 Traffic Control](https://www.cdn5.com/networks/how-to-prevent-ddos-attacks/#traffic-shaping))
iptables -A INPUT -p udp -m
limit
--
limit
1000/sec -j ACCEPT iptables -A INPUT -p udp -j DROP
This configuration reduces 70% of junk traffic.
1. Linux Kernel Tuning (Mandatory Configurations)
SYN Cookie Mechanism:
# Enable SYN Cookies for SYN Flood defense (details: [CDN5 Transport Layer Guide](https://www.cdn5.com/guides/ddos/attack-prevention/#transport-layer))
echo
1 > /proc/sys/net/ipv4/tcp_syncookies
Connection Queue Adjustments:
# Half-open queue limit (default 1024 → 65535)
echo
65535 > /proc/sys/net/ipv4/tcp_max_syn_backlog
# Fully established queue limit
echo
65535 > /proc/sys/net/core/somaxconn
Supports 10x more concurrent connections.
2. Layer 4 Load Balancing (Nginx Example)
Geolocation-Based Traffic Routing:
geo
$blocked_country {
default
0
; 192.168.1.0/24 1;
# Allow internal IPs
58.96.0.0/15 0;
# Hong Kong region
223.255.0.0/16 1;
# High-risk attack regions (data source: [HK InfoSec Threat Intel](https://www.infosec.gov.hk/en/best-practices/business/defending-against-ddos-attack))
}
server
{
if
($blocked_country) {
return
444
; }
# Other configurations...
}
Blocks 90% of overseas malicious traffic.
1. CAPTCHA Integration
2. API Protection (Nginx + Lua Dynamic Rate Limiting)
Business-Specific Rate Limiting:
lua_shared_dict
my_limit
10m
;
server
{
location
/api {
access_by_lua_block
{
local
limit = ngx.shared.my_limit local key = ngx.var.remote_addr .. ngx.var.http_user_agent local req, _ = limit:get(key) if req and req >
100
then
# 100 requests/sec threshold (ref: [eSecurityPlanet](https://example.com))
ngx.exit(
503
) else limit:incr(key,
1
,
1
) end }
# Other configurations...
} }
Blocks 95% of API abuse.
1. SSDP Reflection Attack Defense
Drop UDP port 1900 traffic at the border router.
Suricata Detection Rule:
alertudpanyany->any
1900
(msg:"SSDPReflectionAttack";content:"M-SEARCH*HTTP/1.1";depth:14;sid:1000001;)
Cooperate with ISPs to scrub cross-border SSDP traffic.
2. Layer 4 CC Attack Mitigation
TCP Connection Fingerprint Analysis:
# Use tshark to extract attack patterns (method from [eSecurityPlanet](https://example.com))
tshark -r attack.pcap -Y
"tcp.flags.syn==1"
-T fields -e ip.src -e tcp.options
Analyze TCP option fields to identify botnet clusters.
1. Business Continuity Plan
Static Fallback Page (Nginx Config):
server
{
location
/ {
error_page
502503504
/static.html;
# Normal logic...
}
location
= /static.html {
root
/var/www/emergency;
expires
1h
; } }
Automatically switches to a static page during outages (ref: HK InfoSec Guidelines).
2. Attack Forensics & Legal Process
tcpdump -i eth0 -w attack.pcap -G 3600 -C 100
(see eSecurityPlanet Guide).whois 203.0.113.5 | tee attacker_info.txt
.Tool Type | Recommended Solutions | Use Cases | Complexity |
---|---|---|---|
Traffic Scrubbing | CDN5 Pro | Small/Medium Web Apps | ★★☆☆☆ |
Protocol Layer Defense | Suricata + EmergingThreats | Enterprise Network Perimeters | ★★★★☆ |
Application Layer | ModSecurity + OWASP CRS | E-commerce/High-Security Needs | ★★★☆☆ |
Behavioral Analysis | Fail2ban + Elasticsearch | Real-Time Server Monitoring | ★★★★☆ |
Full-Stack Protection | CDN SDK | Gaming/Live Streaming | ★★☆☆☆ |
1. Use a DDoS Protection Service or Self-Defense?
2. Emergency Response During Attacks
3. How to Detect an Attack?
5. Budget Solutions for Small Companies