Quick answer
If an attack is happening right now, the fastest route back online is to get your traffic behind a network that can absorb it — for a website that means moving DNS to a reverse proxy, and for anything else it means routed transit. Before that helps you have to confirm it is actually an attack rather than a traffic spike or an outage, and you have to make sure your origin address cannot be reached directly, or the attacker will simply bypass whatever you put in front of it. Blocking individual addresses and rebooting the server are the two most common reactions and neither works against a distributed attack.
01First: confirm it is an attack
A genuine traffic spike, an application fault, an upstream network problem and an attack all present as "the site is down", and acting on the wrong one wastes the time that matters most. The read-only checks in signs of a DDoS attack separate them in a few minutes, from the link inwards to the application. If the site already sits behind a proxy, a 502 bad gateway or a 504 gateway timeout points at the origin rather than at the network in front of it.
02While it is happening
The order matters. Getting protection in place is useless if the attacker can still reach the address behind it.
- Get behind a network with capacity — for HTTP, point DNS at a reverse proxy; for anything else, arrange routed or tunnelled transit
- Check the TTL on the records you are about to change: resolvers keep the old answer for up to that long, and lowering it now only helps once the old value has expired
- Firewall the origin to accept web traffic only from your provider's published ranges, or the attack simply continues around your new protection; hiding your origin IP covers the other leaks to close
- Turn on the strictest protection mode you have while you stabilise, then relax it
- Cache aggressively — anything served from cache never touches your origin
- Tell your host: they see the traffic before you do and may already be null-routing you
#!/usr/sbin/nft -f
# Replace the example ranges with the list your provider publishes.
# Re-running the file replaces this table and leaves other rules alone.
table inet origin_lock
delete table inet origin_lock
table inet origin_lock {
set proxy4 {
type ipv4_addr
flags interval
elements = { 203.0.113.0/24, 198.51.100.0/24 }
}
set proxy6 {
type ipv6_addr
flags interval
elements = { 2001:db8::/32 }
}
chain input {
type filter hook input priority filter; policy accept;
iif "lo" accept
ct state established,related accept
tcp dport { 80, 443 } ip saddr @proxy4 accept
tcp dport { 80, 443 } ip6 saddr @proxy6 accept
tcp dport { 80, 443 } counter drop
}
}03Pick the route back online by what is under attack
The fix depends less on the attack than on what it is aimed at. A website can be moved behind protection with a DNS change; most other services cannot, and knowing that before you start saves an hour of trying the wrong thing.
| What is attacked | Fastest route back | What to watch |
|---|---|---|
| Website or HTTP API | Point DNS at a reverse proxy with DDoS capacity | Every hostname that still resolves to the origin |
| Game server or other UDP service | Routed or tunnelled transit that filters UDP rather than dropping it | The real address published in server lists or launchers |
| Mail server | Keep MX on a separate host; a web proxy does not carry SMTP | MX records that point at the same address as the website |
| DNS server | Secondary or hosted DNS on a network with capacity | Open recursion, which turns your server into a reflector |
| Your own address block | Upstream filtering announced over BGP, with clean traffic delivered back by tunnel | Whether the provider can announce your prefix at all |
| Anything your host has null-routed | Move the service behind protection first, then ask for the null route to be lifted | What the host's policy is for lifting it; they differ |
04What not to do
These are the reactions people reach for first, and each one costs time without helping.
| Reaction | Why it fails |
|---|---|
| Blocking attacking IPs | Thousands of sources, rotating constantly; in reflection attacks they are innocent third parties |
| Rebooting the server | It comes back up into the same flood, having lost whatever was still working |
| Blocking a whole country | Attacks are global; you mostly block customers |
| Turning off the site | That is the attacker's goal, achieved manually |
| Scaling up the server | Volumetric attacks saturate the link, which more CPU does not widen |
| Switching protection off the moment it goes quiet | Attacks often come back in waves, and the next one lands on an unprotected origin |
| Paying a ransom | Marks you as a target that pays, and rarely ends it |
05Afterwards, before the next one
Attacks recur, frequently against the same target and often shortly after. The window right after one ends is the only time you will have both the motivation and the calm to prepare properly.
- Keep protection always-on rather than switching it on when something breaks: Cloudflare's report for the first half of 2026 found that 90.6% of network-layer attacks were over within ten minutes, faster than anyone can react by hand; how long DDoS attacks last has the wider data
- Audit every DNS record for anything still pointing at the origin, including subdomains you forgot; a DNS lookup of each name shows what the rest of the world sees
- Check certificate transparency logs for certificates issued to hostnames that resolve to your origin — the logs are public and append-only, so anything there stays findable
- Move mail off the web server, or its headers publish the address you just hid
- Write down what the traffic looked like: source spread, request pattern, which endpoints were targeted
- Report serious or repeated attacks: DDoS attacks are a criminal offence in most jurisdictions, and timestamps plus logs make a report usable
- Set alerts on your own baseline, not on fixed thresholds
06Match the defence to the layer
A single answer does not cover every attack type, and buying the wrong one is a common and expensive mistake.
| Attack | What actually stops it |
|---|---|
| Volumetric flood | Upstream capacity — absorbed before your uplink |
| SYN or protocol flood | Filtering at the edge, plus SYN cookies, which avoid holding state for half-open connections |
| HTTP flood | Request inspection and challenges, not packet filtering; on a server you run, nginx limits and caching buy headroom |
| Slow attacks such as Slowloris | Connection timeouts and limits at the proxy |
| UDP flood on a game server | Routed transit with real UDP filtering, not null-routing |
Questions
Frequently asked questions
Sources
Sources and verification
nftables ruleset syntax-checked with nft 1.0.6, loaded twice in an isolated network namespace and tested over a veth pair (a listed source reached port 80, an unlisted source was dropped and counted). Debian 12, October 2026.
Last updated