Amazon Elastic Compute Cloud
User Guide for Linux Instances

Enabling Enhanced Networking with the Elastic Network Adapter (ENA) on Linux Instances

Amazon EC2 provides enhanced networking capabilities to C5, C5d, F1, G3, H1, I3, m4.16xlarge, M5, M5d, P2, P3, R4, R5, R5d, T3, X1, X1e, and z1d instances through the Elastic Network Adapter (ENA).

Requirements

To prepare for enhanced networking using the ENA, set up your instance as follows:

  • Launch the instance from an HVM AMI using Linux kernel version of 3.2 or later. The latest Amazon Linux HVM AMIs have the modules required for enhanced networking installed and have the required attributes set. Therefore, if you launch an Amazon EBS–backed, enhanced networking–supported instance using a current Amazon Linux HVM AMI, ENA enhanced networking is already enabled for your instance.

  • Launch the instance in a VPC. (You can't enable enhanced networking if the instance is in EC2-Classic.)

  • Install and configure the AWS CLI or the AWS Tools for Windows PowerShell on any computer you choose, preferably your local desktop or laptop. For more information, see Accessing Amazon EC2. Enhanced networking cannot be managed from the Amazon EC2 console.

  • If you have important data on the instance that you want to preserve, you should back that data up now by creating an AMI from your instance. Updating kernels and kernel modules, as well as enabling the enaSupport attribute, might render incompatible instances or operating systems unreachable; if you have a recent backup, your data will still be retained if this happens.

Testing Whether Enhanced Networking Is Enabled

To test whether enhanced networking is already enabled, verify that the ena module is installed on your instance and that the enaSupport attribute is set. If your instance satisfies these two conditions, then the ethtool -i ethn command should show that the module is in use on the network interface.

Kernel Module (ena)

To verify that the ena module is installed, use the modinfo command as follows:

[ec2-user ~]$ modinfo ena filename: /lib/modules/4.14.33-59.37.amzn2.x86_64/kernel/drivers/amazon/net/ena/ena.ko version: 1.5.0g license: GPL description: Elastic Network Adapter (ENA) author: Amazon.com, Inc. or its affiliates srcversion: 692C7C68B8A9001CB3F31D0 alias: pci:v00001D0Fd0000EC21sv*sd*bc*sc*i* alias: pci:v00001D0Fd0000EC20sv*sd*bc*sc*i* alias: pci:v00001D0Fd00001EC2sv*sd*bc*sc*i* alias: pci:v00001D0Fd00000EC2sv*sd*bc*sc*i* depends: retpoline: Y intree: Y name: ena ...

In the above Amazon Linux case, the ena module is installed.

ubuntu:~$ modinfo ena ERROR: modinfo: could not find module ena

In the above Ubuntu instance, the module is not installed, so you must first install it. For more information, see Enabling Enhanced Networking on Ubuntu.

Instance Attribute (enaSupport)

To check whether an instance has the enhanced networking enaSupport attribute set, use one of the following commands. If the attribute is set, the response is true.

  • describe-instances (AWS CLI)

    aws ec2 describe-instances --instance-ids instance_id --query "Reservations[].Instances[].EnaSupport"
  • Get-EC2Instance (Tools for Windows PowerShell)

    (Get-EC2Instance -InstanceId instance-id).Instances.EnaSupport

Image Attribute (enaSupport)

To check whether an AMI has the enhanced networking enaSupport attribute set, use one of the following commands. If the attribute is set, the response is true.

  • describe-images (AWS CLI)

    aws ec2 describe-images --image-id ami_id --query "Images[].EnaSupport"
  • Get-EC2Image (Tools for Windows PowerShell)

    (Get-EC2Image -ImageId ami_id).EnaSupport

Network Interface Driver

Use the following command to verify that the ena module is being used on a particular interface, substituting the interface name that you wish to check. If you are using a single interface (default), it will be eth0.

[ec2-user ~]$ ethtool -i eth0 driver: vif version: firmware-version: bus-info: vif-0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no

In the above case, the ena module is not loaded, because the listed driver is vif.

[ec2-user ~]$ ethtool -i eth0 driver: ena version: 1.5.0g firmware-version: expansion-rom-version: bus-info: 0000:00:05.0 supports-statistics: yes supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no

In this case, the ena module is loaded and at the minimum recommended version. This instance has enhanced networking properly configured.

Enabling Enhanced Networking on the Amazon Linux AMI

Amazon Linux 2 and the latest versions of the Amazon Linux AMI have the module required for enhanced networking installed and have the required enaSupport attribute set. Therefore, if you launch an instance with an HVM version of Amazon Linux on a supported instance type, enhanced networking is already enabled for your instance. For more information, see Testing Whether Enhanced Networking Is Enabled.

If you launched your instance using an older Amazon Linux AMI and it does not have enhanced networking enabled already, use the following procedure to enable enhanced networking.

To enable enhanced networking on Amazon Linux AMI

  1. Connect to your instance.

  2. From the instance, run the following command to update your instance with the newest kernel and kernel modules, including ena:

    [ec2-user ~]$ sudo yum update
  3. From your local computer, reboot your instance using the Amazon EC2 console or one of the following commands: reboot-instances (AWS CLI), Restart-EC2Instance (AWS Tools for Windows PowerShell).

  4. Connect to your instance again and verify that the ena module is installed and at the minimum recommended version using the modinfo ena command from Testing Whether Enhanced Networking Is Enabled.

  5. [EBS-backed instance] From your local computer, stop the instance using the Amazon EC2 console or one of the following commands: stop-instances (AWS CLI), Stop-EC2Instance (AWS Tools for Windows PowerShell). If your instance is managed by AWS OpsWorks, you should stop the instance in the AWS OpsWorks console so that the instance state remains in sync.

    [Instance store-backed instance] You can't stop the instance to modify the attribute. Instead, proceed to this procedure: To enable enhanced networking on Amazon Linux AMI (instance store-backed instances).

  6. From your local computer, enable the enhanced networking attribute using one of the following commands:

  7. (Optional) Create an AMI from the instance, as described in Creating an Amazon EBS-Backed Linux AMI. The AMI inherits the enhanced networking enaSupport attribute from the instance. Therefore, you can use this AMI to launch another instance with enhanced networking enabled by default.

  8. From your local computer, start the instance using the Amazon EC2 console or one of the following commands: start-instances (AWS CLI), Start-EC2Instance (AWS Tools for Windows PowerShell). If your instance is managed by AWS OpsWorks, you should start the instance in the AWS OpsWorks console so that the instance state remains in sync.

  9. Connect to your instance and verify that the ena module is installed and loaded on your network interface using the ethtool -i ethn command from Testing Whether Enhanced Networking Is Enabled.

    If you are unable to connect to your instance after enabling enhanced networking, see Troubleshooting the Elastic Network Adapter (ENA).

To enable enhanced networking on Amazon Linux AMI (instance store-backed instances)

Follow the previous procedure until the step where you stop the instance. Create a new AMI as described in Creating an Instance Store-Backed Linux AMI, making sure to enable the enhanced networking attribute when you register the AMI.

  • register-image (AWS CLI)

    aws ec2 register-image --ena-support ...
  • Register-EC2Image (AWS Tools for Windows PowerShell)

    Register-EC2Image -EnaSupport $true ...

Enabling Enhanced Networking on Ubuntu

The latest Ubuntu HVM AMIs have the module required for enhanced networking with ENA installed and have the required enaSupport attribute set. Therefore, if you launch an instance with the latest Ubuntu HVM AMI on a supported instance type, enhanced networking is already enabled for your instance. For more information, see Testing Whether Enhanced Networking Is Enabled.

If you launched your instance using an older AMI and it does not have enhanced networking enabled already, you can install the linux-aws kernel package to get the latest enhanced networking drivers.

To install the linux-aws kernel package

  1. Connect to your instance.

  2. Update the package cache and packages.

    ubuntu:~$ sudo apt-get update && sudo apt-get upgrade -y linux-aws

    Important

    If during the update process you are prompted to install grub, use /dev/xvda to install grub onto, and then choose to keep the current version of /boot/grub/menu.lst.

Enabling Enhanced Networking on Linux

The following procedure provides the general steps for enabling enhanced networking on a Linux distribution other than Amazon Linux AMI or Ubuntu, such as SUSE Linux Enterprise Server, Red Hat Enterprise Linux, or CentOS. Before you begin, see Testing Whether Enhanced Networking Is Enabled to check if your instance is already enabled for enhanced networking. For more information, such as detailed syntax for commands, file locations, or package and tool support, see the specific documentation for your Linux distribution.

To enable enhanced networking on Linux

  1. Connect to your instance.

  2. Clone the source code for the ena module on your instance from GitHub at https://github.com/amzn/amzn-drivers.

    git clone https://github.com/amzn/amzn-drivers
  3. Compile and install the ena module on your instance.

  4. Run the sudo depmod command to update module dependencies.

  5. Update initramfs on your instance to ensure that the new module loads at boot time. For example, if your distribution supports dracut, you can use the following command:

    dracut -f -v
  6. Determine if your system uses predictable network interface names by default. Systems that use systemd or udev versions 197 or greater can rename Ethernet devices and they do not guarantee that a single network interface will be named eth0. This behavior can cause problems connecting to your instance. For more information and to see other configuration options, see Predictable Network Interface Names on the freedesktop.org website.

    1. You can check the systemd or udev versions on RPM-based systems with the following command:

      rpm -qa | grep -e '^systemd-[0-9]\+\|^udev-[0-9]\+' systemd-208-11.el7_0.2.x86_64

      In the above Red Hat Enterprise Linux 7 example, the systemd version is 208, so predictable network interface names must be disabled.

    2. Disable predictable network interface names by adding the net.ifnames=0 option to the GRUB_CMDLINE_LINUX line in /etc/default/grub.

      sudo sed -i '/^GRUB\_CMDLINE\_LINUX/s/\"$/\ net\.ifnames\=0\"/' /etc/default/grub
    3. Rebuild the grub configuration file.

      sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  7. [EBS-backed instance] From your local computer, stop the instance using the Amazon EC2 console or one of the following commands: stop-instances (AWS CLI), Stop-EC2Instance (AWS Tools for Windows PowerShell). If your instance is managed by AWS OpsWorks, you should stop the instance in the AWS OpsWorks console so that the instance state remains in sync.

    [Instance store-backed instance] You can't stop the instance to modify the attribute. Instead, proceed to this procedure: To enable enhanced networking on Linux (instance store–backed instances).

  8. From your local computer, enable the enhanced networking enaSupport attribute using one of the following commands:

  9. (Optional) Create an AMI from the instance, as described in Creating an Amazon EBS-Backed Linux AMI . The AMI inherits the enhanced networking enaSupport attribute from the instance. Therefore, you can use this AMI to launch another instance with enhanced networking enabled by default.

    Important

    If your instance operating system contains an /etc/udev/rules.d/70-persistent-net.rules file, you must delete it before creating the AMI. This file contains the MAC address for the Ethernet adapter of the original instance. If another instance boots with this file, the operating system will be unable to find the device and eth0 might fail, causing boot issues. This file is regenerated at the next boot cycle, and any instances launched from the AMI create their own version of the file.

  10. From your local computer, start the instance using the Amazon EC2 console or one of the following commands: start-instances (AWS CLI), Start-EC2Instance (AWS Tools for Windows PowerShell). If your instance is managed by AWS OpsWorks, you should start the instance in the AWS OpsWorks console so that the instance state remains in sync.

  11. (Optional) Connect to your instance and verify that the module is installed.

    If you are unable to connect to your instance after enabling enhanced networking, see Troubleshooting the Elastic Network Adapter (ENA).

To enable enhanced networking on Linux (instance store–backed instances)

Follow the previous procedure until the step where you stop the instance. Create a new AMI as described in Creating an Instance Store-Backed Linux AMI, making sure to enable the enhanced networking attribute when you register the AMI.

Troubleshooting

For additional information about troubleshooting your ENA adapter, see Troubleshooting the Elastic Network Adapter (ENA).