I found fping very handy when I need to ping lots of IP addresses concurrently, thank you for providing this great tool!
Recently I noticed an issue when I want to bind to a particular interface using fping.
My server machine has multiple interfaces, you can see that if I use "ping" with the same binding (eth2), it works. But if I use fping binding to eth2, it doesn't work. (claim unreachable). And then if I remove "-I eth2" from fping command line, it works again!
I am wondering if there is a bug when working with the interface binding for fping since "ping" works with eth2 binding..
This is fairly easily reproducible: on my local machine, if I use binding to ping the ip address configued on that interface, it will say "unreachable". I am wondering why Linux system respond to fping and ping differently? Thanks!
=============================================
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ifconfig eth2
eth2 Link encap:Ethernet HWaddr 00:50:56:9F:79:8E
inet addr:10.80.69.110 Bcast:10.80.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:18101440 errors:0 dropped:35509 overruns:0 frame:0
TX packets:7480471 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7763913987 (7.2 GiB) TX bytes:5479977217 (5.1 GiB)
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ifconfig eth3
eth3 Link encap:Ethernet HWaddr 00:50:56:9F:B3:8B
inet addr:10.80.69.111 Bcast:10.80.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:17347650 errors:0 dropped:35516 overruns:0 frame:0
TX packets:9847398 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
==> fping doesn't work with "-I eth2"
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# fping -I eth2 10.80.69.110
10.80.69.110 is unreachable
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# fping -I eth2 10.80.69.111
10.80.69.111 is unreachable
===> fping works without "-I eth2"
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# fping 10.80.69.111
10.80.69.111 is alive
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# fping 10.80.69.110
10.80.69.110 is alive
==> ping works either way:
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ping -I eth2 10.80.69.110
PING 10.80.69.110 (10.80.69.110) from 10.80.69.110 eth2: 56(84) bytes of data.
^C
--- 10.80.69.110 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.019/0.027/0.035/0.008 ms
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ping 10.80.69.111
PING 10.80.69.111 (10.80.69.111) 56(84) bytes of data.
^C
--- 10.80.69.111 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ping -I eth2 10.80.69.110
PING 10.80.69.110 (10.80.69.110) from 10.80.69.110 eth2: 56(84) bytes of data.
^C
--- 10.80.69.110 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.022/0.022/0.022/0.000 ms
[controller-VMware-421f4145bd167fb7-1b45bb987799c3bb:~]# ping 10.80.69.110
PING 10.80.69.110 (10.80.69.110) 56(84) bytes of data.
^C
--- 10.80.69.110 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.020/0.020/0.020/0.000 ms
=============
strace shows "fping -I eth2 " indeed didn't get response back:
sendto(3, "\10\0\254\206Ky\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64, 0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.80.69.111")}, 16) = 64
select(4, [3], [], NULL, {0, 500060}) = 0 (Timeout)
sendto(3, "\10\0\254\205Ky\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64, 0, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.80.69.111")}, 16) = 64
select(4, [3], [], NULL, {0, 750000}) = 0 (Timeout)
====
While ping get response back.
sendmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.80.69.111")}, msg_iov(1)=[{"\10\0\346\6L<\0\1\266\307\fY\0\0\0\0;\310\10\0\0\0\0\0\20\21\22\23\24\25\26\27"..., 64}], msg_controllen=32, {cmsg_len=28, cmsg_level=SOL_IP, cmsg_type=, ...}, msg_flags=0}, 0) = 64
recvmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("10.80.69.111")}, msg_iov(1)=[{"E\0\0T\23\v\0\0@\1\310!\nPEo\nPEn\0\0\356\6L<\0\1\266\307\fY"..., 192}], msg_controllen=32, {cmsg_len=32, cmsg_level=SOL_SOCKET, cmsg_type=0x1d /* SCM_??? */, ...}, msg_flags=0}, 0) = 84