Associate \28 Public subnet with an EC2 interface

0

I recently leased a \24 IPv4 subnet and managed to bring it into AWS (BYOIP), successfully, now I am trying to associate one of the \28 subnets of the \24 with one of the interfaces of my EC2 and I am a bit stumped. Effectively I want this interface to have 16 Public IPs all from the same subnet.

已提問 9 個月前檢視次數 287 次
1 個回答
2

Hi there,

The first four IP addresses and the last IP address in each AWS subnet CIDR block are not available for your use, and they cannot be assigned to a resource, such as an EC2 instance. This means you will only have 13 usable IPs in a /28

To answer the second part of your question, here are the steps to assign multiple IP addresses from your BYOIP subnet to a single EC2 instance interface:

  1. Create a new EC2 instance and attach an Elastic Network Interface (ENI) to it. Use a subnet in your VPC that has a route to the internet gateway.
  2. Modify the ENI to assign a primary private IP address in the VPC subnet range. This will be the primary private IP for the instance.
  3. Under the network interface properties, change the setting for "Secondary private IPv4 addresses" to assign up to 15 additional secondary IPs. These must be within the CIDR range of your VPC subnet.
  4. For each secondary private IP, associate it with an IP address from your BYOIP public subnet using the CLI:

aws ec2 assign-private-ip-addresses --network-interface-id ENI_ID --secondary-private-ip-addresses IP_1,IP_2 etc

  1. Allocate an Elastic IP for each public IP you associated and associate it with the corresponding secondary private IP on the ENI.

This will result in the ENI having a primary private IP, up to 15 secondary private IPs, and a corresponding Elastic IP for each secondary IP. Your instance will then have 16 public IP addresses assigned from your BYOIP range, if your subnet can accomodate this.

profile pictureAWS
已回答 9 個月前
profile pictureAWS
專家
已審閱 9 個月前
  • Hi, you can see the addresses in use in a subnet via 'aws ec2 describe-network-interfaces --filters Name=subnet-id,Values=<subnet id> | jq -r '.NetworkInterfaces[].PrivateIpAddress' | sort'

  • Great I was able to get that to work, to my understanding that means if I am on a c6 metal and I maximize the number of network interfaces I could get up to 15 interfaces and 50 IPs per interface resulting in 750 public IPs on that host. I have heard people with over 3000 IPs on a single c6 instance, is it possible to use prefix delegation to use a /28 almost as if it was just 1 IP leading to a theoretical 12000 IPs on a single host?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南