AWS Ubuntu Instance does not configure the second NIC

AWS Ubuntu EC2 Instance does not configure the second network interface

An AWS Ubuntu image will only have one network interface online although two were specified in the blueprint..

Overview

For specifics on why this occurs in AWS you can visit this AWS Knowledge Center Articlearrow-up-right for further details and resolutions across versions.

An example blueprint of an Ubuntu 18.04 image containing two Nics:

vm.nics.external-network

vm.nics.internal-network

#
# Demo Blueprint that configures a Network and launches an Instance
# Version
---
variables:
  admin_username:
    description: The username for the administrative user.
    type: string
    default: adminuser
  admin_public_key:
    description: The OpenSSH Public Key to use for administrative access.
    type: string

location:
  region:
      demo-region:
        country: USA
        area: northwest
  folder:
    multi-cloud:
      region: demo-region

networking:
  network:
    demo-network:
      range: 
        - 10.0.0.0/16
        - 10.100.0.0/16
      public: true
  subnet:
    demo-internal-subnet:
      range: 10.0.0.0/24
      network: demo-network
      firewall: demo-internal-firewall
    demo-external-subnet:
      range: 10.100.0.0/24
      network: demo-network
      firewall: demo-external-firewall
      public: true
  protocol:
    ssh:
      ports:
        - port: 22
          proto: tcp
    http:
      ports:
        - port: 443
          proto: tcp
    https:
      ports: 
        - port: 80
          proto: tcp

  firewall:
    demo-internal-firewall:
      rules:
        - protocols: ssh
        to: self
    demo-external-firewall:
      rules:
        - protocols: ssh
        to: self
        - protocols: http
        to: self
        - protocols: https
        to: self



compute:
  image:
    bionic:
      publisher: Canonical
      product: UbuntuServer
      sku: 18.04-LTS
      venue:
        aws:
          # if provisioning fails due to image not found, go to:
          # https://cloud-images.ubuntu.com/locator/ec2/
          # and search for "bionic amd64 ebs us-west-2"
          image_id: ami-04bb0cc469b2b81cc
  vm:
    demo-instance:
      cores: 1
      memory: 2 gb
      count: 1
      image: bionic
      configure:
        admin:
          username: (( admin_username ))
          public_key: (( admin_public_key ))
      disks:
        data:
          size: 128 GB
          tags:
            demo: multi-cloud
      nics:
        external-network: #Provides first discovered NIC external IP access to NAT server 
          ips:
            - private:
                type: dynamic
              public:
                type: static
          firewall: demo-external-firewall
          subnet: demo-external-subnet
        internal-network: 
          ips:
            - private:
                type: dynamic
          firewall: demo-internal-firewall
          subnet: demo-internal-subnet
      tags:
        demo: multi-cloud

When inspecting the VMs network via an SSH session we can see there is only one network interface online. ifconfig -a does not return an IP for the second Nic.

ifconfig -a

Running the ip address command shows the network interface named ens6 is state DOWN

ip address

Resolution

Solution 1

Using a different AWS Linux image such as the Amazon Linux 2 AMI does not present this issue

Solution 2

Following the AWS knowledge center article for Ubuntu 18.0.4

  1. Obtain the IP address for the affected secondary Network Interface in the amazon console under EC2 -> Network Interfaces:

  1. SSH into your deployed Ubuntu instance with your SSH key

ssh <admin_username>@<ip>

  1. Create a configuration file for the interface

you can issue a :set paste in vi before copying the yaml contents to ensure proper formatting.

  1. Add the following lines to the 51-eth1.yaml file with the obtained secondary IP,default gateway and subnet outlined in the blueprint.

If the adapter name is not eth1 in your instance as in this example, ensure the name is correct in /etc/netplan/51-eth1.yaml

ens6

10.0.0.47/24

10.0.0.1

  1. Apply the network configuration:

sudo netplan --debug apply

  1. Verify network now shows two active Nics in your instance:

ifconfig

ip addr

Last updated

Was this helpful?