Creating a Network for Instances with the CLI

Depending on the network configuration and workloads, you must create a network prior to launching an instance. The Cisco Managed Network and Cisco Managed Gateway enable you to add a private network for use with your instances.

When your cloud is delivered, Metacloud engineers created a public network named “PUBLIC DO NOT MODIFY”.

$ openstack network list
+--------------+----------------------+---------------------+
| ID           | Name                 | Subnets             |
+--------------+----------------------+---------------------+
| <network_id> | PUBLIC DO NOT MODIFY | <subnet_id>         |
+--------------+----------------------+---------------------+

When you want your instances to communicate outside of your project (tenant), such as for SSH connections to the instances, you must attach a router to the public network on an internal interface and set the gateway on the public network. You also need to logically subdivide the private network into subnets.

To create and prepare a private network for launching instances in Metacloud:

  1. Create a network.

    $ openstack network create sampleNetwork
    +---------------------------+----------------------+
    | Field                     | Value                |
    +---------------------------+----------------------+
    | admin_state_up            | True                 |
    | id                        | <network_id>         |
    | name                      | sampleNetwork        |
    | provider:network_type     | vlan                 |
    | provider:physical_network | bond0                |
    | provider:segmentation_id  | 1651                 |
    | router:external           | False                |
    | shared                    | False                |
    | status                    | ACTIVE               |
    | subnets                   |                      |
    | tenant_id                 | <tenant_id>          |
    +---------------------------+----------------------+
    
  2. Create a subnet associated with the private network.

    $ openstack subnet create sampleNetwork-subnet \
       --network sampleNetwork \
       --subnet-range 10.0.0.1/24
    +------------------+------------------------------------------------+
    | Field            | Value                                          |
    +------------------+------------------------------------------------+
    | allocation_pools | {"start": "10.0.0.2", "end": 10.0.0.254"}      |
    | cidr             | 10.0.0.0/24                                    |
    | dns_nameservers  |                                                |
    | enable_dhcp      | True                                           |
    | gateway_ip       | 10.0.0.1                                       |
    | host_routes      |                                                |
    | id               | <subnet_id>                                    |
    | ip_version       | 4                                              |
    | name             | sampleNetwork-subnet                           |
    | network_id       | <network_id>                                   |
    | tenant_id        | <tenant_id>                                    |
    +------------------+------------------------------------------------+
    

    Note
    If you receive an Invalid input for operation: Only 1 subnet per internal network is allowed response, make sure your project does not have another subnet already created with identical IP range.

  3. Create a router.

    $ openstack router create sampleRouter
    

    Note

    • If you receive a conflict message, make sure the name is not identical to an existing router.
    • If you receive a Quota exceeded for resources: ['router'] response, you have exceeded your quota for routers. Contact your administrator for further assistance.
  4. Create an interface from the router to the private network.

    $ neutron router-interface-add sampleRouter sampleNetwork-subnet
    
  5. Set the gateway for the router to access the public network.

    $ neutron router-gateway-set sampleRouter "PUBLIC DO NOT MODIFY"