ThorneLabs

Configure Multiple Network Interfaces on an OpenStack Instance

• Updated January 10, 2019


Most of the pre-made OpenStack Cloud Images are configured to connect an OpenStack Instance to one network interface on creation of the instance.

As of OpenStack Icehouse, the functionality to attach another network interface to an existing OpenStack Instance through the Horizon Dashboard is not exposed. However, you can attach another network interface to an existing OpenStack Instance using the neutron and nova commands.

Manually Attach Another Network Interface

First, decide which Neutron Network you want to attach the second network interface of the OpenStack Instance to.

Create a Neutron Port on that Neutron Network (vmnet2 is the Neutron Network in this example):

neutron port-create vmnet2

If you want to create a Neutron Port with a pre-defined IP address instead of pulling the next available IP address from the Neutron Network’s DHCP pool, run the following command instead (the IP address you use must not already be in-use):

neutron port-create vmnet2 --fixed-ip ip_address=<IP-ADDRESS>

Copy the id returned when the command completes. You will use this in the next command.

Attach the OpenStack Instance to the newly created Neutron Port (instance1 is the name of the OpenStack Instance in this example):

nova interface-attach --port-id $PORT_ID instance1

Once the Neutron Port has been created and attached to the OpenStack Instance, log in to the instance and setup the network configuration for eth1.

CentOS 6

If you are using CentOS 6, create /etc/sysconfig/network-scripts/ifcfg-eth1 with the following contents:

DEVICE=eth1
NAME=eth0
BOOTPROTO=dhcp
NM_CONTROLLED=no
PERSISTENT_DHCLIENT=1
ONBOOT=yes
TYPE=Ethernet

If the second Neutron Network you attached your OpenStack Instance to has a default gateway, it will override the instances’ existing default gateway. You do not need to change anything if that is the desired behavior. If that is not the desired behavior you can configure CentOS to always use the default gateway from a specific network interface with the following configuration change:

echo 'GATEWAYDEV=eth0' >> /etc/sysconfig/network

Ubuntu 12.04 and 14.04

On Ubuntu Server 12.04, open /etc/network/interfaces and append the following contents:

auto eth1
iface eth1 inet dhcp

On Ubuntu Server 14.04, create /etc/network/interfaces.d/eth1.cfg with the following contents:

auto eth1
iface eth1 inet dhcp

As mentioned above, if the second Neutron Network you attached your OpenStack Instance to has a default gateway, it will override the instances’ existing default gateway. You do not need to change anything if that is the desired behavior. If that is not the desired behavior Ubuntu puts you in a complicated situation. Ubuntu does not provide the same configuration utility as CentOS to ensure the default gateway is always used from a specific network interface. You can either remove the default gateway from the second Neutron Network or try implementing the following change created by a colleague to emulate the CentOS configuration utility in Ubuntu.

Finally, on either operating system, bring up eth1 with the following command.

ifup eth1

eth1 should be assigned the IP address assigned to the Neutron Port when it was created.

Automate Attaching Another Network Interface

This very manual process is not something you want to do all the time. So, to get around going through all those steps, simply boot an OpenStack Instance, setup the network configuration for eth1 using the same steps above, and snapshot the instance.

Then, when you need to create an OpenStack Instance attached to multiple Neutron Networks, use the snapshot you just created, and tell OpenStack, either via the Horizon Dashboard or the command line tools, to attach the OpenStack Instance to multiple Neutron Networks. The first Neutron Network specified will be connected to eth0 and the second Neutron Network specified will be connected to eth1.

This same process should work if you need an OpenStack Instance attached to more than two Neutron Networks.

References

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided affiliate links. I will receive a referral payment from any of the services you sign-up for.

Get faster shipping and more with Amazon Prime: About to order something from Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.

Thanks for reading and take care.