osc network subnet create
Creates a subnet on a network.
OpenStack Networking does not try to derive the correct IP version from the CIDR. If you do not specify the gateway_ip
attribute, OpenStack Networking allocates an address from the CIDR for the gateway for the subnet.
To specify a subnet without a gateway, set the gateway_ip
attribute to null
in the request body. If you do not specify the allocation_pools
attribute, OpenStack Networking automatically allocates pools for covering all IP addresses in the CIDR, excluding the address reserved for the subnet gateway. Otherwise, you can explicitly specify allocation pools as shown in the following example.
When you specify both the allocation_pools
and gateway_ip
attributes, you must ensure that the gateway IP does not overlap with the allocation pools; otherwise, the call returns the Conflict (409)
response code.
A subnet can have one or more name servers and host routes. Hosts in this subnet use the name servers. Devices with IP addresses from this subnet, not including the local subnet route, use the host routes.
Specify the ipv6_ra_mode
and ipv6_address_mode
attributes to create subnets that support IPv6 configurations, such as stateless address autoconfiguration (SLAAC), DHCPv6 stateful, and DHCPv6 stateless configurations.
A subnet can optionally be associated with a network segment when it is created by specifying the segment_id
of a valid segment on the specified network. A network with subnets associated in this way is called a routed network. On any given network, all of the subnets must be associated with segments or none of them can be. Neutron enforces this invariant. Currently, routed networks are only supported for provider networks.
Normal response codes: 201
Error response codes: 400, 401, 403, 404, 409
Usage: osc network subnet create [OPTIONS] --ip-version <IP_VERSION> --network-id <NETWORK_ID>
Options:
-
--allocation-pools <JSON>
— Allocation pools withstart
andend
IP addresses for this subnet. If allocation_pools are not specified, OpenStack Networking automatically allocates pools for covering all IP addresses in the CIDR, excluding the address reserved for the subnet gateway by default -
--cidr <CIDR>
— The CIDR of the subnet -
--description <DESCRIPTION>
— A human-readable description for the resource. Default is an empty string -
--dns-nameservers <DNS_NAMESERVERS>
— List of dns name servers associated with the subnet. Default is an empty list -
--dns-publish-fixed-ip <DNS_PUBLISH_FIXED_IP>
— Whether to publish DNS records for IPs from this subnet. Default isfalse
Possible values:
true
,false
-
--enable-dhcp <ENABLE_DHCP>
— Indicates whether dhcp is enabled or disabled for the subnet. Default istrue
Possible values:
true
,false
-
--gateway-ip <GATEWAY_IP>
— Gateway IP of this subnet. If the value isnull
that implies no gateway is associated with the subnet. If the gateway_ip is not specified, OpenStack Networking allocates an address from the CIDR for the gateway for the subnet by default -
--host-routes <JSON>
— Additional routes for the subnet. A list of dictionaries withdestination
andnexthop
parameters. Default value is an empty list -
--ip-version <IP_VERSION>
— The IP protocol version. Value is4
or6
-
--ipv6-address-mode <IPV6_ADDRESS_MODE>
— The IPv6 address modes specifies mechanisms for assigning IP addresses. Value isslaac
,dhcpv6-stateful
,dhcpv6-stateless
Possible values:
dhcpv6-stateful
,dhcpv6-stateless
,slaac
-
--ipv6-ra-mode <IPV6_RA_MODE>
— The IPv6 router advertisement specifies whether the networking service should transmit ICMPv6 packets, for a subnet. Value isslaac
,dhcpv6-stateful
,dhcpv6-stateless
Possible values:
dhcpv6-stateful
,dhcpv6-stateless
,slaac
-
--name <NAME>
— Human-readable name of the resource. Default is an empty string -
--network-id <NETWORK_ID>
— The ID of the network to which the subnet belongs -
--prefixlen <PREFIXLEN>
— The prefix length to use for subnet allocation from a subnet pool. If not specified, thedefault_prefixlen
value of the subnet pool will be used -
--segment-id <SEGMENT_ID>
— The ID of a network segment the subnet is associated with. It is available whensegment
extension is enabled -
--service-types <SERVICE_TYPES>
— The service types associated with the subnet -
--subnetpool-id <SUBNETPOOL_ID>
— The ID of the subnet pool associated with the subnet -
--tenant-id <TENANT_ID>
— The ID of the project that owns the resource. Only administrative and users with advsvc role can specify a project ID other than their own. You cannot change this value through authorization policies -
--use-default-subnetpool <USE_DEFAULT_SUBNETPOOL>
— Whether to allocate this subnet from the default subnet poolPossible values:
true
,false