From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020826 Description of problem: Net::Ping succeeds regardless of port assignment The Net::Ping library, on Red Hat Linux 8.0, seems to ignore the port specified and only checks whether a given host is active or not. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Run the attached script, modifying it to point to a port that is listening on localhost. 2. Run the attached script, modifying it to point to a port that is NOT listening on localhost. Actual Results: On Red Hat Linux 8.0: 1. Script printed "Able to connect..." 2. Script printed "Able to connect..." Expected Results: Observed on Red Hat Linux 7.3: 1. Script prints "Able to connect..." 2. Script prints "Unable to connect..." Additional info:
Created attachment 88250 [details] Test script
Can someone test the script provided in this report and verify if this is still an issue?
Yep, it's an issue on FC3 (perl-5.8.5-12.FC3) and FC4 (perl-5.8.6-15). I could reproduce the failure on a Solaris and a Debian box too, so it looks like an upstream issue. See also http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Ping On a side note, the issue (all tcp pings succeed even for non-open ports) seems to occur here only when pinging a local IP address, others appear to work as expected. But that could be a coincidence.
I'm not sure this is actually a bug. As the Net::Ping manual states: $p->service_check( { 0 | 1 } ); Set whether or not the connect behavior should enforce remote service availability as well as reachability. Normally, if the remote server reported ECONNREFUSED, it must have been reachable because of the status packet that it reported. With this option enabled, the full three-way tcp handshake must have been established successfully before it will claim it is reachable. So adding $p->service_check(1); before the $p->ping($host); in the example script attachment makes it only succeed if a tcp server is actually listening to the $port on $host, which I believe was the intent, and which resolves the problem described in this bug. Yes, I agree if a port is specified for a TCP ping, a full connect(2) attempt should be made, but this is not how Net::Ping was designed or documented to work - a tcp ping only verifies that the host is reachable, unless the service_check(1) option is specified . Hence, this bug is being closed as NOTABUG - if you disagree, please re-open it.