Adding a Second Network Interface to AWS EC2 Instance

By Łukasz Kallas
Picture of the author
Published on
aws image

Adding a second network interface to your EC2 instance can be useful for various scenarios, such as creating a management network or implementing network segmentation. Let's walk through the process of adding and configuring an additional network interface.

Prerequisites

  • An existing EC2 instance
  • Available IP addresses in your VPC subnet
  • Appropriate IAM permissions

Step 1: Create a New Network Interface

  1. Navigate to the EC2 Dashboard in AWS Console
  2. In the left sidebar, under "Network & Security", click on "Network Interfaces"
  3. Click "Create Network Interface"
  4. Configure the following:
    • Select the subnet (must be in the same AZ as your EC2 instance)
    • Choose or auto-assign an IPv4 address
    • Select appropriate security groups
    • Add a description (e.g., "Management Interface")
  5. Click "Create"

Step 2: Attach the Network Interface

  1. Select the newly created network interface
  2. Click "Actions" and choose "Attach"
  3. Select your EC2 instance from the dropdown
  4. Click "Attach"

Step 3: Configure the Network Interface

  1. SSH into your EC2 instance

  2. For Amazon Linux AMI, the secondary network interface will be automatically configured via DHCP. Verify it's present:

    ip a
    

    You should see both interfaces listed with their respective IP addresses.

  3. If you need to modify any network settings, they can be found in:

    /etc/sysconfig/network-scripts/
    

    However, modification is typically not necessary as Amazon Linux AMI automatically handles the configuration.

Note: The manual configuration steps shown are primarily needed for other Linux distributions. Amazon Linux AMI includes enhanced networking support and automatic configuration of additional network interfaces.

Important Considerations

  • The second network interface must be in the same Availability Zone as the EC2 instance
  • Make sure your security groups allow the necessary traffic
  • Some instance types have limits on the number of network interfaces they support
  • Source/Destination check settings might need to be modified depending on your use case

Common Use Cases

  1. Management Network: Create a separate network for administrative access
  2. Network Appliances: Use multiple interfaces for routing or firewall applications
  3. High Availability: Set up redundant network paths
  4. Network Segmentation: Separate different types of traffic (e.g., application and database traffic)

Stay Tuned

Want to learn?
The best articles, links and news related to software development delivered once a week to your inbox.