How to Handle a SYN Attack on a Hosting Server Without Taking Down the Customer Website
When a SYN flood hits one customer IP, null routing stops the attack but also takes the site offline. Here's a practical hosting workflow: confirm the attack, protect first, migrate when needed, and only blackhole as a last resort.

At 2:15 PM on a Tuesday, a multi-IP hosting node carrying sixty customer websites started timing out on TLS handshakes even though upstream bandwidth barely crossed 85 Mbps. In hosting operations, the reflex reaction is almost always asking the data center to null-route the targeted IP address so the server recovers. That blackhole stops the flood in seconds, and it also knocks a paying customer's website completely offline right when they need traffic flowing.
Most small and mid-sized TCP SYN floods do not saturate physical NIC capacity; they exhaust kernel socket state tables on a single IP and port. By confirming the backlog first, hardening the Linux TCP stack, placing a reverse-proxy edge in front of a rotated origin IP, and isolating tenants cleanly, you can stop the outage without taking down the customer site.
Confirm Server Load vs. Socket Backlog Exhaustion
Before editing firewall rules or routing tables, confirm whether the host faces a network state flood rather than an application bottleneck. A maxed-out PHP worker pool or locked database table can make HTTPS checks time out identically on external monitors.

Check load averages, memory pressure, and CPU time split between user processes (us) and kernel interrupt handling (sy):
uptime
# 14:17:09 up 94 days, 6:12, 1 user, load average: 6.42, 4.11, 2.08
vmstat 1 3
# procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
# r b swpd free buff cache si so bi bo in cs us sy id wa st
# 7 0 0 4821900 312400 3910420 0 0 4 28 18420 9130 49 29 22 0 0
When CPU climbs near 78% with heavy interrupt rates (in above 18,000 per second) while memory stays flat around 52% and disk wait (wa) sits at zero, the kernel networking stack is absorbing packet pressure. If you instead see pure user-space CPU or storage wait, switch to diagnosing high CPU usage on Linux servers before touching packet filters.
Pinpoint Half-Open SYN-RECV Connections and the Targeted IP
In a normal TCP handshake, a client sends SYN, the kernel replies with SYN-ACK while holding a slot in SYN-RECV, and the client answers with ACK to reach ESTAB. During a SYN flood, spoofed sources or botnets send thousands of SYN packets per second without completing the final ACK, starving the listen queue.

Use ss (or netstat -ant on older nodes) to count half-open sockets and rank which local IP on your hosting server is targeted:
ss -ant state syn-recv | tail -n +2 | wc -l
# 1842
ss -ant state syn-recv | awk 'NR>1 {print $4}' | sort | uniq -c | sort -rn | head -n 5
# 1819 203.0.113.45:443
# 18 203.0.113.10:443
# 5 203.0.113.45:80
nstat -az | grep -E 'TcpExtListenDrops|TcpExtTCPReqQFullDoCookies'
# TcpExtListenDrops 49210 0.0
# TcpExtTCPReqQFullDoCookies 128440 0.0
On legacy systems, netstat -ant | awk '$6 == "SYN_RECV" {print $4}' | sort | uniq -c | sort -rn gives the same ranking. Here, dedicated customer IP 203.0.113.45:443 holds 1,819 half-open sockets while shared IP 203.0.113.10 holds 18, identifying the exact virtual host under fire.
Harden the Linux TCP Stack and Avoid the Conntrack Trap
Your first local mitigation makes half-open handshakes cheap to track and fast to expire. Create /etc/sysctl.d/90-syn-mitigation.conf:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 8192
net.core.somaxconn = 8192
net.ipv4.tcp_synack_retries = 2
Apply with sysctl --system and reload Nginx or Apache so listen sockets adopt the raised somaxconn limit. Dropping tcp_synack_retries from 5 (~63 seconds) to 2 (~7 seconds) clears dead SYN-RECV slots nearly nine times faster while giving mobile users on lossy networks two retries.
Avoid a classic firewall mistake: placing stateful iptables or nftables rate limits on spoofed SYN floods without bypassing conntrack. Random spoofed source IPs allocate a fresh table entry per packet until nf_conntrack_count reaches nf_conntrack_max, printing nf_conntrack: table full, dropping packet in dmesg and dropping legitimate SSH and database traffic. Check sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max first, and meter raw SYN bursts inside the raw hook (notrack):
nft add table inet syn_guard
nft 'add chain inet syn_guard raw_pre { type filter hook prerouting priority raw; policy accept; }'
nft 'add rule inet syn_guard raw_pre ip daddr 203.0.113.45 tcp flags syn / syn,ack,fin,rst meter syn_src { ip saddr limit rate over 15/second burst 30 packets } notrack drop'
Scrub Traffic With a Reverse Proxy CDN and Rotate the Origin IP
Kernel tuning absorbs moderate floods, whereas sustained attacks belong at an Anycast CDN and WAF edge like Cloudflare or Fastly. Because the proxy completes the TCP handshake at the edge before forwarding valid HTTP/TLS requests, raw SYN floods never touch your origin daemon.

Flipping DNS to a proxy is only half the job because bots hammering 203.0.113.45 ignore DNS updates and scrape historical origin IPs from Passive DNS archives. To shed the attack cleanly:
- Enable CDN reverse-proxy mode with
Full (Strict)TLS verification. - Reassign the customer's virtual host in Nginx, Apache, or cPanel onto a clean secondary IP on the box (such as
203.0.113.88). - Point the CDN's origin
Arecord to203.0.113.88and lock ports80and443on that IP innftablesso only published CDN CIDRs can connect. - Audit
MXandmail.records so mail headers or DNS zones do not expose203.0.113.88.
Decide Whether to Mitigate in Place or Migrate Clean Sites
Multi-tenant servers require clear trade-offs depending on whether the flood targets a dedicated IP or a shared IP hosting dozens of accounts.

| Scenario | Recommended Action | Customer Downtime | Primary Operational Risk |
|---|---|---|---|
| Moderate flood on dedicated IP | Tune sysctl, proxy domain via CDN, rotate vhost to clean IP | Zero downtime | Leaving mail. subdomain pointing to the new origin IP |
| Flood on shared IP with 40+ sites | Spot targeted Host or TLS SNI in recent logs, move target to isolated IP + CDN | Under 2 minutes | Pure SYN packets carry no SNI until handshakes complete |
| Volumetric flood saturating 1 Gbps NIC | Migrate clean sites or target to scrubbed VPS, then blackhole old IP | 5-minute DNS TTL window | Stale resolver caches if TTL was left at 3600s |
| Repeat target refusing proxy setup | Move tenant onto isolated DDoS-filtered VLAN | Scheduled window | Neighboring customers seeing recurring latency spikes |
When handshakes fail before Nginx logs HTTP requests on a shared IP, check access log spikes from the minute right before TcpExtListenDrops rose, or sample companion PSH-ACK packets via tcpdump. Like the safeguards we added after our late-night 502 incident response, keeping zone DNS TTLs at 300 seconds turns emergency migrations into five-minute cutovers.
Reserve Null Routing Strictly for the Final Resort
Null routing locally (ip route add blackhole 203.0.113.45/32) or upstream via BGP Remote Triggered Black Hole (RTBH) drops every packet for that IP before it hits your server.

Upstream RTBH makes sense in only two cases: after live DNS traffic has cut over to a protected IP, or when multi-gigabit volumetric traffic saturates physical rack uplinks (rx_dropped climbing on ip -s link show eth0) and threatens neighboring machines. Otherwise, blackholing finishes the attacker's job. Confirm SYN-RECV sockets first, tune kernel queues, shield and rotate the origin IP behind an edge proxy, and save null routes for retired addresses.