- Newest
- Most votes
- Most comments
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.
Relevant content
- asked 2 years ago