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
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.
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.
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 specificed will be connected to eth1.
This same process should work if you need an OpenStack Instance attached to more than two Neutron Networks.