Skip to main content

bgp_prefixes

Creates, updates, deletes, gets or lists a bgp_prefixes resource.

Overview

Namebgp_prefixes
TypeResource
Idcloudflare.addressing.bgp_prefixes

Fields

The following fields are returned by SELECT queries:

Fetch BGP Prefix response

NameDatatypeDescription
idstringIdentifier of BGP Prefix. (example: 7009ba364c7a5760798ceb430e603b74)
asnintegerAutonomous System Number (ASN) the prefix will be advertised under.
asn_prepend_countintegerNumber of times to prepend the Cloudflare ASN to the BGP AS-Path attribute
auto_advertise_withdrawbooleanDetermines if Cloudflare advertises a BYOIP BGP prefix even when there is no matching BGP prefix in the Magic routing table. When true, Cloudflare will automatically withdraw the BGP prefix when there are no matching BGP routes, and will resume advertising when there is at least one matching BGP route.
bgp_signal_optsobject
cidrstringIP Prefix in Classless Inter-Domain Routing format. (example: 192.0.2.0/24)
created_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
modified_atstring (date-time) (example: 2014-01-01T05:20:00.12345Z)
on_demandobject

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, prefix_id, bgp_prefix_idRetrieve a single BGP Prefix according to its identifier
listselectaccount_id, prefix_idList all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to control which specific subnets are advertised to the Internet. It is possible to advertise subnets more specific than an IP Prefix by creating more specific BGP Prefixes.
createinsertaccount_id, prefix_id, cidrCreate a BGP prefix, controlling the BGP advertisement status of a specific subnet. When created, BGP prefixes are initially withdrawn, and can be advertised with the Update BGP Prefix API.
editupdateaccount_id, prefix_id, bgp_prefix_idUpdate the properties of a BGP Prefix, such as the on demand advertisement status (advertised or withdrawn).

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
bgp_prefix_idstring
prefix_idstringThe IP prefix ID.

SELECT examples

Retrieve a single BGP Prefix according to its identifier

SELECT
id,
asn,
asn_prepend_count,
auto_advertise_withdraw,
bgp_signal_opts,
cidr,
created_at,
modified_at,
on_demand
FROM cloudflare.addressing.bgp_prefixes
WHERE account_id = '{{ account_id }}' -- required
AND prefix_id = '{{ prefix_id }}' -- required
AND bgp_prefix_id = '{{ bgp_prefix_id }}' -- required
;

INSERT examples

Create a BGP prefix, controlling the BGP advertisement status of a specific subnet. When created, BGP prefixes are initially withdrawn, and can be advertised with the Update BGP Prefix API.

INSERT INTO cloudflare.addressing.bgp_prefixes (
cidr,
account_id,
prefix_id
)
SELECT
'{{ cidr }}' /* required */,
'{{ account_id }}',
'{{ prefix_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Update the properties of a BGP Prefix, such as the on demand advertisement status (advertised or withdrawn).

UPDATE cloudflare.addressing.bgp_prefixes
SET
asn_prepend_count = {{ asn_prepend_count }},
auto_advertise_withdraw = {{ auto_advertise_withdraw }},
on_demand = '{{ on_demand }}'
WHERE
account_id = '{{ account_id }}' --required
AND prefix_id = '{{ prefix_id }}' --required
AND bgp_prefix_id = '{{ bgp_prefix_id }}' --required
RETURNING
errors,
messages,
result,
success;