DDoS Protection

Cloudflare DDoS Protection vs kernel firewall: when to use what?

June 21, 2026 · 11 min read
Illustration immersive du sujet : Cloudflare vs kernel firewall

When evaluating Cloudflare vs kernel firewall solutions in 2026, infrastructure teams face a fundamental architectural question: should you filter malicious traffic before it reaches your server (cloud-based edge), or intercept it at the server's kernel network stack? Both approaches address DDoS mitigation and access control, but operate at entirely different layers with complementary strengths. This article dissects the technical tradeoffs, cost structures, and practical deployment scenarios to help you choose—or combine—the right protection layer for your infrastructure.

The comparison between cloud-based reverse proxies like Cloudflare and kernel-level firewalls (XDP/eBPF + nftables) is not binary. Many production environments deploy both: Cloudflare for L7 application-layer protection and TLS termination, kernel firewalls for sub-millisecond L3/L4 filtering directly on the target server. Understanding where each technology excels prevents both over-spending on unnecessary upstream scrubbing and catastrophic gaps in coverage when attackers bypass edge filters.



How Cloudflare and Kernel Firewalls Operate at Different Network Layers

Cloudflare functions as a reverse proxy and CDN. When you point your DNS to Cloudflare's nameservers, HTTP/HTTPS requests hit Cloudflare's edge network first. Cloudflare inspects headers, payloads, and TLS handshakes before proxying legitimate traffic to your origin server. This model is powerful for:

  • L7 DDoS mitigation: detecting HTTP floods, slowloris, and application-specific exploits.
  • Web Application Firewall (WAF): blocking SQL injection, XSS, and OWASP Top 10 vulnerabilities.
  • TLS termination: offloading SSL/TLS handshakes and certificate management.
  • Global CDN: caching static assets at hundreds of edge locations.

However, Cloudflare only protects HTTP/HTTPS traffic by default. Non-HTTP protocols (game server UDP, SSH, custom TCP ports) require Cloudflare Spectrum or Magic Transit—premium add-ons priced per gigabyte or bandwidth commit, often starting at hundreds of dollars monthly. Furthermore, Cloudflare cannot prevent your origin IP from being discovered and attacked directly if an attacker bypasses the proxy (origin IP leak via DNS history, misconfigured email headers, or scanning).

Kernel firewalls, in contrast, run on the server itself, filtering packets at the earliest possible software hook: XDP (eXpress Data Path) operates at the network driver layer, even before the Linux kernel allocates a socket buffer (skb). This allows:

  • Protocol-agnostic filtering: TCP, UDP, ICMP, or any IP protocol on any port.
  • Stateless packet rate-limiting: XDP can drop or rate-limit packets in under a microsecond per packet, handling several million packets per second (pps) on modern hardware.
  • Stateful connection tracking: nftables (successor to iptables) with conntrack validates TCP handshakes, enforces SYN cookies, and applies per-connection rate limits.
  • No DNS dependency: protection is bound to the server's network interface, regardless of how traffic arrives.

The critical distinction: Cloudflare protects the path to your server; kernel firewalls protect the server itself. A comprehensive 2026 strategy often layers both, but for budget-conscious or non-HTTP workloads, kernel firewalls deliver immediate value without recurring bandwidth or feature-tier costs.

PAKKT.io exemplifies modern kernel firewall orchestration: a centralized SaaS panel that deploys and monitors XDP/eBPF + nftables rules across fleets of Linux servers, with real-time metrics and zero-conflict integration with existing Docker, fail2ban, or iptables-persistent setups.
Close-up of a modern datacenter server rack with fiber optic cables glowing cyan and blue, shallow depth of field, cables entering network interface cards, representing high-speed packet filtering at the kernel layer


Performance: Bandwidth, Latency, and Packet Processing Capacity

Cloudflare's edge network spans over 300 cities and absorbs terabits of attack traffic daily. For volumetric attacks (UDP floods, DNS amplification, memcached reflection), Cloudflare's scrubbing centers can absorb far more bandwidth than any single-server kernel firewall. If an attacker sends 100 Gbps to your origin IP, no amount of XDP magic will save the uplink—the pipe is saturated before packets reach your NIC.

Yet latency tells a different story. Every Cloudflare-proxied request incurs at least one additional network hop (client → Cloudflare edge → origin). For latency-sensitive applications—game servers with 20 ms tick rates, high-frequency trading APIs, real-time voice—this added RTT is measurable. Kernel firewalls add negligible latency: XDP processing overhead is typically sub-microsecond per packet, and nftables conntrack lookups are nanosecond-scale hash operations.

