Create a trunk to enable multi-VLAN routing

Create a trunk by creating a parent port and then associating it with the trunk.

Before you begin

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.
    $ dnf list installed python-openstackclient

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:
    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Identify the network connected to the instances that you want to give access to the trunked VLANs:
    $ openstack network list -c Name -c Subnets --max-width=55
    Sample output
    +-------------+---------------------------------------+
    | Name        | Subnets                               |
    +-------------+---------------------------------------+
    | private     | 47d34cf0-0dd2-49bd-a985-67311d80c5c4, |
    |             | 82014d36-9e60-43eb-92fc-74674573f4e8, |
    |             | d7535565-113f-4192-baa6-da21f301f141  |
    | private2    | 7ee56cef-83c0-40d1-b4e7-5287dae1c23c  |
    | public      | 49dda67d-814e-457b-b14b-77ef32935c0f, |
    |             | 6745edd4-d15f-4971-89bf-70307b0ad2f1, |
    |             | cc3f81bb-4d55-4ead-aad4-5362a7ca5b04  |
    | lb-mgmt-net | 5ca08724-568c-4030-93eb-f2e286570a25  |
    +-------------+---------------------------------------+
  3. Create the parent trunk port, and attach it to the network that the instances connect to.
    Example

    In this example, a port named parent-trunk-port is created on the public network. This port is the parent port, as you can use it to create subports:

    $ openstack port create --network public parent-trunk-port
    Sample output
    +-------------------------+--------------------------------------------+
    | Field                   | Value                                      |
    +-------------------------+--------------------------------------------+
    | admin_state_up          | UP                                         |
    | allowed_address_pairs   |                                            |
    | binding_host_id         |                                            |
    | binding_profile         |                                            |
    | binding_vif_details     |                                            |
    | binding_vif_type        | unbound                                    |
    | binding_vnic_type       | normal                                     |
    | created_at              | 2024-09-25T20:18:40Z                       |
    | data_plane_status       | None                                       |
    | description             |                                            |
    | device_id               |                                            |
    | device_owner            |                                            |
    | device_profile          | None                                       |
    | dns_assignment          | fqdn='host-10-0-0-236.openstacklocal.',    |
    |                         | hostname='host-10-0-0-236',                |
    |                         | ip_address='10.0.0.236'                    |
    |                         | fqdn='host-2002-c000-200--                 |
    |                         | 64.openstacklocal.',                       |
    |                         | hostname='host-2002-c000-200--64',         |
    |                         | ip_address='2002:c000:200::64'             |
    | dns_domain              |                                            |
    | dns_name                |                                            |
    | extra_dhcp_opts         |                                            |
    | fixed_ips               | ip_address='10.0.0.236', subnet_id='6745ed |
    |                         | d4-d15f-4971-89bf-70307b0ad2f1'            |
    |                         | ip_address='2002:c000:200::64', subnet_id= |
    |                         | '49dda67d-814e-457b-b14b-77ef32935c0f'     |
    | id                      | 530ff46e-b285-4ad7-a77a-7dca1fb9174d       |
    | ip_allocation           | immediate                                  |
    | mac_address             | fa:16:3e:0f:b8:cb                          |
    | name                    | parent-trunk-port                          |
    | network_id              | bcdb3cc0-8c0b-4d2d-813c-e141bb97aa8f       |
    | numa_affinity_policy    | None                                       |
    | port_security_enabled   | True                                       |
    | project_id              | 24089d2fe1a94dd29ca2f665794fbe92           |
    | propagate_uplink_status | None                                       |
    | qos_network_policy_id   | None                                       |
    | qos_policy_id           | None                                       |
    | resource_request        | None                                       |
    | revision_number         | 1                                          |
    | security_group_ids      | 9bf70539-31b0-47e5-a0ea-3ee409de0499       |
    | status                  | DOWN                                       |
    | tags                    |                                            |
    | trunk_details           | {'trunk_id':                               |
    |                         | 'ef2aff85-9e51-43d4-ab28-2ab833f049b3',    |
    |                         | 'sub_ports': []}                           |
    | updated_at              | 2024-09-25T20:18:40Z                       |
    +-------------------------+--------------------------------------------+
  4. Create a trunk using the parent port.
    Example

    In this example, the trunk is named trunk1, and its parent port is named parent-trunk-port:

    $ openstack network trunk create --parent-port parent-trunk-port trunk1
    Sample output
    +-----------------+--------------------------------------+
    | Field           | Value                                |
    +-----------------+--------------------------------------+
    | admin_state_up  | UP                                   |
    | created_at      | 2024-09-25T20:19:43Z                 |
    | description     |                                      |
    | id              | ef2aff85-9e51-43d4-ab28-2ab833f049b3 |
    | name            | trunk1                               |
    | port_id         | 530ff46e-b285-4ad7-a77a-7dca1fb9174d |
    | project_id      | 24089d2fe1a94dd29ca2f665794fbe92     |
    | revision_number | 1                                    |
    | status          | ACTIVE                               |
    | sub_ports       |                                      |
    | tags            | []                                   |
    | tenant_id       | 24089d2fe1a94dd29ca2f665794fbe92     |
    | updated_at      | 2024-09-25T20:19:43Z                 |
    +-----------------+--------------------------------------+

