Create a GRE tunnel
Creates a new GRE tunnel. Use ?validate_only=true as an optional query parameter to only run validation without persisting changes.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Accepted Permissions (at least one required)
Body ParametersJSON
A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side of the tunnel. Select the subnet from the following private IP space: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255.
The name of the tunnel. The name cannot contain spaces or special characters, must be 15 characters or less, and cannot share a name with another GRE tunnel.
True if automatic stateful return routing should be enabled for a tunnel, false otherwise.
A 127 bit IPV6 prefix from within the virtual_subnet6 prefix space with the address being the first IP of the subnet and not same as the address of virtual_subnet6. Eg if virtual_subnet6 is 2606:54c1:7:0:a9fe:12d2::/127 , interface_address6 could be 2606:54c1:7:0:a9fe:12d2:1:200/127
Create a GRE tunnel
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/magic/gre_tunnels \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"cloudflare_gre_endpoint": "203.0.113.1",
"customer_gre_endpoint": "203.0.113.1",
"interface_address": "192.0.2.0/31",
"name": "GRE_1",
"automatic_return_routing": true,
"description": "Tunnel for ISP X",
"interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127"
}'{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "c4a7362d577a6c3019a474fd6f485821",
"cloudflare_gre_endpoint": "203.0.113.1",
"customer_gre_endpoint": "203.0.113.1",
"interface_address": "192.0.2.0/31",
"name": "GRE_1",
"automatic_return_routing": true,
"bgp": {
"customer_asn": 0,
"extra_prefixes": [
"string"
],
"md5_key": "md5_key"
},
"bgp_status": {
"state": "BGP_DOWN",
"tcp_established": true,
"updated_at": "2019-12-27T18:11:19.117Z",
"bgp_state": "bgp_state",
"cf_speaker_ip": "192.168.1.1",
"cf_speaker_port": 1,
"customer_speaker_ip": "192.168.1.1",
"customer_speaker_port": 1
},
"created_on": "2017-06-14T00:00:00Z",
"description": "Tunnel for ISP X",
"health_check": {
"direction": "bidirectional",
"enabled": true,
"rate": "low",
"target": {
"effective": "203.0.113.1",
"saved": "203.0.113.1"
},
"type": "request"
},
"interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127",
"modified_on": "2017-06-14T05:20:00Z",
"mtu": 0,
"ttl": 0
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"id": "c4a7362d577a6c3019a474fd6f485821",
"cloudflare_gre_endpoint": "203.0.113.1",
"customer_gre_endpoint": "203.0.113.1",
"interface_address": "192.0.2.0/31",
"name": "GRE_1",
"automatic_return_routing": true,
"bgp": {
"customer_asn": 0,
"extra_prefixes": [
"string"
],
"md5_key": "md5_key"
},
"bgp_status": {
"state": "BGP_DOWN",
"tcp_established": true,
"updated_at": "2019-12-27T18:11:19.117Z",
"bgp_state": "bgp_state",
"cf_speaker_ip": "192.168.1.1",
"cf_speaker_port": 1,
"customer_speaker_ip": "192.168.1.1",
"customer_speaker_port": 1
},
"created_on": "2017-06-14T00:00:00Z",
"description": "Tunnel for ISP X",
"health_check": {
"direction": "bidirectional",
"enabled": true,
"rate": "low",
"target": {
"effective": "203.0.113.1",
"saved": "203.0.113.1"
},
"type": "request"
},
"interface_address6": "2606:54c1:7:0:a9fe:12d2:1:200/127",
"modified_on": "2017-06-14T05:20:00Z",
"mtu": 0,
"ttl": 0
},
"success": true
}