Networking – AWS EC2 Not Responding to Both EIPs

amazon ec2networking

I h ave an Ubuntu EC2 server, and I'm not sure if my issue is related to Ubuntu or AWS.

Basically I have an EC2 server running HAProxy that I'm using as my load balancer, but I'm trying to set up a second redundant one by having an elastic network interface with it's own elastic IP (the main remote IP of my DB cluster) so that if one goes down I can move the network interface from once instance to the next in case of failure.

Now all that works quite well actually, the problem comes from the fact the my Ubuntu instance doesn't seem to see or respond to any requests made with the IP address of the second network interface. Everything works fine from the primary address, but I can't get a response of any kind from the second.

Am I missing a step in my AWS configuration? Or is there something on the Ubuntu side of things that I need to modify for it to work with both interfaces?


Also, just tested it, and I cannot ping both private IPs from another server the network. I can ping the first private IP, but not the second.

Best Answer

Alright, so the issue was definitely on the Ubuntu side, but I figured it all out.

You can use this to enable an IP address alias on the primary network interface that allows you to use two IP addresses on a single nic (ens3 is the network interface, usually called eth0 but for some reason the AWS device is called this instead)

ip address add 172.31.0.0/24 dev ens3

And then if you want to keep those settings on reboot, you'll need to add the following to nano /etc/network/interfaces

auto ens3:1
iface ens3:1 inet static
address 172.31.0.0 #your secondary private IP
gateway 172.31.48.1 #your gateway, get with `ip route`, after "default via "
netmask 255.255.240.0 #get the "Mask" with `ipconfig` from your nic

And reboot and you should be all good to go!

Related Question