I have two EC2 instances on AWS. I attach a second network interface to one of the EC2 instances and configure Redhat to use the new interface and IP.
The problem is that I can't ping the EC2 instance over the second NIC.
I was reading that asymmetric routing has to be prevented for this but I did not manage to this correctly. My steps were as follows.
1) Setup the new NIC because it does not get the new IPv4 automatically.
cd /etc/sysconfig/network-scripts/
cat ifcfg-eth0 > ifcfg-eth1
The eth1 config looks as follows.
BOOTPROTO=dhcp
DEVICE=eth1
HWADDR=02:d9:f6:0e:09:00
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPADDR=192.168.125.232
ifdown eth1
ifup eth1
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 192.168.125.247 netmask 255.255.255.224 broadcast 192.168.125.255
inet6 fe80::3d:5cff:fef4:f5a8 prefixlen 64 scopeid 0x20<link>
ether 02:3d:5c:f4:f5:a8 txqueuelen 1000 (Ethernet)
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 192.168.125.232 netmask 255.255.255.224 broadcast 192.168.125.255
inet6 fe80::d9:f6ff:fe0e:900 prefixlen 64 scopeid 0x20<link>
ether 02:d9:f6:0e:09:00 txqueuelen 1000 (Ethernet)
[...]
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.125.225 0.0.0.0 UG 100 0 0 eth0
0.0.0.0 192.168.125.225 0.0.0.0 UG 101 0 0 eth1
192.168.125.0 0.0.0.0 255.255.255.0 U 100 0 0 eth1
192.168.125.224 0.0.0.0 255.255.255.224 U 100 0 0 eth0
192.168.125.224 0.0.0.0 255.255.255.224 U 101 0 0 eth1
2) Trying to setup asymmetric routing like this.
ip route add default via 192.168.125.225 dev eth0 tab 1
ip route add default via 192.168.125.225 dev eth1 tab 2
ip rule add from 192.168.125.247/24 tab 1
As soon as I run the above command I get disconnected from the instance and I can't reconnect via SSH. After this I just re-create the instance.
I never manage to run the last command, which I think is needed.
ip rule add from 192.168.125.232/24 tab 2
What am I missing? How do I set up the routing correctly for my setup?
EDIT #1: New try with new IP addresses won't work.
ip route add 192.168.125.224/27 dev eth0 table t1
ip route add 192.168.125.224/27 dev eth1 table t2
ip route add default via 192.168.125.225 dev eth0 table t1
ip route add default via 192.168.125.225 dev eth1 table t2
ip rule add from 192.168.125.243/27 table t1 priority 100
ip rule add from 192.168.125.232/27 table t2 priority 200
ip route flush cache
The workaround to disable source/destination check works but is not really something I want.
EDIT #2: After even more googling and pulling hair out of my head. Another try (not working :/).
ip route add default via 192.168.125.225 dev eth0 table t1
ip route add default via 192.168.125.225 dev eth1 table t2
ip rule add from 192.168.125.243/32 table t1 priority 100
ip rule add from 192.168.125.232/32 table t2 priority 200
ip route flush cache
The answer is to configure a route and a rule for both interfaces.
The ip commands can be added to
/etc/rc.d/rc.local
for persistent settings.