Tech Junkie Blog - Real World Tutorials, Happy Coding!: Iaas With AWS: Associate An Instance With AWS Elastic Network Interface

Wednesday, October 14, 2020

Iaas With AWS: Associate An Instance With AWS Elastic Network Interface

 In the previous post we associated our Elastic IP with an instance directly.  In this post we are going to take another approach to assign our Elastic IP to our instance.  In this approach we will create an Elastic Network Interface and associate it with our instance instead.  In the first approach the Elastic IP replaces the public IP because we associate it directly to the instance. But if we create an Elastic Network Interface we are essentially adding a second interface in our instance with two IPs, eth0 is the main network interface and eth1 will be the second interface.  It's like having two network interface in the physical world but this time it's virtualized in AWS.


Here are the steps to create a network interface:

1. Create an Elastic IP, follow this post if you don't know how.

If you look at the instance description you will see that there's no Elastic IP address assignment, so if you stop and start the instance you will get a new public IP, and there's only one network interface (eth0). By the time we are finish with this post the instance will have tow network interfaces and an Elastic IP.


2. Click on "Network Interfaces" under "Network & Security"










3.  Click on "Create Network Interface"




4. Choose the same subnet as the Elastic IP

5.  Fill in the fields as you see below, and select the appropriate Security Group, let AWS "Auto-assign" the IP (this is actually going to be the private IP, we did not associate the Elastic IP yet). Click on the "Create" button













6. Once the network interface has been created we want to attach the instance to the ENI, so in the "Network Interfaces" page, check the ENI you've just created and click on the "Attach" button. Think of it like installing a second network card to your PC

7. Select the instance and click "Attach"


8. Now we want to associate the Elastic IP to the ENI, click on "Elastic IPs" under "Network & Security"









9. Check the Elastic IP you want to make the association with, and select "Associate Elastic IP address" option









10.  Select the "Network interface" radio button under "Resource type" and choose the ENI that you've just created. 

11. Choose the "Private IP address"  and check "Allow this Elastic IP to be reassociated", then click on "Associate"


12.  Now if you look at the instance "Description" tab you will see that there's an Elastic IP address associated with the instance now, and a second network interface (ElasticENI)


Previous: Iaas With AWS: Create An Elastic IP And Assign It To An Instance

Next: Iaas With AWS: Associate An Instance With AWS Elastic Network Interface

No comments:

Post a Comment

Search This Blog