Posted by & filed under AWS/Linux/Unix/Devops stuff.

Assigning a second network interface within the EC2 console and setting up the additional OS configuration is not terribly hard (I used the instructions here), but there was an extra catch to routing my EIP though this interface…

Assigning a second network interface within the EC2 console and setting up the additional OS configuration is not terribly hard (I used the instructions here):

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
post-up ip route add default via g.g.g.g dev eth0 tab 1
post-up ip rule add from x1.x1.x1.x1/32 tab 1 priority 500

auto eth1
iface eth1 inet dhcp
post-up ip route add default via g.g.g.g dev eth1 tab 2
post-up ip rule add from x2.x2.x2.x2/32 tab 2 priority 600

where x1.x1.x1.x1 and x2.x2.x2.x2 are my Private IP addresses. g.g.g.g is the IP gleaned from the existing route table. To get it, run ip route show on the command line and make a note of the IP with the line default via g.g.g.g dev eth0

However, when assigning the EIP in the EC2 console I discovered that you can’t just assign the EIP to the instance (as it will presumably default to eth0), it must be assigned to the network interface.