Skip to content

GreTunnel

Source: src/Cloudflare/MagicTransit/GreTunnel.ts

A Magic Transit / Magic WAN GRE tunnel between Cloudflare and a customer router.

Requires a Magic Transit or Magic WAN subscription on the account — accounts that are not onboarded receive a typed MagicTransitNotOnboarded error (Cloudflare code 1012).

The tunnel name is its routing identity (unique, ≤15 chars) — changing it triggers a replacement, as does changing bgp (the update API cannot modify BGP settings). Everything else is updated in place via PUT.

Basic tunnel

const tunnel = yield* Cloudflare.GreTunnel("office", {
name: "office-gre-1",
cloudflareGreEndpoint: "203.0.113.1",
customerGreEndpoint: "198.51.100.1",
interfaceAddress: "10.213.0.8/31",
});

Tunnel with health checks and MTU

const tunnel = yield* Cloudflare.GreTunnel("office", {
name: "office-gre-1",
cloudflareGreEndpoint: "203.0.113.1",
customerGreEndpoint: "198.51.100.1",
interfaceAddress: "10.213.0.8/31",
mtu: 1476,
ttl: 64,
healthCheck: { enabled: true, rate: "mid", type: "reply" },
});
yield* Cloudflare.MagicStaticRoute("office-route", {
prefix: "10.100.0.0/24",
nexthop: "10.213.0.9",
priority: 100,
});