Packet-per-second (pps) capacity diverges sharply. A 10 Gbps link saturated by 64-byte packets delivers ~14.8 million pps. Cloudflare handles this upstream, but once traffic reaches your origin, the kernel must process it. A default Linux network stack without XDP begins dropping packets around 1–2 million pps per core. XDP, by bypassing the kernel's generic receive path, can sustain 10+ million pps on a single CPU core with optimized drivers (mlx5, i40e).

Metric Cloudflare (edge) XDP/eBPF (kernel)
Max volumetric mitigation Terabits (Tbps) Limited by server NIC + uplink
Packet processing speed N/A (upstream) Sub-microsecond per packet
Added latency ~5–50 ms (edge hop) <1 µs
Protocol coverage HTTP/HTTPS (Spectrum for UDP/TCP) All IP protocols

For workloads where the origin IP is never exposed (web apps behind Cloudflare with strict firewall rules allowing only Cloudflare IP ranges), kernel firewalls remain essential for defense-in-depth: blocking port scans, SSH brute-force, and internal lateral movement. For non-HTTP services (Minecraft on UDP 19132, SSH on TCP 22, custom game protocols), kernel firewalls are the primary DDoS defense, not a supplement.

Stateless vs. Stateful: XDP and nftables in Tandem

XDP programs are stateless by design—they evaluate each packet independently, making them blazingly fast but unable to track TCP connection state or apply burst limits across time windows. This is where nftables complements XDP:

nft add rule inet pakkt input tcp dport 25565 ct state new limit rate 50/second accept
nft add rule inet pakkt input tcp flags syn ct state new meter syn_flood { ip saddr limit rate 10/second } accept

The first rule limits new TCP connections to port 25565 (Minecraft Java) to 50 per second globally. The second uses a meter (dynamic set) to enforce per-source-IP SYN rate limits. Combined with XDP's global packet-per-second ceiling, this dual-layer approach blocks both unsophisticated UDP floods (XDP) and sophisticated SYN floods or slowloris attacks (nftables conntrack).

PAKKT orchestrates this automatically: a single XDP program per interface (the PAKKT Engine) driven by up to 256 BPF map rules (port range, protocol, rate_limit/block/allow_only), while the isolated inet pakkt nftables table handles stateful policies without conflicting with Docker's iptables rules or fail2ban's dynamic blacklists.


Abstract 3D visualization of network packets flowing through a transparent Linux kernel represented as layered cyan grids, with some packets being filtered and dropped, high-tech atmosphere with blue lighting


Cost Structure: Cloudflare Plans vs. Kernel Firewall Licensing

Cloudflare's Free tier includes unmetered DDoS mitigation for HTTP/HTTPS, a shared WAF, and basic CDN. The Pro plan ($20/month per zone) adds image optimization and advanced caching. Business ($200/month) unlocks custom WAF rules and PCI compliance. Enterprise (custom pricing, typically $5,000+/month) provides dedicated account management, SLA guarantees, and Spectrum/Magic Transit for non-HTTP protocols.

For a single web property, $20–$200/month is reasonable. For infrastructure teams managing dozens of servers—game server networks, SaaS backends, containerized microservices—the math changes. If you run 50 game servers (each on a different port or IP), you need either:

  • Cloudflare Spectrum: priced per gigabyte or bandwidth commit; a single 10 Gbps commit can cost $1,000+/month.
  • Kernel firewall per server: PAKKT pricing is €3/agent/month, so 50 agents = €150/month (~$165 USD), with zero bandwidth overage fees.

Open-source kernel firewalls (vanilla XDP + nftables) are free, but require deep Linux networking expertise, custom monitoring, and manual synchronization across servers. PAKKT bridges this gap: a centralized panel for fleet-wide rule deployment, GeoIP analytics, per-port metrics (TimescaleDB), and audit logs—operational simplicity at a predictable per-agent cost.

Hidden Costs: Bandwidth Metering and Origin Shielding

Cloudflare Free/Pro/Business plans do not charge bandwidth for cached or proxied traffic. However, if your origin pulls large uncached responses (video streams, software downloads, API payloads), you still pay your hosting provider's bandwidth cost. Cloudflare's CDN reduces this by caching, but cache-miss traffic hits your origin at full rate.

