Prefix lists let you centrally manage frequently used CIDR blocks and reference them in security group rules and route entries across accounts. Changes to a prefix list automatically propagate to all referencing resources.
Common use cases for prefix lists include:
Centrally manage company egress IPs: A company accesses multiple ECS instances over the internet. Without a prefix list, each security group rule must be updated individually when the egress IP changes. With a prefix list, you update the IP once, and all referencing security group rules sync automatically.
Centrally maintain partner IP ranges: When your business communicates with partner IP ranges, you often add the same routes to multiple route tables. A prefix list eliminates this repetition — edit the list once, and all referencing route tables update automatically.
Limits
Gateway route tables and Basic Edition Transit Routers cannot reference prefix lists.
Prefix lists are regional resources. You can use, reference, or share a prefix list only within the region where it was created.
A prefix list cannot contain both IPv4 and IPv6 CIDR blocks.
You must specify the maximum number of entries when you create a prefix list.
A referenced prefix list consumes the quota of the referencing resource. VPC route tables and ECS security groups consume quota based on the maximum number of entries. TR route tables consume quota based on the actual number of entries. For example, a prefix list with a maximum of 50 entries but only 20 actual entries consumes 50 quota units in a VPC route table or security group, but only 20 in a TR route table.
When you create a Gateway Endpoint for a cloud service in a region for the first time, the system automatically creates a prefix list containing the service's IP ranges and references it in the VPC route table with the next hop pointing to the Gateway Endpoint. You cannot reference, modify, delete, or share this system prefix list. In the console, its Owner is displayed as System Account.
Manage prefix lists
Console
Create a prefix list
Go to the VPC Prefix List page in the VPC console. Select a region in the top navigation bar, and then click Create Prefix List.
In the Create Prefix List panel, configure the following parameters:
Select an IP Version (IPv4/IPv6).
Set the Maximum Entries. This value determines quota consumption in VPC route tables and security groups. You can modify it after creation.
For example, a prefix list with a maximum of 50 entries consumes 50 route entries or 50 security group rules in quota, even if only 20 entries exist.
Quota reference: By default, a VPC route table supports up to 200 custom route entries, and a security group supports up to 200 rules.
Configure Prefix List Entries. You can use one of the following methods: Manual Input, Batch Import, or Clone from Another List. You can clone entries from a prefix list in another region, but not from a shared or system prefix list.
Add or delete entries
On the details page of the prefix list, go to the Entry tab:
To add entries, click Create Prefix List.
To delete entries, click Delete in the Actions column of an entry, or select multiple entries and click Delete in Batches.
View referencing resources
On the details page of the prefix list, click the Association tab to view all resources that reference it.
Delete a prefix list
To delete a prefix list, find it in the list and click Delete in the Actions column. You can also click Delete on the details page.
Before you delete a prefix list, make sure that it is not referenced by any resources or shared with other accounts.
API
Call CreateVpcPrefixList to create a prefix list.
Call ModifyVpcPrefixList to add or delete entries.
Call GetVpcPrefixListAssociations to view resources that reference a prefix list.
Call DeleteVpcPrefixList to delete a prefix list.
Before you delete a prefix list, make sure that it is not referenced by any resources or shared with other accounts.
Terraform
Resource: alicloud_vpc_prefix_list
# Specify the region.
provider "alicloud" {
region = "cn-hangzhou"
}
# Create a prefix list.
resource "alicloud_vpc_prefix_list" "example_pl" {
prefix_list_name = "example_pl_name"
ip_version = "IPV4" # IP version
max_entries = 50 # Maximum number of entries
entrys {
cidr = "10.0.1.0/24" # Entry 1
}
entrys {
cidr = "10.0.2.0/24" # Entry 2
}
}Reference a prefix list
You can reference a prefix list in a VPC route table, a Transit Router (TR) route table, or an ECS security group. Changes to the prefix list automatically apply to all referencing resources.
In a VPC route table
You can reference a prefix list when adding a custom route entry to a VPC route table. Note the following:
Avoid route conflicts with existing entries. If a conflict exists, you cannot reference the prefix list. If a conflict occurs after referencing, see Resolve entry conflicts after referencing a prefix list.
The maximum number of entries, not the actual count, consumes the VPC route table's custom route entry quota. To reduce quota risk, decrease the maximum, merge adjacent IP ranges, or remove unused entries.
Console
Go to the details page of the route table. On the tab, click Add Route Entry and configure the following parameters:
Destination CIDR Block: Select VPC Prefix List from the drop-down list and then select the prefix list that you want to reference.
Next Hop Type: Select a next hop type and an instance.
API
Call CreateRouteEntry and set the DestinationCidrBlock parameter to the ID of the prefix list.
Terraform
Resource: alicloud_route_entry
# Specify the region.
provider "alicloud" {
region = "cn-hangzhou"
}
# Add a route entry to a VPC route table. The destination of the route entry is a prefix list.
resource "alicloud_route_entry" "example" {
route_table_id = "vtb-bp1pa1mwgfd6rqxfxxxxx" # The ID of the VPC route table.
destination_cidrblock = "pl-bp1fnjzxkk2m6qrwxxxxx" # The destination CIDR block. Set this parameter to the ID of the prefix list.
nexthop_type = "Ecr" # The next hop type.
nexthop_id = "ecr-assoc-stwhaft9a371nxxxxx" # The ID of the next hop instance.
}In a TR route table
You can reference a prefix list in an Enterprise Edition TR route table. The system automatically adds route entries for all CIDR blocks in the prefix list. Note the following:
If route propagation is enabled for the TR, the system automatically propagates the route entries that correspond to the prefix list to other network instances.
Route entries from the prefix list cannot conflict with existing TR route table entries. See Route compatibility for conflict rules. If a conflict prevents referencing, or occurs after referencing, see Resolve entry conflicts after referencing a prefix list.
The actual number of entries in the prefix list counts against the TR route table quota. To avoid exceeding the quota, merge adjacent IP ranges or remove unused entries.
Console
Associate a prefix list
Go to the details page of the TR route table, click the CIDR Block tab, and then click Associate With Route Prefix.
Route Prefix ID: Select the prefix list that you want to reference.
Blackhole Route:
Yes: Traffic that matches the prefix list is dropped.
No: Traffic that matches the prefix list is forwarded to the specified Next Hop.
Filter route entries
Go to the details page of the TR route table, click the Route Entry tab, and filter by Route Prefix ID to view routes added from a prefix list.
Disassociate a prefix list
When you disassociate a prefix list, the system automatically removes all related route entries from the Enterprise Edition TR route table. Before you disassociate a prefix list, migrate your service traffic to prevent network interruptions.
Go to the Basic Settings page of the TR route table and click the CIDR Block tab. Find the prefix list and click Delete in the Actions column.
API
Associate a prefix list: Call CreateTransitRouterPrefixListAssociation to reference a prefix list in the route table of an Enterprise Edition TR.
Filter route entries that correspond to a prefix list: Call ListTransitRouterPrefixListAssociation. In the response, use the
PrefixListIdparameter to filter the route entries that are added from a prefix list.Disassociate a prefix list: Call DeleteTransitRouterPrefixListAssociation to disassociate a prefix list from the route table of an Enterprise Edition TR.
Terraform
Resource: alicloud_cen_transit_router_prefix_list_association
# Specify the region.
provider "alicloud" {
region = "cn-hangzhou"
}
# Reference a prefix list in a Transit Router.
resource "alicloud_cen_transit_router_prefix_list_association" "example" {
prefix_list_id = "pl-bp1fnjzxkk2m6qrwxxxxx" # The ID of the prefix list.
transit_router_id = "tr-bp1czv20pflygguoxxxxx" # The ID of the Transit Router.
transit_router_table_id = "vtb-bp1v7079o4dwrkgpxxxxx" # The ID of the route table of the Transit Router.
next_hop_type = "BlackHole" # The next hop type.
next_hop = "BlackHole" # The ID of the next hop instance.
}In an ECS security group
You can reference a prefix list when configuring inbound or outbound security group rules.
Console
The following example adds an inbound security group rule. Go to the security group details page in the ECS console. On the Rules > Inbound tab, click Add Rule and configure the following parameters:
Source: Select Prefix List from the drop-down list and then select the prefix list that you want to reference.
Other parameters: Configure other parameters as required.
API
To add an inbound security group rule, call AuthorizeSecurityGroup and set the
SourcePrefixListIdparameter to the ID of the prefix list.To add an outbound security group rule, call AuthorizeSecurityGroupEgress and set the
DestPrefixListIdparameter to the ID of the prefix list.
Terraform
Resources: alicloud_security_group, alicloud_security_group_rule
# Specify the region.
provider "alicloud" {
region = "cn-hangzhou"
}
# Specify a security group.
resource "alicloud_security_group" "sg_example" {
security_group_name = "sg_example_name"
vpc_id = "vpc-bp1d00iurwfx3pcxxxxx" # The ID of the VPC.
}
# Reference a prefix list when you create a security group rule.
resource "alicloud_security_group_rule" "sg_rule_pl_example" {
security_group_id = alicloud_security_group.sg_example.id
type = "ingress"
ip_protocol = "tcp"
policy = "accept"
port_range = "8080/8080"
prefix_list_id = "pl-bp1fnjzxkk2m6qrxxxxxx" # The ID of the VPC prefix list.
}Resolve entry conflicts
After you reference a prefix list in a VPC route table or a TR route table, if you modify the prefix list and the change conflicts with an existing route entry, the change does not take effect.
On the Association tab of the prefix list details page, you can view conflict details. The Status for the resource with the conflict is Disassociated. Hover over the Status to view the conflicting entries in the ErrorMessage.
You can resolve the conflict in one of two ways:
Before you modify a route entry, make sure that your services are not affected.
Option 1: Modify the prefix list. Delete the conflicting entry from the prefix list. After you delete the entry, the system automatically reapplies the prefix list to all resources that reference it.
Option 2: Modify the route table. Delete the conflicting route entry from the route table. Then, manually reapply the prefix list until the status changes from Disassociated to Delivered.
To manually reapply a prefix list:
Console
Go to the VPC Prefix List page in the VPC console. Select a region in the top navigation bar, and then click the ID of the prefix list.
Click the Association tab, find the associated resource, and click Retry in the Actions column.
API
Call RetryVpcPrefixListAssociation to reapply the prefix list.
Terraform
Terraform does not support reapplying a prefix list without modifying its entries.
Share a prefix list
Sharing a prefix list lets multiple accounts reference the same CIDR blocks in security groups or routes, reducing maintenance overhead and configuration errors.
In the following example, Account A (the owner) shares a prefix list with Account B (the principal).
An owner can share prefix lists with any Alibaba Cloud account or restrict sharing to accounts within their resource directory.
Console
Enable sharing
This section describes how to share a prefix list with any account. To share resources only within a resource directory, see Share resources only within a resource directory.
Log on to the Resource Management console with the owner account and go to the Resource Sharing > Shared by Me page. Select the region of the resource that you want to share from the top navigation bar, and then click Create Resource Share. Perform the following steps:
Step 1: Enter a Resource Share Name. In the Resources section, select VPC Prefix List from the drop-down list, and then select the prefix lists that you want to share.
Step 2: The system selects the
AliyunRSDefaultPermissionPrefixListpermission by default.Step 3: Set Principal Scope to All Accounts and Method to Add Manually. Enter the Alibaba Cloud account ID of the principal, and then click Add.
Step 4: Review the configurations and click Confirm.
Log on to the Alibaba Cloud console as the principal and accept the sharing invitation:
Go to the Resource Sharing > Shared with Me page in the Resource Management console.
In the top navigation bar, select the region of the shared resource, find the target resource share, and click Accept in the Status column.
After you accept the invitation, you can access the shared prefix list. Invitations for new resources added to this resource share are accepted by default.
Go to the VPC Prefix List page in the VPC console. Select the region of the shared prefix list in the top navigation bar. You can view the received prefix lists. The Owner column is displayed as Shared.
You can now reference the shared prefix list in your VPC route tables, TR route tables, and ECS security groups. Reference a prefix list.
Manage shared prefix lists and principals
The prefix list owner can view, add, or remove shared prefix lists and principals:
Log on to the Resource Management console with the owner account and go to the Resource Sharing > Shared by Me page. In the top navigation bar, select the region where the shared prefix list is located.
On the Resources I Share page, you can perform the following actions:
View shared prefix lists: Click the Shared Resources tab.
View principals of a shared prefix list: Click the Principals tab.
Click the Resource Shares tab, find the target resource share, and click its ID.
Click the Resources or Principals tab to view the shared prefix lists and principals within this resource share.
If the Status on the Resources and Principals tabs is Associated, the resource and principal are successfully associated.
On the details page of the resource share, click Edit Resource Share in the upper-right corner. You can perform the following actions within this resource share:
Add or remove shared prefix lists: In Step 1, select or clear the check boxes of the prefix lists.
Add or remove principals: In Step 3, add or remove account IDs.
After you review the configurations, in Step 4 of the Edit Resource Share page, click Confirm.
API
Enable sharing
Method 1: Share with any account
Use the credentials of the prefix list owner to call CreateResourceShare to create a resource share. Make sure that the
AllowExternalTargetsparameter is set toTrue.Use the credentials of the prefix list principal to call ListResourceShareInvitations to query received resource invitations, and then call AcceptResourceShareInvitation to accept a resource sharing invitation.
Method 2: Share only within a resource directory
Before you begin, make sure that the prefix list owner and principal are members of the same resource directory.
Use the credentials of the management account of the resource directory to call EnableSharingWithResourceDirectory to enable resource sharing within the resource directory.
Use the credentials of the prefix list owner to call CreateResourceShare to create a resource share. Make sure that the
AllowExternalTargetsparameter is set toFalse.
Manage shared prefix lists and principals
As the prefix list owner, call the following operations to view shared prefix lists and principals:
Call ListSharedResources to view shared prefix lists.
Call ListSharedTargets to view the principals of shared prefix lists.
As the prefix list owner, call the following operations to manage shared prefix lists and principals within a resource share:
Call ListResourceShareAssociations to view the prefix lists or principals in a resource share.
Call AssociateResourceShare to add a shared prefix list or principal to a resource share.
Call DisassociateResourceShare to remove a shared prefix list or principal from a resource share.
Terraform
Terraform supports sharing prefix lists only within a resource directory, not with any account. Before you begin, make sure that the management account of the resource directory has enabled sharing for the resource directory.
Resources: alicloud_resource_manager_resource_share, alicloud_resource_manager_shared_resource, alicloud_resource_manager_shared_target
Use the credentials of the prefix list owner to enable sharing:
# Specify the region.
provider "alicloud" {
region = "cn-hangzhou"
}
# Specify the name of the resource share.
resource "alicloud_resource_manager_resource_share" "example_unit" {
resource_share_name = "example_unit_name"
}
# Specify the prefix list to be shared.
resource "alicloud_resource_manager_shared_resource" "example_vsw" {
resource_share_id = alicloud_resource_manager_resource_share.example_unit.id
resource_id = "pl-bp18t4lsc3e4yd6xxxxx" # The ID of the prefix list to be shared.
resource_type = "PrefixList" # The resource type is PrefixList.
}
# Specify the principal of the shared prefix list.
resource "alicloud_resource_manager_shared_target" "example_target" {
resource_share_id = alicloud_resource_manager_resource_share.example_unit.id
target_id = "101xxxxxxxxxxxxxxx" # The UID of the prefix list principal.
}More information
Billing
The prefix list feature is free of charge.
Supported regions
Area | Regions |
Asia Pacific - China | China (Hangzhou), China (Shanghai), China (Nanjing - Local Region, Closing Down), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Zhongwei), China (Hong Kong), China (Wuhan - Local Region), and China (Fuzhou - Local Region, Closing Down) |
Asia Pacific - Others | Japan (Tokyo), South Korea (Seoul), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), and Malaysia (Johor) |
Europe & Americas | Germany (Frankfurt), UK (London), France (Paris), US (Silicon Valley), US (Virginia), and Mexico |
Middle East | UAE (Dubai) and SAU (Riyadh - Partner Region) |
Quotas
Quota name | Description | Default limit | Adjustable |
vpc_quota_prefixlist_num | The maximum number of prefix lists that you can create with an Alibaba Cloud account. | 10 | Yes. To request a quota increase, go to the Quota Management page or Quota Center. |
vpc_quota_prefixlist_cidr_num_per_prefixlist | The maximum number of CIDR entries per prefix list. | 50 | |
vpc_quota_prefixlist_accept_shared_prefixlist_num | The maximum number of shared prefix lists that a resource principal can accept. | 100 | |
vpc_quota_prefixlist_share_user_num_per_prefixlist | The maximum number of resource principals with which you can share a prefix list. | 10 |
For resource sharing quotas, see Limits on resource sharing.