Create IPv4 sub-prefixes and IPv4 addresses

This page describes how to divide your IPv4 public delegated prefix and create BYOIP addresses to use with Google Cloud resources. You can create IPv4 BYOIP addresses from a public delegated prefix or sub-prefix.

If you want to divide an IPv6 public delegated prefix, see Create IPv6 sub-prefixes.

Before you begin

  1. Create an IPv4 public advertised prefix.
  2. Create an IPv4 public delegated prefix.

Roles

To get the permissions that you need to complete the tasks in this guide, ask your administrator to grant you the Compute Public IP Admin (roles/compute.publicIpAdmin) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Create sub-prefixes

You can divide a public delegated prefix into smaller IP address ranges by creating a sub-prefix. A sub-prefix is a public delegated prefix that has a public delegated prefix parent.

A sub-prefix name can't be changed without deleting and recreating the resource. For this reason, we recommend that you create generic names that won't need to change—for example, sub-203-0-113-0-28, where sub denotes the resource type and 203-0-113-0-28 denotes the specific prefix and prefix length.

A public delegated prefix can be sub-delegated up to three times from a public advertised prefix. For example, if you have a public advertised prefix with IP address range 203.0.113.0/24, you can do the following:

  • Create a public delegated prefix with IP address range 203.0.113.0/25 from the public advertised prefix.
  • Create a sub-prefix with IP address range 203.0.113.0/26 that has the previous public delegated prefix as its parent.
  • Create a sub-prefix with IP address range 203.0.113.0/27 that has the previous sub-prefix as its parent.

At this point, you cannot create further sub-prefixes that have the 203.0.113.0/27 sub-prefix as a parent.

Console

  1. In the Google Cloud console, go to Bring your own IP.

    Go to Bring your own IP

  2. Click the public delegated prefix that you want to subdivide.

  3. Click Create sub-prefix.

  4. Enter a Name and optional Description for the sub-prefix.

  5. Select a Prefix length for the sub-prefix.

  6. Select IP addresses for the sub-prefix.

  7. Select a Project for the sub-prefix. The IP addresses are made available in this project only.

  8. Click Create.

gcloud

To create a sub-prefix from a public delegated prefix, use the public-delegated-prefixes delegated-sub-prefixes create command

gcloud compute public-delegated-prefixes \
    delegated-sub-prefixes \
    create SUB_PREFIX_NAME \
    --range=SUB_PREFIX_RANGE \
    --public-delegated-prefix=PDP_NAME \
    --public-delegated-prefix-region=PDP_REGION \
    --delegatee-project=PROJECT_ID

Replace the following:

  • SUB_PREFIX_NAME: a name for the sub-prefix that you are creating.

  • SUB_PREFIX_RANGE: the IP address range for the sub-prefix that you are creating.

  • PDP_NAME: the parent public delegated prefix or sub-prefix that contains the sub-prefix you are creating.

  • PDP_REGION: the region of the public delegated prefix or sub-prefix that contains the sub-prefix you are creating.

  • PROJECT_ID: an optional project ID for the sub-prefix. The following describes the behavior for this value:

    • If you specify a value, the IP addresses are available only in the specified project.

    • If you don't use --delegatee-project, the IP addresses are available in the same project as the sub-prefix's parent public delegated prefix or sub-prefix.

List prefixes

You can list all public advertised prefixes and public delegated prefixes (including sub-prefixes) in a project.

Console

  1. In the Google Cloud console, go to Bring your own IP.

    Go to Bring your own IP

  2. All public advertised prefixes, public delegated prefixes, and sub-prefixes are displayed.

gcloud

To list public delegated prefixes, including sub-prefixes, use the public-delegated-prefixes list command.

gcloud compute public-delegated-prefixes list

Create IP addresses

When you create addresses from a public delegated prefix or sub-prefix, you cannot further sub-divide that prefix.

The IP addresses that you create from a public delegated prefix or sub-prefix are static external IP addresses and can be regional or global. All IP addresses in the public delegated prefix or sub-prefix are made available; there is no reserved network address or broadcast address. For example, if you create IP addresses from a /28 public delegated prefix or sub-prefix, 16 IP address resources are created.

You can list all static external IP addresses. This list includes IP addresses that you have brought to Google Cloud and IP addresses that are provided by Google.

BYOIP addresses are created with names in a consistent format. For example, 203.0.113.144 is assigned the name address-203-0-113-144.

Console

  1. In the Google Cloud console, go to Bring your own IP.

    Go to Bring your own IP

  2. Click the public delegated prefix or sub-prefix that you want to create IP addresses in.

  3. Click Create addresses.

  4. Select the Prefix length.

  5. Select the range of IP addresses you want to create.

  6. Click Create addresses.

gcloud

To create IP addresses from a public delegated prefix or sub-prefix, use the public-delegated-prefixes delegated-sub-prefixes create command.

gcloud compute public-delegated-prefixes \
    delegated-sub-prefixes \
    create ADDRESSES_NAME \
    --create-addresses \
    --public-delegated-prefix=PDP_NAME \
    --public-delegated-prefix-region=PDP_REGION

Replace the following:

  • ADDRESSES_NAME: a name for the group of addresses that you are creating.

  • PDP_NAME: the public delegated prefix or sub-prefix that you are creating IP addresses for.

  • PDP_REGION: the region of the public delegated prefix or sub-prefix that you are creating IP addresses for.

What's next