Two Public IPv4 Elastic IP inside one Instance? Or there is a better solution?


Hey folks!

Please give me some guidance. I believe that I need to have two elastic IPv4s attached to the same instance.

I have two IRC servers. (eg IP and (eg. IP

Clients will connect to these IRC servers both over port 6697.

I want both IRC servers to run on the same AWS EC2 instance.

I know I can have 2 public IPv4 interfaces, so I can put the IRC servers listening on each interface on port 6697.

But I just need a gateway, which redirects port 6697 from client to another port running on my instance. This way I can put irc server A and irc server B running on different ports with a single interface. It is possible?

I don't have route53, as this service is not available in my country.

What do you suggest to me?

Many thanks,

asked 5 days ago142 views
1 Answer

To have both services listening on the same port for your users and assuming that the service is expected to be available over IPv4 only, the simplest solution is to configure your EC2 instance with two ENIs (elastic network interfaces), allow DHCP to allocate private IPs for them, and associate an Elastic IP with each of the ENIs.

You can also configure your VPC in dual-stack mode, so that also IPv6 addresses get assigned to the ENIs. The IPv6 addresses within your VPC will be accessible from the public internet via an IGW (internet gateway) as they are, as long as the routes and security group rules allow traffic to pass, without having to allocate separate public IPs. You can point your customers to the IPv4 EIPs with DNS A records and to the IPv6 addresses with AAAA records.

Intermediate port mapping could be done with a Network Load Balancer (NLB), but that would just increase costs in your case. The second ENI doesn't cost anything on instance types that support two ENIs, while two NLBs (needed to point the listener port on each of the two EIPs to different destinations) would cost at least around ~$32/month, depending on the region. In both cases, you'll have to pay the same amount for the two public IPv4 addresses.

Leo K
answered 5 days 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