Question: How do I install and activate the latest ENA driver for enhanced network support on an Amazon EC2 instance running Red Hat 6/7?

How do I install and activate the latest Elastic Network Adapter (ENA) driver for enhanced network support on an Amazon Elastic Compute Cloud (Amazon EC2) instance running RHEL 6 or 7?Short descriptionSome earlier versions of the Red Hat Enterprise Linux operating system don't include an ENA driver. For Nitro instances, the ENA driver is required to change your EC2 instance type for network connectivity.Note: It's a best practice to create a snapshot of your instance before proceeding with the following resolution.

ResolutionRHEL 7.4 and laterRHEL 7.4 and later AMIs come preinstalled with the module needed for enhanced networking with ENA. For more information, see Enable enhanced networking with the Elastic Network Adapter (ENA) on Linux instances.RHEL 7 lower than 7.41.    Run the following command to upgrade the kernel to the latest version:sudo yum upgrade kernel -y2.    Stop the instance.Note: Data in instance store volumes is lost when an instance is stopped. For more information, see Determine the root device type of your instance. Be sure that you  back up any data that you want to keep on an instance store volume.3.    Run the following AWS Command Line Interface (AWS CLI) command:aws ec2 modify-instance-attribute --instance-id i-xxxxxxxxxxxxxxxxx --ena-support --region xx-xxxxx-xNote: If the AWS CLI isn't installed on your instance, you can install and configure it. If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.4.    Start the instance.5.    Validate that the ENA driver loaded on the instance using the following command. Replace eth0 with the name of the interface that you want to check. The default name for a single interface is eth0. If your operating system uses predictable network names, the network name might be different.$ ethtool -i eth0RHEL 6Note: RHEL 6 doesn't come with Amazon EC2 production-ready NVMe drivers and you can't upgrade to NVME drivers separately. If you want to use a Nitro-based, or any instance type with NVMe instance store volumes, upgrade to RHEL 7.4 or higher.Download and install the ENA driver1.    Update the kernel and reboot the system so that the latest kernel takes effect:sudo yum upgrade kernel -y && sudo reboot2.    Install the development package for building kernel modules to match the kernel:sudo yum install kernel-devel-$(uname -r) gcc git patch rpm-build wget -ycd /usr/src/sudo wget https://github.com/amzn/amzn-drivers/archive/master.zipsudo unzip master.zipcd amzn-drivers-master/kernel/linux/enasudo make3.    Copy the module to the modules directory:sudo cp ena.ko /lib/modules/$(uname -r)/4.    Regenerate the kernel module dependency map files:sudo depmod5.    Use the modinfo command to confirm that the ENA module is present:modinfo enaThe modinfo command output shows the ENA driver information.Note: The ENA driver version might be newer than 2.2.11g while you compile and install it on your system.filename:       /lib/modules/2.6.32-754.33.1.el6.x86_64/ena.koversion:        2.2.11glicense:        GPLdescription:    Elastic Network Adapter (ENA)author:         Amazon.com, Inc. or its affiliatesretpoline:      Ysrcversion:     17C7CD1CEAD3F0ADB3A5E5Ealias:          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*alias:          pci:v00001D0Fd00000051sv*sd*bc*sc*i*depends:        vermagic:       2.6.32-754.33.1.el6.x86_64 SMP mod_unload modversions parm:           debug:Debug level (0=none,...,16=all) (int)parm:           rx_queue_size:Rx queue size. The size should be a power of 2. Max value is 8K (int)parm:           force_large_llq_header:Increases maximum supported header size in LLQ mode to 224 bytes, while reducing the maximum TX queue size by half. (int)parm:           num_io_queues:Sets number of RX/TX queues to allocate to device. The maximum value depends on the device and number of online CPUs. (int)6.    Append net.ifnames=0 to /boot/grub/grub.conf to turn off network interface naming:sudo sed -i '/kernel/s/$/ net.ifnames=0/' /boot/grub/grub.conf7.    Stop the instance.8.    Activate enhanced network support at the instance level. The following example modifies the instance's attribute from the AWS Command Line Interface (AWS CLI).aws ec2 modify-instance-attribute --instance-id i-xxxxxxxxxxxxxxxxx --ena-support --region xx-xxxxx-x9.    Change the instance type to one of the ENA supported instance types.10.    Start the instance, connect to the instance using SSH, and then run the ethtool command:ethtool -i eth0The output includes the ENA driver version, as shown in the following example:driver: enaversion: 2.2.11gfirmware-version: bus-info: 0000:00:05.0supports-statistics: yessupports-test: nosupports-eeprom-access: nosupports-register-dump: nosupports-priv-flags: noConfigure the Dynamic Kernel Module Support (DKMS) program to make sure that the driver is included during future kernel upgradesKeep the following in mind:Software from the EPEL repository is not supported by Red Hat or AWS.Using DKMS voids the support agreement for your subscription.1.    Install the following Red Hat Package Manager ( rpm) file:sudo yum install https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-6-8.noarch.rpm -yNote: For a list of the most recent .rpm packages, refer to the EPEL - Fedora Project Wiki website.2.    Run the install command:sudo yum install dkms -y3.    Detect the current version:VER=$( grep ^VERSION /usr/src/amzn-drivers-master/kernel/linux/rpm/Makefile | cut -d' ' -f2 )4.    Copy the source files into the source directory:sudo cp -a /usr/src/amzn-drivers-master /usr/src/amzn-drivers-${VER}5.    Generate the DKMS config file and build and install the ENA module:sudo cat <<EOM | sudo tee /usr/src/amzn-drivers-${VER}/dkms.confPACKAGE_NAME="ena"PACKAGE_VERSION="$VER"CLEAN="make -C kernel/linux/ena clean"MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=\${kernelver}"BUILT_MODULE_NAME[0]="ena"BUILT_MODULE_LOCATION="kernel/linux/ena"DEST_MODULE_LOCATION[0]="/updates"DEST_MODULE_NAME[0]="ena"AUTOINSTALL="yes"EOMsudo dkms add -m amzn-drivers -v $VERsudo dkms build -m amzn-drivers -v $VERsudo dkms install -m amzn-drivers -v $VER