A script I wrote that checks whether a host is reachable by various protocols like ICMP & TCP.

Posted: February 20, 2013. At: 9:06 AM. This was 5 years ago. Post ID: 5393
Page permalink: http://securitronlinux.com/bejiitaswrath/a-script-i-wrote-that-checks-whether-a-host-is-reachable-by-various-protocols-like-icmp-tcp/

Now, we must convince Congress to stop the FCC. Can you display an alert?
use warnings;
use Net::Ping;
# code source: http://www.perlmonks.org/?node_id=943892
# More: http://stackoverflow.com/questions/3960595/how-can-i-ping-a-host-with-a-perl-one-liner-with-netping
#$| = 1;
print "Please type a host to check..n";
$host = <>;
if (length($host) < 3) {
    print "You did not type a host!n";
my @proto = ("tcp", "udp", "icmp", "stream", "syn");
foreach my $pro ( @proto ) {
    print "nProtocol $pro n";
    my $p = Net::Ping->new($pro);
    # Specify source interface of pings
    print "$host is ";
    print "NOT " unless $p->ping($host, 2);
    print "reachable.n";

This Perl script will check whether a web host is up using a handful of protocols to ping the host. Very useful script. This requires root access.

No comments have been made. Use this form to start the conversation :)

Leave a Reply