2

I've looked everywhere and haven't found a good solution to the following problem:

I'd like to set up an ec2 instance with 2 public ip addresses, with 2 rails servers each using one IP address. They would accept incoming requests on their own separate ip addresses, and outbound requests would also come from those unique addresses. I would be using the most up-to-date amazon linux AMI.

Is this even possible?

Thanks!

2
  • How to do it for incoming and outgoing connections is really two separate questions. Depending on the OS, you might be able to find one approach that will simultaneously cover both, but you haven't specified which OS you are using.
    – kasperd
    Jan 15, 2015 at 20:49
  • I have added the OS to the initial question as an edit. Ideally it would be the most up to date Amazon Linux AMI, but Ubuntu 14.04 would also be alright. Jan 15, 2015 at 23:53

2 Answers 2

0

you could set up two ELBs, one for each app, and both associated to same instance.

2 rails servers each using one IP address. They would accept incoming requests on their own separate ip addresses, and outbound requests would also come from those unique addresses.

make each rails app listen on diff port (same ip, diff port, only need one ip). one elb points to one port, the other elb to the other port. in the response to the client, the source IP should then be each app/port/rails respective elb ip, and each rails app would have that same external incoming elb dnsname/ip

0

There is a lot of information on configuring Elastic Network Interfaces here, which seems like it will get you what you want or perhaps give you an idea of what is possible (on an EC2 instance within a VPC).

Excerpt:

Elastic Network Interfaces (ENI)

An elastic network interface (ENI) is a virtual network interface that you can attach to an instance in a VPC. An ENI can include the following attributes:

  • a primary private IP address
  • one or more secondary private IP addresses
  • one Elastic IP address per private IP address
  • one public IP address, which can be auto-assigned to the network interface for eth0 when you launch an instance, but only when you create a network interface for eth0 instead of using an existing network interface
  • one or more security groups
  • a MAC address
  • a source/destination check flag
  • a description

You can create a network interface, attach it to an instance, detach it from an instance, and attach it to another instance. The attributes of a network interface follow the network interface as it is attached or detached from an instance and reattached to another instance. When you move a network interface from one instance to another, network traffic is redirected to the new instance.

Each instance in a VPC has a default network interface. The default network interface has a primary private IP address in the IP address range of its VPC. You can create and attach additional network interfaces. The maximum number of network interfaces that you can use varies by instance type. For more information, see Private IP Addresses Per ENI Per Instance Type.

Attaching multiple network interfaces to an instance is useful when you want to:

  • Create a management network.
  • Use network and security appliances in your VPC.
  • Create dual-homed instances with workloads/roles on distinct subnets.
  • Create a low-budget, high-availability solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .