AWS second elastic IP not working after correct dh

2019-03-03 13:55发布

问题:

EDIT: Solved, routing table did not update properly. as was answered.

On AWS and Ubuntu 16.04, a 2nd network interface is attached with 2nd elastic IP.

Instance details show 2 private IPs, dhclient eth1 up works properly. ifconfig shows netmask, hwaddr and broadcast correctly. 1st and 2nd IPs use the same security group, 1st IP works.

Yet instance details show only 1 public/elastic IP, and I can't connect to the second elastic IP. Any ideas on debugging this will be appreciated.

Fixed by the following commands: ip route add default via 10.10.2.1 dev eth0 tab 1

ip route add default via 10.10.2.1 dev eth1 tab 2

ip rule add from IP_1 tab 1

ip rule add from IP_2 tab 2

回答1:

This is because you have multiple network interfaces on the same subnet, so your OS is not sending it out of the right interface. You will need to use source based routing on your instance to make this work.



回答2:

echo 2 > /proc/sys/net/ipv4/conf/default/rp_filter
echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter

To make this change persistence

net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.all.rp_filter = 2

** Tested AWS Environment