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
- Create an IPv4 public advertised prefix.
- 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
In the Google Cloud console, go to Bring your own IP.
Click the public delegated prefix that you want to subdivide.
Click Create sub-prefix.
Enter a Name and optional Description for the sub-prefix.
Select a Prefix length for the sub-prefix.
Select IP addresses for the sub-prefix.
Select a Project for the sub-prefix. The IP addresses are made available in this project only.
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
In the Google Cloud console, go to Bring your own IP.
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
In the Google Cloud console, go to Bring your own IP.
Click the public delegated prefix or sub-prefix that you want to create IP addresses in.
Click Create addresses.
Select the Prefix length.
Select the range of IP addresses you want to create.
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.