Create Openstack network and subnet

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

In this part of the Openstack Deep Learning series, we will introduce the creation of Openstack networks and subnets using the Openstack command line interface. Finally we took a look:

Use CLI to add SSH key pair to OpenStack

How to add flavor to OpenStack using CLI

Add images to Openstack Glance

Here, I will show you how to create a provider network, one with VLAN and the other without VLAN. This guide is based on Openstack Ocata version and OpenStack Neutron network service.

Assumptions: You are running an Openstack setup. How to setup Openstack from scratch will be covered in another tutorial.

What is a provider network?

Before launching an instance on Openstack, the necessary virtual network infrastructure must be created. Instance use provider (external) The network connected to the physical network infrastructure by Layer 2 (bridging/switching). The network includes DHCP server Provide an IP address for the instance.

The following figure shows an overview of the provider network (source: Opentack website):

Create a provider network (on the controller node)

How to create a provider network (no VLAN) on the controller node:

openstack network create  --share --external 
  --provider-physical-network provider 
  --provider-network-type flat provider

How to create a provider network on the controller node (with VLAN):

openstack network create --share --external 
--provider-physical-network provider 
--provider-network-type vlan 
--provider-segment 203 provider

Description of options used:

--share:  allows all projects to use the virtual network.
--external: defines the virtual network to be external, for internal network, use --internal.
--provider-physical-network provider : connect the flat virtual network to the flat (native/untagged) physical network
--provider-network-type: specifies network type, flat or vlan
--provider-segment: defines vlan id

replace 203 With your VLAN ID. This VLAN ID will be used on the compute node.

Use the following command to confirm that the network has indeed been successfully created:

$ openstack network list

You should get output similar to the following:

Create Openstack network and subnet on Openstack CLI

Your ml2_conf.ini file should contain the following line:

[ml2_type_flat]
flat_networks = provider

Create an IPv4 subnet on the provider network:

Now that you have added the provider network, the next step is to define the subnet for the network.

openstack subnet create --subnet-range 192.168.10.0/24 
--gateway 192.168.10.1 --network provider 
--allocation-pool start=192.168.10.10,end=192.168.10.200 
--dns-nameserver 8.8.4.4 provider-v4

If you have a public IP pool, please replace it with 192.168.10.0.

Create an IPv6 subnet on the provider network (optional)

If you wish to assign an IPv6 address to the launched instance, create an IPv6 subnet as follows:

openstack subnet create --subnet-range fd00:203:0:113::/64 
--gateway fd00:203:0:113::1 --ip-version 6 
--ipv6-address-mode slaac --network provider 
--dns-nameserver 2001:4860:4860::8844 provider-v6

Confirm settings:

[[email protected] ~(keystone)]$ openstack subnet list

With these settings, you should be ready to configure the compute node.

Configure the compute node:

On the compute node, the interface should be tagged with the VLAN ID configured on the provider network. In my case, this is VLAN203. My VLAN interface has the following configuration:

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-p55p2.203 
DEVICE=p55p2.203
VLAN=yes
ONBOOT=yes
MTU=1500
DEFROUTE=no
NM_CONTROLLED=no
IPV6INIT=no

Note that the basic system used is CentOS 7.3. For the Ubuntu base operating system, the configuration will be different.

On the compute node, the file linuxbridge_agent.ini: It should have the following mapping:

physical_interface_mappings = provider:p55p2

After configuring the Linux bridge on the compute node, a bridge will be created.as follows

OpenStack list calculation display bridge

From the output above, you can see that the bridge is called brqa54af9d4-d2 Its interface is 55. p55p2.203 is the subinterface associated with the physical interface 55

You are ready to create a new instance on the provider network created earlier:

openstack server create --flavor m1.tiny --image CoreOS-x86_64 
 --nic net-id=a54af9d4-d297-45b6-a98c-79d84add5f2e --security-group default 
 --key-name josphat coreos-test-vm

For information on how to add images to openstack, add the following ssh keys and flavors:

Use CLI to add SSH key pair to OpenStack

How to add flavor to OpenStack using CLI

Add images to Openstack Glance

that’s it. Please follow us on Twitter and Facebook to receive daily updates.

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

Sidebar