Second PUBLIC IPv4 Address Associated in one Instance

0

Hi Guys, I'm new in AWS.

I have an AWS EC2 Instance with one elastic IP address allocated. It is possible to allocate a second PUBLIC elastic IP address to this same instance?

I need to create a route from all outside connections. Simple example:

Connections to IP A port 22 will be redirected to my instance on port 2222 Connections to IP B port 22 will be redirected to my instance on port 4444

What is the best way to do this?

Thanks in advance, Rafael Grether

asked 5 months ago140 views
2 Answers
1
Accepted Answer

Hello.

It is possible to attach multiple Elastic IP addresses to an EC2 instance.
The number of ENIs that can be set varies depending on the instance type, so please check the document below.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI

You will need to follow the steps in the document below to add the secondary private IP and then add the corresponding Elastic IP address.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/MultipleIP.html#working-with-multiple-ipv4

I think it depends on the reason why you want to change the port number, but I thought that if SSH connections were controlled by security groups, there would be no need to change it.

profile picture
EXPERT
answered 5 months ago
profile pictureAWS
EXPERT
reviewed 5 months ago
  • Thanks for your reply.

    I read that I cannot associate two elastic IP to an instance:

    "If you associate an Elastic IP address with an instance that already has an Elastic IP address associated, the previously associated Elastic IP address will be disassociated, but the address will still be allocated to your account".

    But I understand that I need to associate a new elastic IP to a Network Interface, not an Instance.

    In this case I need to create a new network interface (eni) and new private IP? And how can I associate the new eni to my instance too?

    In my particular case I don't need to change the SSH port number. It was just an example to illustrate my needs in simple way.

    I'm building two IRC Servers in the same host that listening in default 6697 port and other in 7697 port. But for external, I need booth listening in 6697 default port. So, one IRC server accessible by one public IPv4 address, and other IRC Server by second public IPv4 address.

    But in my unix host, if I can filter the origin (first or second interface), I can redirect the port <second IP>:6697 to HOST:7697.

    Thanks in advance Rafael Grether

0

You can allocate a 2nd IP to an EC2 instance by allocating a 2nd elastic IP, however both ports 2222 and 4444 will be available on BOTH IP addresses.

I dont believe there is any way around this.

profile picture
EXPERT
answered 5 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