How to bring up multiple interfaces up with cloud-init

asked 2019-02-14 08:43:01 -0500

ots1981 gravatar image

I've got a RHEL VM that has cloud-init running on it. My VM has 4 interfaces, eth0 - eth3. I'm running OpenStack Mitaka.

Currently when I boot up the VM, only the eth0 is up and configured with DHCP. This is the default behaviour of cloud-init if no data sources are found. The top of my /etc/sysconfig/network-scripts/ifcfg-eth0 contains a line:

# Created by cloud-init on instance boot automatically, do not edit.

Now what I would like to do is to bring up all 4 Ethernet interfaces with DHCP. Additionally I would like to ignore the default route from eth0, eth2 and eth3.

I know I can do this manually by disabling network configuration of cloud-init and creating ifcfg-eth0, ifcfg-eth1, ifcfg-eth2 and ifcfg-eth3 manually and adding DEFROUTE=no for the three interfaces where I don't want to have a default route. However, I would not like to hard code this into my image. I'd like to provide this with cloud-init and user-data or other such means. However, I've not found a good way to do that.

edit retag flag offensive close merge delete


I might be wrong, but my understanding of cloud-init is to execute an initial configuration at first boot, just some basic stuff. The rest has to be handled by salt, puppet or other automatic configruation tools, or the admin user. You can add user-data for cloud-init to run after boot.

eblock gravatar imageeblock ( 2019-02-14 10:01:52 -0500 )edit

That user-data can contain all kinds of commands, create network configs, restart services and so on. For example, we use that to enable salt-minion with a startup config and that minion registers itself at the salt-master and receives further configuration, everything we need is done via salt.

eblock gravatar imageeblock ( 2019-02-14 10:03:30 -0500 )edit