Linux – Don’t get ICMP reply when ping from specific interface

ip-routingiptableslinuxpingrouting

I have a linux machine running under CentOS with 2 ISP. My rollover ISP channel script try to determine when we at secondary ISP channel is there a primary ISP channel get up and vice versa when need to change from primary to secondary. Normal thing.

To do this i want to ping from interface which now is not default gateway.

My 2 ifaces is eth1 is primary and eth2 secondary.

When we at eth1 for example and want to check is there internet on eth2. Eth2 is in up state.

ping -I eth2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 1.2.3.4 eth2: 56(84) bytes of data.
^C
--- 8.8.8.8 ping statistics ---
15 packets transmitted, 0 received, 100% packet loss, time 14173ms

But my running tcpdump shows that packets are sent and delivered to server, but some reasons don't seen by ping utility. Why is that i have no idea? What may be cause?

tcpdump:

17:36:42.191153 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
    1.2.3.4 > 8.8.8.8: ICMP echo request, id 44138, seq 1, length 64
17:36:42.235899 IP (tos 0x0, ttl 59, id 30465, offset 0, flags [none], proto ICMP (1), length 84)
    8.8.8.8 > 1.2.3.4: ICMP echo reply, id 44138, seq 1, length 64
17:36:43.190616 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
    1.2.3.4 > 8.8.8.8: ICMP echo request, id 44138, seq 2, length 64
17:36:43.235363 IP (tos 0x0, ttl 59, id 31136, offset 0, flags [none], proto ICMP (1), length 84)
    8.8.8.8 > 1.2.3.4: ICMP echo reply, id 44138, seq 2, length 64
17:36:44.190575 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
    1.2.3.4 > 8.8.8.8: ICMP echo request, id 44138, seq 3, length 64
17:36:44.235346 IP (tos 0x0, ttl 59, id 32083, offset 0, flags [none], proto ICMP (1), length 84)
    8.8.8.8 > 1.2.3.4: ICMP echo reply, id 44138, seq 3, length 64
17:36:45.190554 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
    1.2.3.4 > 8.8.8.8: ICMP echo request, id 44138, seq 4, length 64
17:36:45.235368 IP (tos 0x0, ttl 59, id 32355, offset 0, flags [none], proto ICMP (1), length 84)
    8.8.8.8 > 1.2.3.4: ICMP echo reply, id 44138, seq 4, length 64

netstat -rn shows that eth2 not default gateway sure, but it eth1.

Best Answer

ICMP packets generated by ping may be filtered out by over zealous firewall on the path. traceoute may help to locate such problem.