Is it possible to use IPv4 prefixes (subnets) as "public IPs" in the network interface of an AWS EC2 instance?


I transferred a /24 subnet (256 IPs) to AWS via BYOIP and I would like to assign some of these IPs to EC2 instances.

I know it is possible to assign a small subset directly to the instance's network interface as Elastic IPs, but I'm looking for a way to assign a larger quantity at once, for example a /28 (16 IPs) or more.

What I want to achieve in the end is to have an EC2 instance with as many public IPv4 as possible.

Is it possible to use IPv4 prefix delegation (as in the link below) as "public IPs" for outbound traffic?

If not, is there any other way to achieve this?

  • please accept the answer if it was useful for you

2 Answers
  1. Allocate Elastic IP address using your BYOIP Pool
  2. Create a new Elastic network interface
  3. Associate the newly allocated elastic IP with this Network interface
  4. Attach the Network interface to an EC2 instance

You can create and configure network interfaces and attach them to instances in the same Availability Zone The number of Network Interfaces you can attach to an EC2 instance depends on the instance type. Here you can find a table

profile picture
answered 2 months ago
profile picture
reviewed 2 months ago

You cant assign public IP/Elastic IP directly to EC2.

For your use case, what you would need to do is as follows.

Simply delegate your desired Private range for example to an EC2 first, as per the link you shared.

After that create 1-to-1 mapping of your BYOIP to each IP in range. This step will be done in associate Step of Elastic IP where you can select private IP. You will have to do it for each ip individually. With that your EC2 will be able to use BYOIP Pool.

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions