From: brabuhr@... Date: 2010-12-23T23:55:46+09:00 Subject: Re: net-ping error says "false" though server can be reached On Thu, Dec 23, 2010 at 3:28 AM, Athreya Vc wrote: > I am trying a do a ping check on a server > > > irb(main):006:0> HOST='192.168.1.2' > => "192.168.1.2'" > > irb(main):007:0> Ping.pingecho(HOST) > => false > > Am I missing something here? It would help us see what's wrong if you included [more] complete code, but I've been using something like this: > cat p.rb require 'rubygems' require "net/ping" def ping host Net::Ping::TCP.econnrefused = true ping_obj = Net::Ping::TCP.new(host, 22, 1) ping_obj.ping? end p ping(ARGV[0]) > ruby p.rb localhost true > ruby p.rb foozle false > ping -c 1 foozle ping: unknown host foozle > ruby p.rb ******** true > ping -c 1 ******** 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.146/0.146/0.146/0.000 ms This type of TCP ping breaks down if I try to ping outside the firewall: > ruby p.rb www.yahoo.com false > ping -c 1 www.yahoo.com --- ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 36.570/36.570/36.570/0.000 ms