IPsec Anti-Replay Protection, Anycast Tunnels, and Endpoint Configuration
Why anycast IPsec tunnels conflict with anti-replay, how Cloudflare recommends configuring replay protection, and how to fix drops on common routers.
This page summarises Cloudflare documentation on IPsec anti-replay protection for anycast IPsec tunnels used with Cloudflare WAN, Magic Transit, and related products. If your site-to-site tunnel loses packets, flaps on health checks, or logs replay warnings even though you changed settings in the dashboard, the usual cause is a mismatch between Cloudflare’s default (replay protection off) and anti-replay still enabled on your tunnel endpoint (router or firewall).
Replay attacks: what IPsec anti-replay is meant to stop
Section titled “Replay attacks: what IPsec anti-replay is meant to stop”A replay attack is when someone records legitimate traffic and sends the same packets again to trigger an unwanted effect.
Replay attacks occur when a malicious actor intercepts and records a packet ↗︎, and later sends the recorded packet to the target network again with an intent that benefits the attacker.
— Cloudflare, Anti-replay protection
IPsec anti-replay protection assigns each Encapsulating Security Payload (ESP) packet a sequence number. The receiver remembers which numbers it has already accepted and only accepts new numbers inside a replay window (often 64–1024 packets), not strict single-file order, so normal reordering and loss on the Internet do not break the tunnel.
IPsec anti-replay protection works similarly to the prevention example in the scenario above. The sender assigns each IPsec packet a sequence number. The receiver tracks which sequence numbers it has already seen and only accepts packets in a small window around the highest value the receiver has seen, and the window is typically 64-1024 packets.
— Cloudflare, Anti-replay protection
That design assumes one sender and one receiver sharing one sequence counter. Anycast IPsec breaks that assumption.
Cloudflare default: disable anti-replay on anycast IPsec tunnels
Section titled “Cloudflare default: disable anti-replay on anycast IPsec tunnels”For Cloudflare WAN and Magic Transit with anycast IPsec tunnels, Cloudflare recommends disabling anti-replay protection on the tunnel. The platform disables replay protection by default in the dashboard and API.
If you use Cloudflare WAN and anycast IPsec tunnels, we recommend disabling anti-replay protection. Cloudflare disables this setting by default. However, you can enable it through the API or the Cloudflare dashboard for devices that do not support disabling it, including Cisco Meraki, Velocloud, and AWS VPN Gateway.
— Cloudflare, Anti-replay protection
The same recommendation applies to Magic Transit; see Anti-replay protection (Magic Transit). Tunnel endpoint steps live under Configure tunnel endpoints (Cloudflare WAN) and Configure tunnel endpoints (Magic Transit).
| Side | Default / recommended | When to turn replay protection on at Cloudflare |
|---|---|---|
| Cloudflare tunnel | Replay protection off (default) | Endpoint cannot disable anti-replay (e.g. Meraki, VeloCloud, AWS VPN Gateway) |
| Your router / firewall | Anti-replay off or replay window 0 | Match Cloudflare; if you enable replay on Cloudflare, align endpoint per vendor guide |
Anycast IPsec: why anti-replay on the endpoint drops packets
Section titled “Anycast IPsec: why anti-replay on the endpoint drops packets”Anycast means any packet for a tunnel may be processed by any of many servers in many data centers. No single machine sees the full sequence state for traffic leaving Cloudflare toward your network.
Standard IPsec anti-replay protection assumes a single sender and a single receiver. The sender stores a sequence number in memory and increments it for every packet. The receiver tracks which sequence numbers it has already processed.
Cloudflare’s anycast architecture does not fit this model. Because Cloudflare WAN uses anycast, any packet can be processed by any of thousands of servers across hundreds of data centers.
— Cloudflare, Anti-replay protection
From your router’s perspective, ESP packets arrive with different sequence counters (many senders), which looks like replays or out-of-order traffic. The endpoint drops them.
This is the most common IPsec issue. Anti-replay protection expects packets to arrive in sequence from a single sender. Cloudflare’s anycast architecture means tunnel traffic originates from thousands of servers, each with its own sequence counter. This causes your tunnel endpoint to drop packets as out-of-order.
— Cloudflare, Troubleshoot IPsec tunnels
Fix on the customer side (recommended): disable anti-replay on the tunnel endpoint, or set the replay window to 0. Details are in Troubleshoot tunnel health and Troubleshoot IPsec tunnels.
If replay protection is enabled on Cloudflare instead, it works only Cloudflare → customer network; Cloudflare does not pin customer → Cloudflare traffic to one server for anti-replay in the same way (Anti-replay protection).
Security trade-offs: tunnel mode vs transport mode
Section titled “Security trade-offs: tunnel mode vs transport mode”Cloudflare stresses that anti-replay at IPsec matters far more in transport mode (host-to-host) than in tunnel mode site-to-site VPNs.
IPsec anti-replay protection is extremely important for transport mode - host-to-host or even app-to-app IPsec. In transport mode, an attacker has a relatively easy time identifying the encrypted protocol and identifying which packets to replay if the protocol is even subject to replay attacks. Cloudflare WAN, however, uses tunnel mode, not transport mode, which makes a successful replay attack much harder.
— Cloudflare, Anti-replay protection
Reasons packet-level replay is harder in this architecture include full encryption of the inner packet, rekeying invalidating old replays, upper-layer protocols (TCP, TLS, SSH) handling duplicates, and shorter paths through dedicated ISP links and nearby Cloudflare data centers (Anti-replay protection).
Symptoms: tunnel flaps, steady health-check failures, and log messages
Section titled “Symptoms: tunnel flaps, steady health-check failures, and log messages”Intermittent loss and unstable tunnel health
Section titled “Intermittent loss and unstable tunnel health”Typical signs when anti-replay is enabled on your router but Cloudflare has replay protection off:
- IPsec tunnel flaps between healthy and down
- Intermittent packet loss; traffic may work, then stall without config changes
- Logs:
replay check failed,invalid sequence number, orinvalid SPI
Cause summary from Troubleshoot tunnel health:
Anti-replay protection is enabled on your router. IPsec anti-replay protection expects packets to arrive in sequence from a single sender.
Cloudflare’s anycast architecture means your tunnel traffic can originate from thousands of servers across hundreds of data centers. Each server maintains its own sequence counter, causing packets to arrive out-of-order from your router’s perspective.
Health checks fail at a low, steady rate (95–100% pass)
Section titled “Health checks fail at a low, steady rate (95–100% pass)”When Replay protection is off in Cloudflare (default) but the endpoint still enforces anti-replay, you may see mostly working traffic with a small, steady fraction of failed health checks (Troubleshoot IPsec tunnels):
The anti-replay setting on your tunnel endpoint does not match the replay protection setting on your Cloudflare tunnel. Your device still enforces anti-replay protection and drops some Encapsulating Security Payload (ESP) packets as replays.
This can happen even if you have turned off anti-replay on your device. On some devices, the option to turn it off does not take effect or reverts to its previous value.
Check Point example when Cloudflare has replay off but the gateway still checks replays (Check Point):
Encryption failure: Warning - possible replay attack
Make the device anti-replay setting match the Cloudflare tunnel replay protection setting: either turn off anti-replay on the device (preferred), or turn replay protection on in Cloudflare if the device cannot disable it (Troubleshoot IPsec tunnels).
Endpoint configuration: disable anti-replay or set window to 0
Section titled “Endpoint configuration: disable anti-replay or set window to 0”Align both sides. Cloudflare configures replay protection per IPsec tunnel in Networking → Connectors → IPsec/GRE tunnels → Security settings (Check Point).
Vendor-specific settings (high level)
Section titled “Vendor-specific settings (high level)”| Vendor | Approach in Cloudflare docs | Doc |
|---|---|---|
| Fortinet | set anti-replay disable (global or per policy) |
Fortinet |
| Sophos Firewall | set vpn ipsec-performance anti-replay window-size 0 (restarts IPsec; global effect) |
Sophos Firewall |
| Check Point | disable_replay_check true on Security Gateway object via GuiDBedit (gateway-wide) |
Check Point |
| Azure VPN Gateway | Set disableIPSecReplayProtection to true via Azure REST API; Cloudflare doc says leave replay on in dashboard for that scenario |
Microsoft Azure VPN Gateway |
| Cisco Meraki, VeloCloud, AWS VPN Gateway | Cannot reliably disable on device | Enable Replay protection in Cloudflare dashboard |
Fortinet example (Fortinet):
config system global set anti-replay disableendSophos (Sophos Firewall):
set vpn ipsec-performance anti-replay window-size 0When the endpoint cannot disable anti-replay
Section titled “When the endpoint cannot disable anti-replay”Enable Replay protection on the Cloudflare tunnel (dashboard: edit tunnel → enable Replay protection → update). Same path is described in Troubleshoot tunnel health. For Cisco IOS/IOS-XE invalid SPI issues, Cloudflare also documents:
configure terminalcrypto isakmp invalid-spi-recoveryexitCheck Point and Cloudflare both off
Section titled “Check Point and Cloudflare both off”After setting Check Point disable_replay_check to true and installing policy, turn Turn on replay protection off for each tunnel to that gateway in the Cloudflare dashboard (Check Point). Verify on the gateway:
grep -n "disable_replay_check" "$FWDIR/database/myself_objects.C"Expected: :disable_replay_check: (true). That confirms policy install; it does not by itself prove drops stopped (Check Point).
Common mistakes
Section titled “Common mistakes”- Leaving anti-replay on the router while Cloudflare has replay protection off (default)—the usual cause of drops and flaky health checks.
- Assuming a GUI toggle worked when the device still enforces anti-replay (Troubleshoot IPsec tunnels).
- Setting Check Point
disable_replay_checkon the Management Server object instead of the Security Gateway object (no effect) (Check Point). - Enabling Cloudflare replay protection for throughput-sensitive links without accepting single-server routing and lower performance (Anti-replay protection).
- Updating only one of several tunnels to the same firewall; one tunnel left mismatched can still drop packets (Check Point).
- For Palo Alto with health check issues, Cloudflare’s tunnel-health table also suggests Request health check type and disabling anti-replay (Troubleshoot tunnel health).
Tunnel instability specifically tied to anti-replay: see Troubleshoot tunnel health and IPsec troubleshooting (WAN).
How to check this on your site
Section titled “How to check this on your site”-
In the Cloudflare dashboard, open your IPsec tunnel under Networking → Connectors → IPsec/GRE tunnels and note whether Replay protection is on or off (Configure tunnel endpoints).
-
On your tunnel endpoint, confirm anti-replay is disabled or the replay window is 0 using your vendor’s method (Fortinet, Sophos Firewall, Check Point).
-
Compare Cloudflare tunnel health and health-check pass rate with router logs; replay-related messages should stop after a matched configuration (Troubleshoot IPsec tunnels).
-
After changes, force IKE/IPsec renegotiation if your vendor requires it (for example Check Point
vpn tu), then confirm bidirectional traffic and dashboard health (Check Point). -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.