Results

  1. View the trunk connection:
    $ openstack network trunk list --max-width=72
    Sample output
    +--------------------+--------------+--------------------+-------------+
    | ID                 | Name         | Parent Port        | Description |
    +--------------------+--------------+--------------------+-------------+
    | ef2aff85-9e51-43d4 | parent-trunk | 530ff46e-b285-4ad7 |             |
    | -ab28-2ab833f049b3 |              | -a77a-7dca1fb9174d |             |
    +--------------------+--------------+--------------------+-------------+
  2. View the details of the trunk connection:
    $ openstack network trunk show parent-trunk
    Sample output
    +-----------------+--------------------------------------+
    | Field           | Value                                |
    +-----------------+--------------------------------------+
    | admin_state_up  | UP                                   |
    | created_at      | 2024-09-25T20:19:43Z                 |
    | description     |                                      |
    | id              | ef2aff85-9e51-43d4-ab28-2ab833f049b3 |
    | name            | trunk1                               |
    | port_id         | 530ff46e-b285-4ad7-a77a-7dca1fb9174d |
    | project_id      | 24089d2fe1a94dd29ca2f665794fbe92     |
    | revision_number | 1                                    |
    | status          | ACTIVE                               |
    | sub_ports       |                                      |
    | tags            | []                                   |
    | tenant_id       | 24089d2fe1a94dd29ca2f665794fbe92     |
    | updated_at      | 2024-09-25T20:19:43Z                 |
    +-----------------+--------------------------------------+

What to do next

Enable VLAN routing by adding subports to the trunk

Add subports to a trunk to enable VLAN-aware instances.

