Chapter 49. Automatically configuring network interfaces in public clouds using nm-cloud-setup
Normally, a virtual machine (VM) has only one interface that is configurable by DHCP. However, some VMs might have multiple network interfaces, IP addresses, and IP subnets on one interface that is not configurable by DHCP. Also, administrators can reconfigure the network while the machine is running. The nm-cloud-setup
utility automatically retrieves configuration information from the metadata server of the cloud service provider and updates the network configurations of VM in public clouds.
49.1. Configuring and pre-deploying nm-cloud-setup
To enable and configure network interfaces in public clouds, run nm-cloud-setup
as a timer and service.
On Red Hat Enterprise Linux On Demand and AWS golden images, nm-cloud-setup
is already enabled and no action is required.
Prerequisite
- A network connection exists.
The connection uses DHCP.
By default, NetworkManager creates a connection profile which uses DHCP. If no profile was created because you set the
no-auto-default
parameter in/etc/NetworkManager/NetworkManager.conf
, create this initial connection manually.
Procedure
Install the
nm-cloud-setup
package:# dnf install NetworkManager-cloud-setup
Create and run the snap-in file for the
nm-cloud-setup
service:Use the following command to start editing the snap-in file:
# systemctl edit nm-cloud-setup.service
It is important to either start the service explicitly or reboot the system to make configuration settings effective.
Use the
systemd
snap-in file to configure the cloud provider innm-cloud-setup
. For example, to use Amazon EC2, enter:[Service] Environment=NM_CLOUD_SETUP_EC2=yes
You can set the following environment variables to enable the cloud provide you use:
-
NM_CLOUD_SETUP_AZURE
for Microsoft Azure -
NM_CLOUD_SETUP_EC2
for Amazon EC2 (AWS) -
NM_CLOUD_SETUP_GCP
for Google Cloud Platform(GCP) -
NM_CLOUD_SETUP_ALIYUN
for Alibaba Cloud (Aliyun)
-
- Save the file and quit the editor.
Reload the
systemd
configuration:# systemctl daemon-reload
Enable and start the
nm-cloud-setup
service:# systemctl enable --now nm-cloud-setup.service
Enable and start the
nm-cloud-setup
timer:# systemctl enable --now nm-cloud-setup.timer
Additional resources
-
nm-cloud-setup(8)
man page - Configuring an Ethernet connection