How to stop a DDoS attack, step by step
When a service slows to a crawl, the first job is to work out whether it is an attack at all, and if so, which layer it hits. The right fix differs completely between a network flood and a flood of web requests.
Is it really an attack?
Check that first, because many outages that look like attacks are not. A marketing email, a search engine crawl, a backup job saturating the port or a slow database query all produce similar symptoms. Look at three numbers together: traffic on the network interface, the number of connections, and the share of requests that come from a small set of sources or hit one URL. A flood shows traffic or connections far above normal with no matching rise in genuine orders, sign-ins or player counts.
nload -m enp1s0f0
ss -s
ss -Htan state syn-recv | wc -l
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -15
Which layer is under attack?
Answer this before acting. Volumetric floods fill the link with packets; protocol attacks such as SYN floods exhaust connection tables; application floods send valid-looking HTTP requests that keep your web server and database busy. The first two show up in interface counters and kernel statistics; the third shows up in access logs while bandwidth may look ordinary.
| Symptom | Likely layer | First response |
|---|---|---|
| Port at its line rate, packet loss | Volumetric | Edge filtering handles it; confirm in your alerts |
| Thousands of half-open connections | Protocol | SYN cookies and backlog settings, edge filtering |
| CPU high, many identical requests | Application | Rate limits, caching, blocking patterns |
| Normal traffic, slow responses | Probably not an attack | Profile the application and database |
What happens at the network edge?
On our machines, volumetric and protocol floods are detected and scrubbed before they reach your port, automatically and at no extra cost. You will see the clean traffic only, and you may receive an alert that mitigation started. There is nothing to switch on. Our guide on Recognise a network attack explains how to read those notices. If the link is still saturated after mitigation begins, gather a short packet capture so the pattern can be checked.
tcpdump -ni enp1s0f0 -c 2000 -w /root/flood-sample.pcap 'not port 22'
How do I handle an HTTP flood on the host?
Make every request cheaper and limit how many each source may send. Serve cached pages to anonymous visitors, put expensive endpoints such as search and login behind tight per-address limits, and return a quick 429 rather than queueing work. In nginx that takes a few lines:
geo $flood_exempt { default 0; 198.51.100.0/24 1; }
map $flood_exempt $flood_key { 1 ""; default $binary_remote_addr; }
limit_req_zone $flood_key zone=flood_ip:20m rate=480r/m;
limit_conn_zone $binary_remote_addr zone=conns:10m;
location /search { limit_req zone=flood_ip burst=16 nodelay; limit_conn conns 10; }
The geo and map lines exempt an office range from the limit, since an empty key is never counted. If one pattern dominates the logs, such as a fixed user agent or a nonsense query string, block that pattern at the web server. Fail2ban can read the access log and add short bans automatically for sources that exceed a threshold.
Which kernel settings help with protocol floods?
SYN cookies let the server answer connection attempts without keeping state for each one, and a larger backlog absorbs bursts. Most distributions already enable SYN cookies; confirm it during calm times.
sysctl net.ipv4.tcp_syncookies sysctl -w net.ipv4.tcp_max_syn_backlog=8192 net.core.somaxconn=4096
Should I change the server address?
Rarely, and with us not as a quick fix: each machine has one IPv4 and we do not sell extra or failover addresses. Edge filtering is designed so that you keep your address. What does help is separating services: the public website behind a content delivery or caching proxy, and management access such as SSH limited to known addresses or a WireGuard tunnel, so an attack on the public side never locks you out.
What should I do after the attack?
Write down the timeline, the layer, the peak numbers and what worked. Keep the rate limits that helped, add alerts on the signals that first showed the problem, and test that your monitoring host, ideally in another data centre, kept reporting throughout. Repeat attackers often return with a different pattern, so the review is part of the defence. The DDoS protection on bare metal article explains the filtering itself, and Hardening a new dedicated server covers the host baseline.
Machines with headroom for busy public services
| Model | Processor | Cores | Memory | Drives | Port | Per month |
|---|---|---|---|---|---|---|
| ESSENTIAL-2 | Intel Xeon-E 2388G | 8 | 32 GB | 2x 512 GB SSD NVMe | 1 Gbps unmetered | $43.20 |
| BUSINESS-1 2024 | AMD EPYC 4244P | 6 | 32 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $81.60 |
| BUSINESS-2 2024 | AMD EPYC 4344P | 8 | 64 GB | 2x 960 GB SSD NVMe | 3 Gbps unmetered | $109.80 |
| ESSENTIAL-GAME-1 | AMD Ryzen 5 5600X | 6 | 32 GB | 2x 512 GB SSD NVMe | 1 Gbps unmetered | $43.20 |
Related pages
DDoS protection on bare metal
How network edge filtering stops volumetric attacks before they reach your port, and what you still handle yourself.
Read moreRecognise a network attack
Tell an attack from a traffic spike using the server's own counters, know what the upstream filtering handles, and what to send in a ticket.
Read moreHardening a new dedicated server
The first hour on a fresh machine: SSH keys, a firewall, automatic updates, brute force blocking and a habit of checking what listens.
Read moreDDoS protected servers
Every machine sits behind always-on attack filtering at no extra cost; how it works with your own firewall and which services benefit most.
Read moreQuestions and answers
How can I tell a DDoS attack from a traffic spike?
Compare traffic and connections with real business signals such as orders, sign-ins or players. A flood raises the first without the second.
Do I need to switch on DDoS protection during an attack?
No. Edge filtering is always on for every machine we rent and starts mitigation automatically.
How do I stop an HTTP flood on nginx?
Use limit_req and limit_conn per address on costly paths, serve cached pages and block obvious patterns from the access log.
Can I get a new IP address after an attack?
We do not sell extra or failover addresses, and filtering is designed to let you keep the one you have.
What are SYN cookies?
A kernel feature that answers connection attempts without storing state for each, so SYN floods cannot fill the connection table.