Before you begin

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.
    $ dnf list installed python-openstackclient
  • You have a trunk associated on the network that connects to instances that you want to give access to the trunked VLANs.

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:
    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Obtain the MAC address of the parent port.

    Retain this name, because you will need it later:

    Example
    $ openstack port show parent-trunk-port --max-width=72
    Sample output
    +-------------------------+--------------------------------------------+
    | Field                   | Value                                      |
    +-------------------------+--------------------------------------------+
    | admin_state_up          | UP                                         |
    | allowed_address_pairs   |                                            |
    | binding_host_id         |                                            |
    | binding_profile         |                                            |
    | binding_vif_details     |                                            |
    | binding_vif_type        | unbound                                    |
    | binding_vnic_type       | normal                                     |
    | created_at              | 2024-09-25T20:18:40Z                       |
    | data_plane_status       | None                                       |
    | description             |                                            |
    | device_id               |                                            |
    | device_owner            |                                            |
    | device_profile          | None                                       |
    | dns_assignment          | fqdn='host-10-0-0-236.openstacklocal.',    |
    |                         | hostname='host-10-0-0-236',                |
    |                         | ip_address='10.0.0.236'                    |
    |                         | fqdn='host-2002-c000-200--                 |
    |                         | 64.openstacklocal.',                       |
    |                         | hostname='host-2002-c000-200--64',         |
    |                         | ip_address='2002:c000:200::64'             |
    | dns_domain              |                                            |
    | dns_name                |                                            |
    | extra_dhcp_opts         |                                            |
    | fixed_ips               | ip_address='10.0.0.236', subnet_id='6745ed |
    |                         | d4-d15f-4971-89bf-70307b0ad2f1'            |
    |                         | ip_address='2002:c000:200::64', subnet_id= |
    |                         | '49dda67d-814e-457b-b14b-77ef32935c0f'     |
    | id                      | 530ff46e-b285-4ad7-a77a-7dca1fb9174d       |
    | ip_allocation           | immediate                                  |
    | mac_address             | fa:16:3e:0f:b8:cb                          |
    | name                    | parent-trunk-port                          |
    | network_id              | bcdb3cc0-8c0b-4d2d-813c-e141bb97aa8f       |
    | numa_affinity_policy    | None                                       |
    | port_security_enabled   | True                                       |
    | project_id              | 24089d2fe1a94dd29ca2f665794fbe92           |
    | propagate_uplink_status | None                                       |
    | qos_network_policy_id   | None                                       |
    | qos_policy_id           | None                                       |
    | resource_request        | None                                       |
    | revision_number         | 1                                          |
    | security_group_ids      | 9bf70539-31b0-47e5-a0ea-3ee409de0499       |
    | status                  | DOWN                                       |
    | tags                    |                                            |
    | trunk_details           | {'trunk_id':                               |
    |                         | 'ef2aff85-9e51-43d4-ab28-2ab833f049b3',    |
    |                         | 'sub_ports': []}                           |
    | updated_at              | 2024-09-25T20:18:40Z                       |
    +-------------------------+--------------------------------------------+
  3. Create a subport of the parent port for the trunk.
    Example

    In this example, a port is created, subport1. By specifying the MAC address assigned to the parent port, fa:16:3e:33:c4:75, the port created becomes a subport of the parent port:

    $ openstack port create --network private --mac-address fa:16:3e:33:c4:75 subport1
    Sample output
    +-------------------------+--------------------------------------------+
    | Field                   | Value                                      |
    +-------------------------+--------------------------------------------+
    | admin_state_up          | UP                                         |
    | allowed_address_pairs   |                                            |
    | binding_host_id         |                                            |
    | binding_profile         |                                            |
    | binding_vif_details     |                                            |
    | binding_vif_type        | unbound                                    |
    | binding_vnic_type       | normal                                     |
    | created_at              | 2024-09-25T20:19:28Z                       |
    | data_plane_status       | None                                       |
    | description             |                                            |
    | device_id               |                                            |
    | device_owner            |                                            |
    | device_profile          | None                                       |
    | dns_assignment          | fqdn='host-10-0-24-31.openstacklocal.',    |
    |                         | hostname='host-10-0-24-31',                |
    |                         | ip_address='10.0.24.31'                    |
    | dns_domain              |                                            |
    | dns_name                |                                            |
    | extra_dhcp_opts         |                                            |
    | fixed_ips               | ip_address='10.0.24.31', subnet_id='47d34c |
    |                         | f0-0dd2-49bd-a985-67311d80c5c4'            |
    | id                      | 4ce8382f-5efc-4794-83f8-1f89ef7efe68       |
    | ip_allocation           | immediate                                  |
    | mac_address             | fa:16:3e:0f:b8:cb                          |
    | name                    | subport1                                   |
    | network_id              | 317be3d3-5265-43f7-b52b-930e3fd19b8b       |
    | numa_affinity_policy    | None                                       |
    | port_security_enabled   | True                                       |
    | project_id              | 24089d2fe1a94dd29ca2f665794fbe92           |
    | propagate_uplink_status | None                                       |
    | qos_network_policy_id   | None                                       |
    | qos_policy_id           | None                                       |
    | resource_request        | None                                       |
    | revision_number         | 1                                          |
    | security_group_ids      | 9bf70539-31b0-47e5-a0ea-3ee409de0499       |
    | status                  | DOWN                                       |
    | tags                    |                                            |
    | trunk_details           | None                                       |
    | updated_at              | 2024-09-25T20:19:28Z                       |
    +-------------------------+--------------------------------------------+
    Note

    If you receive the error HttpException: Conflict, confirm that you are creating the subport on a different network to the one that has the parent trunk port. This example uses the public network for the parent trunk port, and private for the subport.

  4. Associate the port with the trunk.
    Example

    In this example, subport1 is associated with trunk1. The segmentation type is vlan and the segmentation ID, the VLAN ID, is 55. The type and ID are attributes from the network (private) that was used to create subport1 in an earlier command:

    $ openstack network trunk set --subport port=subport1,\
    segmentation-type=vlan,segmentation-id=55 trunk1

What to do next

Connect instances to trunks for multi-VLAN access

Configure an instance to use a trunk for network connectivity.

Before you begin

  • The administrator has created a project for you and has provided you with a clouds.yaml file for you to access the cloud.
  • The python-openstackclient package is on your workstation.
    $ dnf list installed python-openstackclient
  • You have a trunk that you can configure your instances to connect to.

    For more information, see Create a trunk to enable multi-VLAN routing.

About this task

Compared to access ports which can only send and receive network traffic on one VLAN, trunks typically offer lower latency and higher bandwidth.

You must configure the VM instance operating system to use the MAC address that the RHOSO Networking service (neutron) assigned to the subport. You can also configure the subport to use a specific MAC address during the subport creation step.

Procedure

  1. Confirm that the system OS_CLOUD variable is set for your cloud:
    $ echo $OS_CLOUD
    my_cloud

    Reset the variable if necessary:

    $ export OS_CLOUD=my_other_cloud

    As an alternative, you can specify the cloud name by adding the --os-cloud <cloud_name> option each time you run an openstack command.

  2. Obtain the trunk name and the parent port ID that you want to connect your instance to.

    Retain this information, because you will need it later:

    Example
    $ openstack network trunk list -c Name -c "Parent Port"
    Sample output
    +--------+--------------------------------------+
    | Name   | Parent Port                          |
    +--------+--------------------------------------+
    | trunk1 | 530ff46e-b285-4ad7-a77a-7dca1fb9174d |
    +--------+--------------------------------------+
  3. Create an instance that uses the parent port-id as its vNIC.
    Example

    In this example, an instance, testInstance, is created and connected to the parent port by specifying the port ID, 530ff46e-b285-4ad7-a77a-7dca1fb9174d:

    $ openstack server create --image cirros --flavor m1.tiny \
    --security-group default --key-name sshaccess \
    --nic port-id=530ff46e-b285-4ad7-a77a-7dca1fb9174d testInstance
    Sample output
    +--------------------------------------+---------------------------------+
    | Property                             | Value                           |
    +--------------------------------------+---------------------------------+
    | OS-DCF:diskConfig                    | MANUAL                          |
    | OS-EXT-AZ:availability_zone          |                                 |
    | OS-EXT-SRV-ATTR:host                 | -                               |
    | OS-EXT-SRV-ATTR:hostname             | testinstance                    |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | -                               |
    | OS-EXT-SRV-ATTR:instance_name        |                                 |
    | OS-EXT-SRV-ATTR:kernel_id            |                                 |
    | OS-EXT-SRV-ATTR:launch_index         | 0                               |
    | OS-EXT-SRV-ATTR:ramdisk_id           |                                 |
    | OS-EXT-SRV-ATTR:reservation_id       | r-juqco0el                      |
    | OS-EXT-SRV-ATTR:root_device_name     | -                               |
    | OS-EXT-SRV-ATTR:user_data            | -                               |
    | OS-EXT-STS:power_state               | 0                               |
    | OS-EXT-STS:task_state                | scheduling                      |
    | OS-EXT-STS:vm_state                  | building                        |
    | OS-SRV-USG:launched_at               | -                               |
    | OS-SRV-USG:terminated_at             | -                               |
    | accessIPv4                           |                                 |
    | accessIPv6                           |                                 |
    | adminPass                            | uMyL8PnZRBwQ                    |
    | config_drive                         |                                 |
    | created                              | 2024-09-25T20:22:19Z            |
    | description                          | -                               |
    | flavor                               | m1.tiny (1)                     |
    | hostId                               |                                 |
    | host_status                          |                                 |
    | id                                   | 88b7aede-1305-4d91-a180-67e7eac |
    |                                      | 8b70d                           |
    | image                                | cirros (568372f7-15df-4e61-a05f |
    |                                      | -10954f79a3c4)                  |
    | key_name                             | sshaccess                       |
    | locked                               | False                           |
    | metadata                             | {}                              |
    | name                                 | testInstance                    |
    | os-extended-volumes:volumes_attached | []                              |
    | progress                             | 0                               |
    | security_groups                      | default                         |
    | status                               | BUILD                           |
    | tags                                 | []                              |
    | tenant_id                            | 745d33000ac74d30a77539f8920555e |
    |                                      | 7                               |
    | updated                              | 2024-09-25T20:22:19Z            |
    | user_id                              | 8c4aea738d774967b4ef388eb41fef5 |
    |                                      | e                               |
    +--------------------------------------+---------------------------------+