-1

Fping doesn't work with exit code 4.

Given:

$ fping 8.8.8.8
$
$ echo $?
4
$ fping -h
$ echo $?
4

Then you comment some verbosity flags related if-s in the fping code, build it and see:

./build/usr/local/sbin/fping: icmp: unknown protocol

Strace:

execve("/usr/bin/fping", ["fping", "ya.ru"], 0xbec606ec /* 23 vars */) = 0
brk(NULL)                               = 0x1268000
uname({sysname="Linux", nodename="blablabla.com", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f8c000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=40040, ...}) = 0
mmap2(NULL, 40040, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f82000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\371p\1\0004\0\0\0"..., 512) = 512
_llseek(3, 944172, [944172], SEEK_SET)  = 0
read(3, "\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\0\0\0\0\0\0"..., 3000) = 3000
_llseek(3, 937548, [937548], SEEK_SET)  = 0
read(3, "A4\0\0\0aeabi\0\1*\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\3\f"..., 53) = 53
fstat64(3, {st_mode=S_IFREG|0755, st_size=947172, ...}) = 0
mmap2(NULL, 1013128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e6e000
mprotect(0xb6f50000, 65536, PROT_NONE)  = 0
mmap2(0xb6f60000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe2000) = 0xb6f60000
mmap2(0xb6f63000, 9608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f63000
close(3)                                = 0
set_tls(0xb6f8cdd0)                     = 0
mprotect(0xb6f60000, 8192, PROT_READ)   = 0
mprotect(0x515000, 4096, PROT_READ)     = 0
mprotect(0xb6f8e000, 4096, PROT_READ)   = 0
munmap(0xb6f82000, 40040)               = 0
brk(NULL)                               = 0x1268000
brk(0x1289000)                          = 0x1289000
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=627, ...}) = 0
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 627
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=40040, ...}) = 0
mmap2(NULL, 40040, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f82000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\254\r\0\0004\0\0\0"..., 512) = 512
_llseek(3, 21220, [21220], SEEK_SET)    = 0
read(3, "\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\0\0\0\0\0\0"..., 1080) = 1080
_llseek(3, 20892, [20892], SEEK_SET)    = 0
read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 51) = 51
fstat64(3, {st_mode=S_IFREG|0644, st_size=22300, ...}) = 0
mmap2(NULL, 87672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e58000
mprotect(0xb6e5d000, 61440, PROT_NONE)  = 0
mmap2(0xb6e6c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb6e6c000
close(3)                                = 0
mprotect(0xb6e6c000, 4096, PROT_READ)   = 0
munmap(0xb6f82000, 40040)               = 0
exit_group(4)                           = ?
+++ exited with 4 +++
2

There is nothing to do with process capabilities and file permissions (for example setuid bit mentioned all over the Internet). Also this doesn't refer to any firewall rules, ICMP blocking or like. And your kernel obviously knows what is ICMP. For example:

$ sysctl net.ipv4 | grep icmp | wc -l
8

And

$ grep ICMP /etc/protocols 
icmp    1   ICMP        # internet control message protocol

You can see that there is nsswitch.conf opened and read, the same for libnss_compat.so.2, then the process exits. Open the nsswitch.conf and see:

protocols:      compat
services:       compat

The legacy emulation option, default for some distros. Change those to files.

Now

$ fping 8.8.8.8
8.8.8.8 is alive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.