OpenStack Neutron CLI Commands: Creating IPv4 and IPv6 Subnets

OpenStack Neutron CLI Commands: Creating IPv4 and IPv6 Subnets

OpenStack CLI subnet commands for IPv4 and IPv6

Assumptions made here:

  • The public network has already been created
  • That by doing a openstack subnet list there are no existing subnets named public-v6 or public1
  • You have already installed the Openstack CLI client LINK using your preferred method.
  • You are not using the individual project CLI client for instance Neutron in this case but instead the common client.
  • That you are using the default gw of the first usable address in the subnet. If not you can manually select the gateway here --gateway 192.168.1.254

OpenStack CLI Commands

For IPv4

Run the following command to create an IPv4 subnet with an explicit DHCP allocation pool:

openstack-cli
openstack subnet create --network public --allocation-pool start=192.168.1.2,end=192.168.1.254 --subnet-range 192.168.1.0/24 public1

For IPv6 (SLAAC)

Run the following command to create an IPv6 SLAAC subnet on the same network:

openstack-cli
openstack subnet create --dhcp --network public --ip-version 6 --ipv6-address-mode slaac --subnet-range 2600:100:1:1::/64 public-v6

Confirmation of OpenStack CLI subnet Commands

You can confirm that you have created the subnets by using the OpenStack CLI subnet commands to show you your subnets. You will issue the following commands in order to the see the subnets from the CLI:

openstack-cli
jfarr@nertwork1:~$ openstack subnet list

+--------------------------------------+----------+--------------------------------------+-----------------+

| ID                                   | Name     | Network                              | Subnet          |

+--------------------------------------+----------+--------------------------------------+-----------------+

| 0dc86c16-f87b-4edf-b746-8832e7689444 | public1 | 75de19cb-cb43-42ff-97a2-847fc79fff3e | 192.168.0.0/24  |

Here you will see your subnet, if you want more information you can issue the following commands:

openstack-cli
openstack subnet show public1

Your output will be seen below:

openstack-cli
jfarr@nertwork1:~$ openstack subnet show public1

+-------------------------+--------------------------------------+

| Field                   | Value                                |

+-------------------------+--------------------------------------+

| allocation_pools        | 192.168.0.2-192.168.0.254            |

| cidr                    | 192.168.0.0/24                       |

| created_at              | 2017-12-05T19:51:53Z                 |

| description             |                                      |

| dns_nameservers         | 8.8.8.8                              |

| enable_dhcp             | True                                 |

| gateway_ip              | 192.168.0.1                          |

| host_routes             |                                      |

TRUNCATED

OpenStack CLI Commands Reference

Public subnets and networks do not actually mean public to the outside world in this guide. What they mean in this guide is that these networks can be accessed by anything outside of OpenStack that is routed to the OpenStack cluster. In this sense they are public networks.

>_ Engineering Discussion 2 Comments

+ Add Field Note ↓
  1. Having the legacy neutron subnet-create syntax side-by-side with the modern unified openstack subnet create --subnet-range CLI flags is super helpful when maintaining older Queens/Rocky clouds alongside Yoga.

  2. Don't forget --ipv6-ra-mode slaac --ipv6-address-mode slaac when creating the /64 IPv6 tenant subnet in Neutron so guest instances auto-configure their default gateway via Router Advertisements!

Leave a Technical Comment

Share CLI tips, hardware notes, or questions below. Inline backticks (`command`) are supported.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Engineering Notes