With kernel firewalls, bandwidth costs are identical to your hosting plan—no additional proxy tier. The firewall drops malicious packets before they consume application resources (CPU, memory, database connections), but legitimate traffic flows directly to your service. For high-throughput, low-margin workloads (public game servers, open-source mirrors), eliminating the CDN middle layer can simplify billing.



When to Use Cloudflare, Kernel Firewalls, or Both

Use Cloudflare if:

  • Your workload is HTTP/HTTPS web traffic (websites, REST APIs, SaaS dashboards).
  • You need global CDN for static assets (images, CSS, JS).
  • You require TLS termination and automatic certificate management (Let's Encrypt integration).
  • Your origin IP can remain hidden (strict firewall rules allowing only Cloudflare IP ranges).
  • You want L7 WAF for OWASP Top 10 without custom code.

Use kernel firewalls (XDP/eBPF + nftables) if:

  • Your service runs on non-HTTP protocols (game servers, VoIP, SSH, DNS, SMTP).
  • You need sub-millisecond latency (real-time game ticks, high-frequency APIs).
  • Your origin IP is publicly known (direct IP connections required, no DNS proxy).
  • You manage multiple servers/ports and want per-agent pricing instead of bandwidth tiers.
  • You require defense-in-depth even behind a CDN (block port scans, SSH brute-force, internal threats).

Use both (layered defense) if:

  • You run a web application + game server backend (e.g., a game launcher web portal + UDP game servers).
  • You want Cloudflare's WAF for the web tier and kernel firewalls for game/API servers on different ports.
  • Your threat model includes both volumetric DDoS (mitigated upstream by Cloudflare) and application-layer exploits (mitigated by nftables connection tracking).
  • You need failover resilience: if attackers discover your origin IP, kernel firewalls provide a last line of defense.

A practical 2026 pattern: deploy Cloudflare for your marketing website and customer dashboard (HTTPS, caching, WAF), while PAKKT Integrations (Pterodactyl, public API) protect your game server infrastructure with XDP rate-limiting and nftables SYN flood protection. This maximizes ROI: pay Cloudflare's $20/month for the web zone, pay PAKKT €3/agent/month for each game server, and avoid expensive Spectrum licenses.

Origin IP Protection: The Achilles' Heel of Cloud Proxies

Cloudflare's protection is effective only if attackers route through Cloudflare. If your origin IP leaks (via historical DNS records on SecurityTrails, email headers revealing the server IP, or brute-force scanning), attackers can bypass Cloudflare entirely and hit your server directly. Common leak vectors:

  • DNS history: tools like SecurityTrails archive old A records before you migrated to Cloudflare.
  • Email headers: emails sent from your server include Received: headers with the origin IP.
  • Subdomain enumeration: a misconfigured dev.example.com A record pointing directly to origin.
  • IPv6: Cloudflare proxies IPv4, but if your server has an IPv6 address not proxied, attackers can target that.

Best practice: combine Cloudflare proxy with a kernel firewall rule that drops all traffic except from Cloudflare IP ranges:

nft add set inet pakkt cloudflare_ips { type ipv4_addr; flags interval; }
nft add element inet pakkt cloudflare_ips { 173.245.48.0/20, 103.21.244.0/22, 103.22.200.0/22, ... }
nft add rule inet pakkt input ip saddr @cloudflare_ips accept
nft add rule inet pakkt input drop

This ensures that even if your origin IP is discovered, direct connections are rejected at the kernel level. PAKKT's dual-layer IP whitelist (XDP BPF map + nft rule) automates this synchronization across agents.



Operational Complexity: Deployment, Monitoring, and Updates

Cloudflare's appeal is zero-touch deployment for web traffic: change DNS, enable "Proxy" (orange cloud), done. No server-side agent, no kernel modules. Updates and rule changes happen in Cloudflare's dashboard and propagate globally within seconds.

Kernel firewalls require Linux root access and kernel 5.x or higher with XDP support. Manual XDP deployment involves:

clang -O2 -target bpf -c pakkt_engine.bpf.c -o pakkt_engine.bpf.o
ip link set dev eth0 xdp obj pakkt_engine.bpf.o sec xdp
bpftool map update name pakkt_rules key 0 value ...

Maintaining this across dozens of servers, ensuring rule consistency, and aggregating metrics quickly becomes untenable without orchestration. This is where centralized management platforms like PAKKT shine:

  • Lightweight Go agent: <5 MB RAM, <1% CPU, mTLS-authenticated 30s heartbeat.
  • Automatic XDP rule sync: edit a rule in the web panel, agents pull updates and reload BPF maps within 30 seconds.
  • Real-time metrics: per-port packet counts, GeoIP world map, top source IPs, stored in TimescaleDB for historical analysis.
  • Audit log: track who changed which rule when, critical for compliance (SOC 2, ISO 27001).
  • SHA256 self-update: agents verify binary integrity before updating, with garble obfuscation to resist reverse engineering.

The operational comparison in 2026 favors managed kernel firewall platforms for non-HTTP workloads. A sysadmin can deploy PAKKT to 100 game servers in under an hour (install agent, link to panel, deploy template), whereas manually configuring XDP + nftables + metrics + log aggregation on 100 servers is a multi-day project.

Integration with Existing Infrastructure

Cloudflare integrates seamlessly with DNS providers (Cloudflare Registrar, external registrars via NS delegation). Conflicts arise when mixing Cloudflare with other reverse proxies (e.g., running Cloudflare + AWS CloudFront leads to double proxying and latency spikes).

Kernel firewalls must coexist with Docker (iptables NAT rules), fail2ban (dynamic iptables INSERT), and iptables-persistent (restored on boot). PAKKT solves this by isolating rules in a dedicated inet pakkt nftables table, with priority hooks that execute before Docker's nat table and after fail2ban's dynamic chains. This zero-conflict design is critical for production environments where uninstalling existing tooling is not an option.

For panel integration, PAKKT Integrations with Pterodactyl v1.x are production-ready, enabling game server hosts to offer DDoS protection as a billable add-on. Pelican and WHMCS integrations are in development, while the public API allows custom automation (Terraform providers, Ansible playbooks).



Conclusion

Choosing between Cloudflare and kernel firewalls in 2026 depends on protocol requirements, latency sensitivity, and cost structure. Cloudflare excels at HTTP/HTTPS web protection with global CDN and L7 WAF, while XDP/eBPF + nftables deliver protocol-agnostic, sub-microsecond filtering directly on the server. For comprehensive infrastructure defense, layering both technologies—Cloudflare for web tiers, kernel firewalls for game servers and APIs—maximizes resilience. Centralized management platforms streamline kernel firewall operations, making enterprise-grade protection accessible at predictable per-agent pricing. Evaluate your workload's protocol mix and threat model to architect the optimal defense-in-depth strategy.



FAQ

Can I use Cloudflare and XDP/nftables kernel firewalls together on the same server?

Yes, and this is a recommended layered approach. Configure Cloudflare to proxy your HTTP/HTTPS traffic, then deploy kernel firewalls (XDP + nftables) on your origin server to drop all non-Cloudflare IPs and protect non-HTTP ports (SSH, game servers, custom APIs). Use nftables IP sets containing Cloudflare's published IP ranges to whitelist only proxied traffic, ensuring direct-to-origin attacks are blocked at the kernel level.

Does XDP packet filtering add latency compared to Cloudflare's edge mitigation?

XDP adds negligible latency—typically sub-microsecond per packet—because it processes packets at the network driver layer before the kernel allocates socket buffers. In contrast, Cloudflare's reverse proxy introduces at least one additional network hop (client → Cloudflare edge → origin), adding 5–50 ms RTT depending on geography. For latency-sensitive workloads like real-time game servers or high-frequency APIs, kernel firewalls preserve the direct client-to-server path while still providing DDoS mitigation.

How do I protect non-HTTP services if Cloudflare Free only covers web traffic?

Cloudflare Free and Pro plans proxy only HTTP/HTTPS by default. For UDP game servers, SSH, DNS, or custom TCP protocols, you need Cloudflare Spectrum (paid add-on with bandwidth commits) or deploy kernel firewalls directly on your server. XDP/eBPF with nftables supports all IP protocols and ports, with stateless rate-limiting in XDP and stateful connection tracking in nftables. Platforms like PAKKT.io centralize management of XDP + nftables rules across server fleets at €3/agent/month, providing a cost-effective alternative to Spectrum for multi-port infrastructure.

Protect your servers

Deploy PAKKT in 30 seconds

Dual-layer kernel protection. XDP + nftables. Driven from a central panel. 7-day free trial.