---
description: Cloudflare allows users to use their Cloudflare prefix to route traffic to a different service. Service bindings must be created on the parent account of the prefix.
title: Use BYOIP with CDN and Spectrum
image: https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/og.png?v=5802cf6385249cbf
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/byoip/llms.txt  
> Use this file to discover all available pages before exploring further.

# Use BYOIP with CDN and Spectrum

Last updated May 6, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

With [service bindings](https://developers.cloudflare.com/byoip/service-bindings/), CDN<sup>[1](#user-content-fn-1)</sup> customers using BYOIP can take the same prefix they have onboarded to Cloudflare and use it to selectively route traffic on a per-IP address basis to [Spectrum](https://developers.cloudflare.com/spectrum/)<sup>[2](#user-content-fn-2)</sup>, or vice versa. This means:

- You can upgrade individual IPs within a CDN prefix to a Spectrum IP. For example, if you have a CDN prefix 203.0.113.0/24, you can upgrade 203.0.113.1 to Spectrum.
- You can upgrade individual IPs within a Spectrum prefix to a CDN IP. For example, if you have a Spectrum prefix 203.0.113.0/24, you can upgrade 203.0.113.1 to CDN.

This guide will use the first example and consider a prefix that was onboarded to the CDN, with a few IPs upgraded to Spectrum.

## Before you begin

Cloudflare **strongly** recommends implementing service bindings through an **aggregated** CIDR block, as it is more efficient than adding discrete bindings for non-contiguous CIDR blocks.

<details>

<summary>

Example

</summary>

**CDN protected prefix:** <code>203.0.113.0/24</code>

**IPs to upgrade to Spectrum:**

<code>203.0.113.16</code><br> <code>203.0.113.17</code><br> <code>203.0.113.18</code><br> <code>203.0.113.19</code><br> <code>203.0.113.20</code><br> <code>203.0.113.21</code><br> <code>203.0.113.22</code><br> <code>203.0.113.23</code>

Add one discrete Spectrum service binding for <code>203.0.113.16</code> with a <code>/29</code> netmask.

</details>

Once a service binding is created (or deleted), it will take **four to six hours** to propagate across Cloudflare's global network. Services for the IP addresses in scope will likely be disrupted during this window.

Note

This guide assumes that the prefix is tied to a single Cloudflare account that has both CDN and Spectrum properties. If you are using [prefix delegations](https://developers.cloudflare.com/byoip/concepts/prefix-delegations/), the service bindings must be [created](#2-create-service-bindings) on the parent account.

---

## Prepare your IPs

### 1. Get account information

1. Log in to your Cloudflare account and get your [account ID](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/) and [authentication key or token](https://developers.cloudflare.com/fundamentals/api/get-started/). If using an [API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/), the permissions should include `Account` - `IP Prefixes` - `Edit`.
2. Make a `GET` request to the [List Services](https://developers.cloudflare.com/api/resources/addressing/subresources/services/methods/list/) endpoint and take note of the `id` associated with the Spectrum service.
3. Use the [List Prefixes](https://developers.cloudflare.com/api/resources/addressing/subresources/prefixes/methods/list/) endpoint and take note of the `id` associated with the prefix ( `cidr`) you will configure.

At this point, continuing the [example](#before-you-begin), you should have a mapping similar to the following:

| Variables | Description |
| --- | --- |
| `{service_id}` | The ID of the Spectrum service within Cloudflare. <br><br> Example: `969xxxxxxxx000xxx0000000x00001bf` |
| `{prefix_id}` | The ID of the CDN prefix (`203.0.113.0/24`) you want to configure. <br><br> Example: `6b25xxxxxxx000xxx0000000x0000cfc` |

4. To confirm you currently have a CDN service binding and that it spans across your entire prefix, make a `GET` request to the [List Service Bindings](https://developers.cloudflare.com/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/list/) endpoint. Replace the `{prefix_id}` in the URI path by the actual prefix ID you got from the previous step.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>IP Prefixes: Write</code>
- <code>IP Prefixes: Read</code>

</details>

*List Service Bindingsbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/addressing/prefixes/$PREFIX_ID/bindings" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

### 2. Create service bindings

Caution

Once a service binding is created (or deleted), it will take **four to six hours** to propagate across Cloudflare's global network. Services for the IP addresses in scope will likely be disrupted during this window.

1. Make a `POST` request to the [Create service binding](https://developers.cloudflare.com/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/create/) endpoint, indicating the IP address you want to bind to Spectrum. Specify the **corresponding network mask** as needed.

Continuing the example, `203.0.113.100/32` designates an IP address that is within the CDN prefix `203.0.113.0/24`.

Replace the `{prefix_id}` in the URI with your prefix ID from previous steps. Within the request body, the `cidr` value should correspond to the IP address or subnet that you are configuring for use with Spectrum.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>IP Prefixes: Write</code>

</details>

*Create Service Bindingbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/addressing/prefixes/$PREFIX_ID/bindings" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"cidr": "203.0.113.100/32",
		"service_id": "<SERVICE_ID>"
	}'
```

In the response body, the initial provisioning state should be `provisioning`.

```json
{
  "errors": [],
  "messages": [],
  "success": true,
  "result": {
    "cidr": "203.0.113.100/32",
    "id": "<SERVICE_BINDING_ID>",
    "provisioning": {
      "state": "provisioning"
      },
    "service_id": "<SERVICE_ID>",
    "service_name": "<SERVICE_NAME>"
  }
}
```

You can periodically check the service binding status using the [List Service Bindings](https://developers.cloudflare.com/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/list/) endpoint.

### 3. Verify all service bindings

After the propagation time (four to six hours), the [List Service Bindings](https://developers.cloudflare.com/api/resources/addressing/subresources/prefixes/subresources/service_bindings/methods/get/) endpoint should return all service bindings that are part of the prefix - in this case, CDN and Spectrum.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>IP Prefixes: Write</code>
- <code>IP Prefixes: Read</code>

</details>

*List Service Bindingsbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/addressing/prefixes/$PREFIX_ID/bindings" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

---

## Set up your Cloudflare services

### CDN

If you already use BYOIP with CDN, you might be able to skip this step. However, if you are using this guide to upgrade a few IPs from a Spectrum prefix to the CDN, consider the following sections on [address maps](#address-maps) and [DNS records](#dns-records).

Note

As described below, address maps and DNS records do not apply to Spectrum. To set up your Spectrum application with BYOIP, refer to [Spectrum](#spectrum).

#### Address maps

Use [address maps](https://developers.cloudflare.com/byoip/address-maps/) to specify which IPs should be used by Cloudflare in DNS responses when a record is [proxied](https://developers.cloudflare.com/dns/proxy-status/).

You can choose between two different scopes:

- Account-level: uses the address map for all proxied DNS records across all of the zones within an account.
- Zone-level: uses the address map for all proxied DNS records within a zone.

Note

If you need to map only specific subdomains (and not all proxied DNS records) to specific IP addresses, you can use a [Subdomain setup](https://developers.cloudflare.com/dns/zone-setups/subdomain-setup/).

1. In the Cloudflare dashboard, go to the **Address Maps** page. [Go to **Address maps** ↗](https://dash.cloudflare.com/?to=/:account/ip-addresses/proxy-ips)
2. Select **Create an address map**.
3. Choose the scope of the address map.
4. Add the zones and IP addresses that you want to map.
5. Name your address map.
6. Review the information and select **Save and Deploy**.

Use the [Create Address Map](https://developers.cloudflare.com/api/resources/addressing/subresources/address_maps/methods/create/) endpoint.

Make sure you have the correct Key/Token and permissions.

#### DNS records

While the DNS record proxy status and address map will determine how Cloudflare's authoritative DNS responds to requests for your hostnames, the IP addresses specified in `A`/`AAAA` records will determine [how Cloudflare reaches the configured origin](https://developers.cloudflare.com/fundamentals/concepts/how-cloudflare-works/#cloudflare-as-a-reverse-proxy).

Note

As you create the necessary DNS records, [Total TLS](https://developers.cloudflare.com/ssl/edge-certificates/additional-options/total-tls/) can help making sure that you have SSL/TLS certificates in place for all your hostnames.

To create a DNS record in the dashboard:

1. In the Cloudflare dashboard, go to the **DNS Records** page. [Go to **Records** ↗](https://dash.cloudflare.com/?to=/:account/:zone/dns/records)
2. Select **Add record**.
3. Choose an address ( `A`/ `AAAA`) [record type](https://developers.cloudflare.com/dns/manage-dns-records/reference/dns-record-types/).
4. Complete the required fields, setting the **Proxy status** to **proxied**.
5. Select **Save**.

To create records with the API, use a [POST request](https://developers.cloudflare.com/api/resources/dns/subresources/records/methods/create/). For field definitions, select a record type under the request body specification.

<details>

<summary>

Example

</summary>

| Type | Name | IP address | Proxy status | TTL |
| --- | --- | --- | --- | --- |
| <code>A</code> | <code>www</code> | <code>203.0.113.150</code> | <code>Proxied</code> | <code>Auto</code> |

At this point, if an address map for a zone <code>example.com</code> specifies that Cloudflare should use <code>203.0.113.100</code> for proxied records and the above record exists in the same zone, you can expect the following:

1. Cloudflare responds to DNS requests for <code>www.example.com</code> with <code>203.0.113.100</code>.
2. Cloudflare proxies requests through the CDN and then routes the requests to the origin server <code>203.0.113.150</code>.
3. As the HTTP response egresses the Cloudflare network back to the client side, the source IP address of the response becomes <code>203.0.113.100</code> (the IP address that the HTTP request originally landed on).

</details>

Note

Having the same IP address as ingress IP (defined in the address map) and origin IP (listed in the DNS record) will not cause any loops.

<details>

<summary>

Example

</summary>

Assuming <code>203.0.113.100</code> was also the origin IP, the DNS record would look like the following:

| Type | Name | IP address | Proxy status | TTL |
| --- | --- | --- | --- | --- |
| <code>A</code> | <code>www</code> | <code>203.0.113.100</code> | <code>Proxied</code> | <code>Auto</code> |

</details>

### Spectrum

UDP applications

Spectrum UDP applications are supported with BYOIP, including [CDN and Spectrum service bindings](https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/). However, they are [not currently supported with Magic Transit service bindings](https://developers.cloudflare.com/spectrum/reference/limitations/#udp).

Configuring Spectrum to use your own IP address is only possible via the [Cloudflare API](https://developers.cloudflare.com/api/resources/spectrum/).

The `origin_direct` field takes the origin IP address, while `edge_ips` allows you to define which IP address from your BYOIP prefix Cloudflare should use to process requests for your Spectrum application.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>Zone Settings Write</code>

</details>

*Create Spectrum application using a name for the originbash*

```bash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/spectrum/apps" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '[
		{
				"protocol": "tcp/22",
				"dns": {
						"type": "CNAME",
						"name": "ssh.example.com"
				},
				"origin_direct": [
						"tcp://192.0.2.1:22"
				],
				"proxy_protocol": "off",
				"ip_firewall": true,
				"tls": "full",
				"edge_ips": {
						"type": "static",
						"ips": [
								"203.0.113.18"
						]
				},
				"traffic_type": "direct"
		}
	]'
```

---

## (Optional) Add layer 7 functionality

Leverage other features according to your needs. For example:

- [Cache](https://developers.cloudflare.com/cache/)
- [WAF custom rules](https://developers.cloudflare.com/waf/custom-rules/)
- [Security analytics](https://developers.cloudflare.com/waf/analytics/security-analytics/)

## Footnotes

1. Layer 7 HTTP-based [↩](#user-content-fnref-1)
2. Layer 4 or Layer 7 HTTP with custom ports [↩](#user-content-fnref-2)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/#page","headline":"Use BYOIP with CDN and Spectrum","description":"Cloudflare allows users to use their Cloudflare prefix to route traffic to a different service. Service bindings must be created on the parent account of the prefix.","url":"https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/","inLanguage":"en","image":"https://developers.cloudflare.com/byoip/service-bindings/cdn-and-spectrum/og.png?v=5802cf6385249cbf","dateModified":"2026-05-06","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["DNS","Integration"]}
```
