Chapter 49. Automatically configuring network interfaces in public clouds using nm-cloud-setup

download PDF

Usually, a virtual machine (VM) has only one interface that is configurable by DHCP. However, DHCP cannot configure VMs with multiple network entities, such as interfaces, IP subnets, and IP addresses. Additionally, you cannot apply settings when the VM instance is running. To solve this runtime configuration issue, the nm-cloud-setup utility automatically retrieves configuration information from the metadata server of the cloud service provider and updates the network configuration of the host. The utility automatically picks up multiple network interfaces, multiple IP addresses, or IP subnets on one interface and helps to reconfigure the network of the running VM instance.

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.


  • 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.


  1. Install the nm-cloud-setup package:

    # dnf install NetworkManager-cloud-setup
  2. Create and run the snap-in file for the nm-cloud-setup service:

    1. 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.

    2. Use the systemd snap-in file to configure the cloud provider in nm-cloud-setup. For example, to use Amazon EC2, enter:


      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)
    3. Save the file and quit the editor.
  3. Reload the systemd configuration:

    # systemctl daemon-reload
  4. Enable and start the nm-cloud-setup service:

    # systemctl enable --now nm-cloud-setup.service
  5. Enable and start the nm-cloud-setup timer:

    # systemctl enable --now nm-cloud-setup.timer

Additional resources

49.2. Understanding the role of IMDSv2 and nm-cloud-setup in the RHEL EC2 instance

The instance metadata service (IMDS) in Amazon EC2 allows you to manage permissions to access instance metadata of a running Red Hat Enterprise Linux (RHEL) EC2 instance. The RHEL EC2 instance uses IMDS version 2 (IMDSv2), a session-oriented method. By using the nm-cloud-setup utility, administrators can reconfigure the network and automatically update the configuration of running RHEL EC2 instances. The nm-cloud-setup utility handles IMDSv2 API calls by using IMDSv2 tokens without any user intervention.

  • IMDS runs on a link-local address for providing access to native applications on a RHEL EC2 instance.
  • After you have specified and configured IMDSv2 for each RHEL EC2 instance for applications and users, you can no longer access IMDSv1.
  • By using IMDSv2, the RHEL EC2 instance maintains metadata without using the IAM role while remaining accessible through the IAM role.
  • When the RHEL EC2 instance boots, the nm-cloud-setup utility automatically runs to fetch the EC2 instance API access token for using the RHEL EC2 instance API.

Use the IMDSv2 token as an HTTP header to check the details of the EC2 environment.

Additional resources

  • nm-cloud-setup(8) man page
Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.