Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show result when fping a domain with DNS error #357

Open
tinyhare opened this issue Nov 1, 2024 · 1 comment
Open

Don't show result when fping a domain with DNS error #357

tinyhare opened this issue Nov 1, 2024 · 1 comment
Labels

Comments

@tinyhare
Copy link

tinyhare commented Nov 1, 2024

I use fping to do check with domain and ip mixed,like this:

root@linux:~# fping 8.8.8.8 google.com -q -c 3
8.8.8.8    : xmt/rcv/%loss = 3/3/0, min/avg/max = 55.1/64.1/76.7
google.com : xmt/rcv/%loss = 3/3/0, min/avg/max = 125/131/136

When the network breakdown,DNS is out of work,and after the DNS cache expired,
the result looks like this:no domain result

root@linux:~# fping 8.8.8.8 google.com -q -c 3
8.8.8.8 : xmt/rcv/%loss = 3/0/100

If there is a domain result will simplify the script logic afterwards.

I want the result like this:

root@linux:~# fping 8.8.8.8 google.com -q -c 3
8.8.8.8 : xmt/rcv/%loss = 3/0/100
google.com : xmt/rcv/%loss = 0/0/100

Should this be a new feature?

@auerswal
Copy link
Collaborator

fping first adds all given targets (hosts) to an internal table, and then sends probes to every target in this table. DNS name resolution happens during the first phase only. If DNS resolution of a target given as a name fails, it is not added to the internal table, and the later fping code does not know about it. Only a counter for name resolution errors is increased.

If you do not use -q, an error message is printed:

$ fping 8.8.8.8 name.is.invalid
name.is.invalid: Name or service not known
8.8.8.8 is alive
$ fping -c3 8.8.8.8 name.is.invalid
name.is.invalid: Name or service not known
8.8.8.8 : [0], 64 bytes, 12.8 ms (12.8 avg, 0% loss)
8.8.8.8 : [1], 64 bytes, 13.3 ms (13.0 avg, 0% loss)
8.8.8.8 : [2], 64 bytes, 13.6 ms (13.2 avg, 0% loss)

8.8.8.8 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 12.8/13.2/13.6

With -s, the number of names that could not be resolved is printed after pinging usable targets:

$ fping -s 8.8.8.8 name.is.invalid
name.is.invalid: Name or service not known
8.8.8.8 is alive

       1 targets
       1 alive
       0 unreachable
       1 unknown addresses

       0 timeouts (waiting for response)
       1 ICMP Echos sent
       1 ICMP Echo Replies received
       0 other ICMP received

 15.6 ms (min round trip time)
 15.6 ms (avg round trip time)
 15.6 ms (max round trip time)
        0.025 sec (elapsed real time)

If no IP address for a target is found, the exit code is set to 2. You could check this in a script:

$ fping -qc3 8.8.8.8 name.is.invalid ; echo "(fping exit code is $?)"
8.8.8.8 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 13.5/13.9/14.4
(fping exit code is 2)

I would expect that quite a bit of effort and changes to fping would be required to add the behavior you expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants