Automatic SYN flood defense

Automatic SYN flood defense

A SYN flood fills the server with half-open connections (SYN_RECV state) until it can no longer serve legitimate connections. Resources detects it and blocks the attackers by itself, without you having to log in to the server.

What it does

  • When half-open connections exceed the threshold, the panel detects the source IPs.
  • It permanently blocks the IPs that have 5 or more half-open connections. The minimum is set per server.
  • The block is made in the server's own firewall: CSF (csf -d) if installed and, if not, firewalld (with a permanent ipset), ipset with iptables or nftables.
  • The blocks are re-applied automatically if the firewall restarts.
  • It only alerts (e-mail, WhatsApp and escalation, with confirmation, mutes and maintenance windows like the rest of the alerts) if the attack continues after 5 checks. The alert says how many IPs were blocked and the main ones.
  • It is on by default.

What it never blocks

  • The panel's IPs.
  • Private and reserved IPs.
  • The server's own IPs.
  • The organization's other servers.
  • The IPs in that server's allowed IPs list.
  • It has caps on blocks per reading and per server, so a mistake or a huge attack cannot fill the firewall.

Spoofed or distributed attacks

If the attack comes from thousands of IPs with 1 or 2 connections each (spoofed addresses or a very distributed botnet), blocking IP by IP does not help: the panel does not mass-block. In that case the alert explains it and recommends turning on SYN cookies on the server or asking your provider to filter the traffic before it arrives.

Permissions: root or one sudoers line

  • With the root user nothing is needed.
  • With a non-root user, the panel needs to run only the firewall commands with sudo. In the SYN flood tab the panel shows the ready-made line for the detected firewall. For CSF, on the server, with visudo -f /etc/sudoers.d/reikor-synflood:
Cmnd_Alias REIKOR_SYNFLOOD = /usr/sbin/csf -d * reikor synflood, /usr/sbin/csf -dr *
<user> ALL=(root) NOPASSWD: REIKOR_SYNFLOOD

Replace <user> with the SSH user you added the server with. It only allows blocking and unblocking IPs with CSF, nothing else.

The SYN flood tab

It is in each Resources server and shows:

  • The state of the defense and the detected firewall.
  • The settings: a switch to turn it on or off, the minimum half-open connections per IP and the allowed IPs.
  • The table of blocks, with the Unblock button to remove an IP from the firewall.

Requirements and plans

  • Linux servers with Resources. It is not available on Windows servers.
  • Available on paid plans, at no extra cost. See pricing.

See also add a server, alerts and server security.