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 个月前291 查看次数
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?

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则