openstack Verified current stable Not installed? Cloud Infrastructure

Openstack / Create Subnet In Network

Create Subnet In Network

Creates a new subnet within an existing network in OpenStack.

$
Terminal
openstack subnet create --network <network_id_or_name> --subnet-range 192.168.0.0/24 <subnet_name>

When To Use

When establishing a new subnet for an application environment requiring IP address allocation.

Pro Tip

Use the `--allocation-pool` flag to define a specific range of IPs to be allocated, ensuring client devices receive appropriate addresses during DHCP operations.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
openstack subnet create --network <network_id_or_name> --subnet-range 192.168.0.0/24 <subnet_name>

Anatomy of Output

Understanding the result

+--------------+--------------------------------------+ Header: Subnet Creation Result

Indicates the start of the output information.

| id | 12345678-1234-5678-1234-567812345678 | Subnet ID

Unique identifier for the newly created subnet.

| name | subnet-abc | Subnet Name

Human-readable name for the subnet.

| ip_version | 4 | IP Version

Indicates the IP version in use.

| cidr | 192.168.0.0/24 | CIDR Notation

Shows the subnet's address range via CIDR format.

| dns_nameservers | 8.8.8.8 | DNS Servers

Lists configured DNS servers for the subnet.

Troubleshooting

Common pitfalls

ERROR: InvalidInput: Subnet range overlaps with existing subnets.

Solution: Ensure the specified range does not conflict with existing subnets within the network.

ERROR: NetworkNotFound: Network 'net-unknown' not found.

Solution: Verify the network ID or name is correct and exists in the OpenStack environment.

ERROR: InvalidCIDR: Invalid CIDR '192.168.0.0/24'.

Solution: Check the CIDR notation to ensure proper formatting and valid ranges.

Command Breakdown

What each part is doing

openstack
Base Command
The executable that performs this operation. Here it runs Openstack before the shell applies any redirect operators.
<network_id_or_name>
network id or name
The value supplied for network id or name.
<subnet_name>
subnet name
The value supplied for subnet name.
--network
Command Option
Tool-specific option used by this command invocation.
--subnet-range
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.