Creating a subnet
You can use the following methods to create a subnet.
A subnet is a logical subdivision of a VCN. Each subnet consists of a contiguous range of IP addresses that do not overlap with other subnets in the VCN.
To create a subnet, you must have already created a virtual cloud network (VCN) that this subnet will be part of.
- Open the navigation menu, click Networking, and then click Virtual cloud networks.
- Click the name of the VCN you're interested in.
- Click Create Subnet.
In the Create Subnet dialog box, specify the resources to associate with
the subnet (for example, a route table). By default, the subnet is created in
the current compartment, and you choose the resources from the same compartment.
Click the Click here link in the dialog box if you want to enable
compartment selection for the subnet and each of those resources. Enter the
- Create in Compartment: If you've enabled compartment selection, specify the compartment where you want to put the subnet.
- Name: A friendly name for the subnet. It doesn't have to be unique, and it cannot be changed later in the Console (but you can change it with the API). Avoid entering confidential information.
- Regional or AD-specific subnet: Oracle recommends creating only regional subnets, which means that the subnet can contain resources in any of the region's availability domains. If you instead choose Availability Domain-Specific (the only type of subnet that Oracle originally offered), you must also specify an availability domain. This choice means that any instances or other resources later created in this subnet must also be in that availability domain.
- IPv4 CIDR Block: A single, contiguous CIDR block for the subnet (for example, 172.16.0.0/24). Ensure that it's within the cloud network's CIDR block and doesn't overlap with any other subnets. You can change the size of this CIDR block later. See Allowed VCN Size and Address Ranges. For reference, here's a CIDR calculator.
- IPv6 Prefixes: You can request an Oracle-allocated IPv6 /64 prefix, or enter BYOIPv6 or ULA prefixes. You can have a maximum of three IPv6 prefixes in a subnet. Once you have assigned an IPv6 prefix to a VCN, it must always have at least one IPv6 prefix assigned to it. This option is available for VCNs in all commercial and government regions, provided the VCN is already enabled for IPv6. For more information, see IPv6 Addresses.
- Route Table: The route table to associate with the subnet. If you've enabled compartment selection, under Route Table Compartment, you must specify the compartment that contains the route table.
- Private or public subnet: This controls whether VNICs in the subnet can have public IP addresses. For more information, see Access to the Internet.
- Use DNS Hostnames in this Subnet:
This option is available only if you provided a DNS
label for the VCN during creation. The option is required for assignment of DNS
hostnames to hosts in the subnet, and also when you plan to use the VCN's
default DNS feature (called the Internet and VCN Resolver). If the check
box is selected, you can specify a DNS label for the subnet, or let the Console generate one for you. The dialog box
automatically displays the corresponding DNS Domain Name for the subnet
<subnet_DNS_label>.<VCN_DNS_label>.oraclevcn.com). For more information, see DNS in Your Virtual Cloud Network.
- DHCP Options: The set of DHCP options to associate with the subnet. If you've enabled compartment selection, under DHCP Options Compartment, you must specify the compartment that contains the set of DHCP options.
- Security Lists: One or more security lists to associate with the subnet. If you've enabled compartment selection, you must specify the compartment that contains the security list.
- Tags: If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you are not sure whether to apply tags, skip this option (you can apply tags later) or ask your administrator.
- Click Create.
The subnet is then created and displayed on the Subnets page in the compartment you chose.
Use the network vcn create command and required parameters to create a subnet:
oci network subnet create --cidr-block cidr-block --compartment-id ocid --vcn-id ocid ... [OPTIONS]
For a complete list of flags and variable options for CLI commands, see the Command Line Reference.
Run the CreateSubnet operation to create a subnet.