To route traffic between Cloudflare's global network and your origin network, Cloudflare WAN wraps your original packets inside an outer packet — a process called encapsulation. The outer packet carries your traffic across the Internet to its destination, where it is unwrapped (decapsulated) and delivered.
Cloudflare WAN uses two encapsulation protocols: Generic Routing Encapsulation (GRE) and IPsec. GRE is stateless and simpler to configure but does not encrypt traffic. IPsec encrypts traffic and authenticates the source, providing stronger security. Both create tunnels — logical point-to-point connections between Cloudflare and your network. Cloudflare sets up tunnel endpoints on global network servers inside your network namespace, and you set up tunnel endpoints on routers at your data center.
To accommodate additional header data introduced by encapsulation, you must adjust the maximum segment size (MSS) to comply with the standard Internet routable maximum transmission unit (MTU), which is 1500 bytes.
For instructions, refer to Set maximum segment size.
This diagram illustrates the flow of traffic with Cloudflare WAN.
sequenceDiagram accTitle: Tunnels and encapsulation accDescr: This diagram shows the flow of traffic with Cloudflare WAN. participant A as Client machine participant B as Cloudflare Cloudflare WAN participant C as Origin router A->>B: Payload <br> Protocol <br> IP header Note left of A: Ingress <br> traffic B->>C: Payload <br> Protocol <br> IP header <br> GRE <br> IP header C->>A: IP header <br> Protocol <br> Payload Note right of C: Egress <br> traffic
Traditional tunnels connect two fixed endpoints — one device on each side. Cloudflare WAN uses a different model: anycast IP addresses for Cloudflare's tunnel endpoints. In the anycast model, any server in any Cloudflare data center can receive traffic and must be capable of encapsulating and decapsulating packets for any tunnel. This means your tunnel is not tied to a single Cloudflare server — traffic is handled by whichever data center is closest to the source.
This works with GRE tunnels because the GRE protocol is stateless. Cloudflare processes each packet independently without requiring any negotiation or coordination between tunnel endpoints. Tunnel endpoints bind to IP addresses but not to specific devices. Any device that can strip off the outer headers and then route the inner packet can handle any GRE packet sent over the tunnel.
For IPsec tunnels, the customer's router negotiates the creation of an IPsec tunnel with Cloudflare using the Internet Key Exchange (IKE) protocol. Because IPsec is stateful (it requires shared keys and session parameters), one Cloudflare server handles the initial negotiation, then propagates the tunnel details (traffic selectors, keys, etc.) across all Cloudflare data centers. The result is that any Cloudflare server can handle traffic for that IPsec tunnel, even though only one server negotiated the setup.
Cloudflare's anycast architecture provides a conduit to your tunnel for every server in every data center on Cloudflare's global network. The following image shows this architecture.
flowchart LR
accTitle: Anycast tunnel
accDescr: Multiple servers in data center preparing packets to send through anycast tunnel.
a(User)
subgraph 1
direction LR
b(Cloudflare global <br> network server)
c(Cloudflare global <br> network server)
d(Cloudflare global <br> network server)
e(Cloudflare global <br> network server)
f(Cloudflare global <br> network server)
g(Cloudflare global <br> network server)
h(Cloudflare global <br> network server)
end
subgraph 2
i("Acme router <br> 198.51.100.1")
j("FTP server <br> (203.0.113.100)")
end
subgraph 3
x("Acme router <br> 198.51.100.1")
z("FTP server <br> (203.0.113.100)")
end
a --> 1== Cloudflare anycast GRE <br> single endpoint ==>i --> j
1== Cloudflare anycast IPsec <br> single endpoint ==>x --> z
IPsec ↗ is a group of protocols that work together to set up encrypted connections between devices. It helps keep data you send over public networks secure. Organizations often use IPsec to set up Virtual Private Networks (VPNs), and it works by encrypting IP packets and authenticating the source where the packets come from.
For information on how to set up an IPsec tunnel, refer to Configure tunnel endpoints. To learn more about the configuration parameters Cloudflare WAN uses to create an IPsec tunnel, keep reading.
Cloudflare WAN uses the following stages to establish an IPsec tunnel:
- Initial Exchange (
IKE_SA_INIT): IKE peers negotiate parameters for the IKE Security Association (SA) and establish a shared secret for key derivation, and when relevant, signal support for post-quantum key exchange with RFC 9370 ↗. When downgrade protection is enabled, Cloudflare also sends anIKE_SA_INIT_FULL_TRANSCRIPT_AUTHnotification during this exchange to signal support for full transcript authentication. After this exchange, the peers have a secure communication channel but they have not yet authenticated each other. - Intermediate Exchange (
IKE_INTERMEDIATE): If both peers support RFC 9370, they perform an additional key exchange using ML-KEM (Module-Lattice-based Key-Encapsulation Mechanism), a post-quantum key exchange specified in draft-ietf-ipsecme-ikev2-mlkem ↗. This creates a hybrid shared secret by combining a secret derived from classical Diffie-Hellman (established during theIKE_SA_INIT) with post-quantum ML-KEM to protect against harvest-now, decrypt-later ↗ attacks. - Auth Exchange (
IKE_AUTH): Using the keys established from both theIKE_SA_INITand theIKE_INTERMEDIATEexchange, IKE peers mutually authenticate each other. After authentication, they establish the IKE security association (SA). Next, the peers negotiate and establish an IPsec tunnel, known as a Child SA. - Rekeying: Periodically, or through manual intervention, IKE SAs can be rekeyed to generate new SAs with fresh keys for the session. This rekey operation is performed for both the IKE SA (to refresh the control plane) and the Child SAs (to refresh the data plane). When a hybrid exchange is in use (RFC 9370), the rekey process for the IKE SA will once again perform the parallel classical (DH) and post-quantum (ML-KEM) exchanges to ensure continued quantum resistance.
In summary, IKEv2 creates an IKE SA that uses certain cryptographic transforms. It then uses that IKE SA to create a Child SA which itself uses certain cryptographic transforms. The following configuration section details which of these transforms Cloudflare WAN currently supports for IKE SAs and Child SAs.