This guide assumes you've configured your ENI inside linux instance. After you've assigned second ip address to your ENI in the AWS console, you need to reconfigure your interface inside intance.
Assume your interface name: eth1 Assume your second ip: $second_ip From the guide, mentioned above, the content of /etc/network/interfaces.d/eth1.cfg should look like:
auto eth1
iface eth1 inet static
address $your_ip_addr
netmask $your_mask
up ip route add default via $your_gateway dev eth1 table $your_table_name
up ip rule add from $your_ip_addr/32 table out
up ip rule add to $your_ip_addr/32 table out
up ip route flush cache
You should update this file with a few lines, so it would look like this:
auto eth1
iface eth1 inet static
address $your_ip_addr
netmask $your_mask
up ip route add default via $your_gateway dev eth1 table $your_table_name
up ip rule add from $your_ip_addr/32 table out
up ip rule add to $your_ip_addr/32 table out
up ip route flush cache
#second ip
iface eth1 inet static
address $second_ip
netmask $your_mask
up ip rule add from $second_ip/32 table $your_table_name
up ip rule add to $second_ip/32 table $your_table_name
Don't forget to restart your interface:
ifdown eth1
ifup eth1
Note: you won't be able to see your secondary ip with ifconfig eth1
command, you should use ip address show eth1
instead.