← Lab /Systems

Cloudflare built a high-performance VPN for WARP using Linux NAT and packet marks

Their Linux-based VPN implementation can securely and efficiently egress arbitrary user packets for millions of mobile clients.

Systems Cloudflare Research 29 Oct 2025 Method Deployed evidence

Published as “How to build your own VPN, or: the history of WARP”

Why it matters

The write-up shows that a production-grade VPN can be built from standard Linux networking components, but IPv4 scarcity forces redesign for further scaling.

Summary

The post describes how Cloudflare created a custom VPN for its WARP service by leveraging Linux's Netfilter, nftables, and conntrack to perform source NAT and packet marking. They route traffic from a TUN device through a single public IP address, using conntrack marks to separate WARP client traffic from other traffic. The implementation runs on Cloudflare edge servers and serves millions of mobile users, demonstrating that a standard Linux stack can be used for large-scale VPN egress. However, the authors note that IPv4 address exhaustion limits scalability and will require a different approach in the future.

What they found 2

  1. All connections from WARP are clearly identified and can be firewalled separately from other traffic.

    “All connections from WARP are clearly identified and can be firewalled separately from locally-originated connections or other nodes on our network.”

  2. A single nftables rule can perform source NAT for the entire private subnet used by VPN clients.

    “nft add rule ip nat postrouting oifname "eth0" ip saddr 10.0.0.0/8 snat to 198.51.100.42”

Caveats 4

  • The authors admit that using one IPv4 address per server does not scale due to address exhaustion and cost.
  • They state that future work is needed to share IPs across many servers, indicating the current solution has scalability limits.
  • Requires a dedicated public IPv4 address per edge server, which is costly and does not scale.
  • The approach relies on IPv4 NAT; IPv6 deployment or IP sharing is not addressed in this version.

What’s new here 3

  • Use of nftables source NAT combined with conntrack marks to identify and route WARP client traffic.
  • Implementation of a TUN device-based VPN front-end written in Rust (boringtun) integrated with Linux routing.
  • Demonstration of a production-grade VPN serving millions of mobile clients on Cloudflare edge infrastructure.