How to Build an OpenStack Network using the Neutron CLI

Introduction

Within this article we will provide the steps required to build a simple Neutron network. The network will consist of,

  • Provider network (NET_EXTERNAL)
  • Tenant network (NET_INTERNAL)
  • L3 Router (NEUTRON-ROUTER)
  • Floating IPs (172.16.100.30-172.16.100.70)

Below is a diagram on how the topology looks,

Provider Network

First we create the provider network. This is a layer2 network that maps to a physical network, allowing us to use a physical device as the gateway. Below traffic is sent out tagged on VLAN100.
We then assign a subnet to the network. This contains the floating IPs as well as the default gateway.

neutron net-create --provider:physical_network=physnet1 \
                   --provider:network_type=vlan \
                   --provider:segmentation_id=100 \
                   --shared --router:external NET_EXTERNAL

neutron subnet-create NET_EXTERNAL 172.16.100.0/24 \
                   --name SUBNET_EXTERNAL \ 
                   --enable_dhcp=False \
                   --allocation_pool start=172.16.100.30,end=172.16.100.70 \ 
                   --gateway 172.16.100.1

Tenant Network

The tenant network is then created. We assign the DNS servers and IP pool (fixed IPs) that will be assigned to the instances by DHCP on creation.

neutron net-create NET_INTERNAL
neutron subnet-create NET_INTERNAL 10.1.1.0/24 \
                 --name SUBNET_INTERNAL \
                 --dns-nameservers list=true 8.8.8.8 4.2.2.2

L3 Router

Finally we create the L3 router. We assign the gateway network (i.e provider) and then the tenant network.

neutron router-create NEUTRON-ROUTER
neutron router-gateway-set NEUTRON-ROUTER NET_EXTERNAL
neutron router-interface-add NEUTRON-ROUTER SUBNET_INTERNAL

Show Commands

CommandDetails
neutron net-listList networks
neutron net-show <network>Show network
neutron subnet-istList subnets
neutron subnet-show <subnet>Show subnet
neutron floatingip-listList floating IPs
neutron floatingip-show <floating_ip>Show floating IP
neutron router-listList routers
neutron router-show <router>Show router

Links

Installation Scripts – https://github.com/busterswt/openstack_installer

Rick Donato

Want to become an OpenStack expert?

Here is our hand-picked selection of the best courses you can find online:
OpenStack Essentials course
Certified OpenStack Administrator course
Docker Mastery course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial