Creating a Neutron port and attaching to an Instance

This post will demonstrate the flexibility of creating a new port on a Neutron network and attaching it to an existing Instance. The Instance this port is attaching to is a nested vSphere host so I will run the additional commands listed in this [article].

Creating the port

The first task is to create a port in neutron. The operation consists of the following

The command neutron port-create lab_transport_MGT allows the creation of a new Neutron port on the existing network called _lab_transport_MGT.

[email protected]:~$ neutron port-create _lab_transport_MGT                     Created a new port:
| Field                 | Value                                                                               |
| admin_state_up        | True                                                                                |
| allowed_address_pairs |                                                                                     |
| binding:vnic_type     | normal                                                                              |
| device_id             |                                                                                     |
| device_owner          |                                                                                     |
| fixed_ips             | {"subnet_id": "011821e4-bab3-4987-9eeb-7350f363daf2", "ip_address": ""} |
| id                    | a2815656-76f7-46d4-9d11-057063db1a14                                                |
| mac_address           | fa:16:3e:3f:fe:a9                                                                   |
| name                  |                                                                                     |
| network_id            | d84ce932-b101-4301-98fe-70888792debb                                                |
| port_security_enabled | True                                                                                |
| security_groups       | d96a7dc2-6cf0-429b-ba89-ec74c151baa1                                                |
| status                | DOWN                                                                                |
| tenant_id             | c3485cfe92be4f47852db87ca06b4383                                                    |

Attaching the port to an instance

Now that the port is created it needs to be attached to an instance. Attaching a newly created port to an Instance can be done while the Instance is running.

nova interface-attach --port-id a2815656-76f7-46d4-9d11-057063db1a14 mgt_esx4

This uses nova to attach the newly created Neutron port to the instance with a name of mgt_esx4.

The appearance of a new network interface without a restart depends on Instance image. There is no hot NIC support within ESX so I require a reboot for my changes to appear.

To validate that I have connected to an instance I can do many things. I have chosen to check the mac-address against neutron to see which instance has registered. The MAC address should match to the address listed in the neutron port we created at the start.

[email protected]:~$ neutron port-list | grep fe:a9
| a2815656-76f7-46d4-9d11-057063db1a14 | | fa:16:3e:3f:fe:a9 | {"subnet_id": "011821e4-bab3-4987-9eeb-7350f363daf2", "ip_address": ""} |

There! Nice and easy. Restart this particular instance and you have added a network interface to an instance. In this case it was dedicated NIC for VXLAN traffic in a nested NSX lab.

Leave a Reply

Your email address will not be published. Required fields are marked *