Specific case
You want to ping the "nearest" fixed IP that is non-routable when the ISP enters traffic overload state. On my system I can emulate this situation by failing the ADSL authentication. In that case, by comparing the results of traceroute -n
in normal and abnormal conditions, I see that the first hop to 8.8.8.8 (or any surely external site) that does not respond is 151.6.68.45, which is part of my ISP's infrastructure.
By using that IP as a "check-alive" host (after repeating the test just to be sure it is fixed), I can detect an ISP anomaly without getting a false positive in case the ADSL is OK, but the ISP routing has troubles.
Of course, I could use 8.8.8.8 on purpose, reasoning that if I can't reach Google's infrastructure, I don't care about the reason, I might as well try with the backup router.
General case
"internet is available" is a much more complicated thing than simply "Is 8.8.8.8 (or other IP) reachable".
For a quick, dirty and not always reliable check, pinging 8.8.8.8 is good. But seeing as how you use a numeric IP instead of a domain name, you've already cottoned up to the fact that you might have IP connectivity and still "no Internet" because of DNS problems.
A complete diagnostic would have to start close to your PC.
- query local network configuration and retrieve gateway and DNS server.
- ping the gateway. It should be reachable. If not, there's a local problem.
- run a traceroute with short TTL (actually, a TCP traceroute such as the one provided by hping is better) of a surely external address, 8.8.8.8 is okay.
- you want to see that, after your gateway, some extra nodes are responding.
For example in Windows XP at home I have:
1 <1 ms <1 ms <1 ms 192.168.4.200 -- (constant) Home Linux box (gateway)
2 <1 ms <1 ms <1 ms 192.168.0.1 -- (constant) ADSL modem
3 * * * * -- WAN interface, always fails; expected
4 * 6 ms 6 ms 151.6.64.30 -- (varies) ISP gateway
Now try pinging DNS. It should be reachable. Even better, run a simple DNS check. In order to avoid DNS caches, I sometimes use some domain which will answer to all queries no matter what. So for example
$ host randomasdfdsasdqwerty987667.godaddy.com
randomasdfdsasdqwerty987667.godaddy.com has address 97.74.104.201
while if the DNS server is unreliable, the same query might return the address of the captive portal for wifi
$ host randomasdfdsasdqwerty987667.godaddy.com
captiveportal.homenet has address 192.168.4.200
or 127.0.0.1, or even an error.
In case of DNS failures I may try a traceroute of the DNS IP address (or a different DNS such as OpenDNS's ones). That will not only tell me whether the problem is the DNS or the ISP, it will often allow me to work around the interruption.
If everything goes OK at this point I know that the connection is in working order, in general; it may still fail for some sites. All I need now is for isup.me
to be up :-), then checking
http://www.isup.me/www.google.com
http://www.isup.me/mail.google.com
or a site such as Down Detector will keep me informed about the "Internet weather".
Actually, on my home server there's a Squid cache and the error page contains the last data retrieved successfully from down-site statistics, so I may see something like
Google.com is not reachable
STORM ALERT: 12 out of 14 sites are unreachable!
just as it happened this last Friday here in Italy.
IANA reserves the domain
example.com
and provides a test server. It is reachable through both HTTP and HTTPS. I am not sure if the IETF maintains similar test servers. You should probably use a test server like IANA's; and you should probably avoid hitting production servers like Google DNS. – jww – 2018-10-11T20:46:53.3931I would suggest you test for what you actually want. When you say "Internet is available", what do you mean? – David Schwartz – 2014-06-15T09:24:30.553
1@DavidSchwartz he means that the internet is not unavailable. If you want a specific test, much is going to be WAN based so not an option to test 'cos it's past the wall but the ISP would know. – barlop – 2014-06-15T12:07:50.267
5
ping stackexchange.com
;) – None – 2014-06-15T13:16:14.2006@barlop That's kind of funny, but not helpful. What does "the internet is not unavailable" mean? If I can't reach Google's website, is "the internet unavailable"? If DNS works but no web pages work, is the internet available? The first step to answering a question is understanding the question. – David Schwartz – 2014-06-15T15:00:34.377
4@DavidSchwartz I was't joking,and considering that he's talking about pinging a google related IP as a test,and not pinging a domain like www.google.com as a test,he obviously means that in a case where DNS is unavailable but everything else is available,then he considers the Internet is available.i.e.not unavailable.If u want to find a question mark,it'd b whether a poor router is 'internet unavailable' but obviously if u could provide a test 4 that scenario vs WAN available,or specifics within that,it'd be more helpful than just giving him a test for just one specific case or worse,no cases. – barlop – 2014-06-15T20:05:04.283
1http://www.downforeveryoneorjustme.com/ – Robotnik – 2014-06-16T01:00:56.410
This question would be more answerable with some details on scope. The types of answers that might make sense for a site-local script that you can edit when necessary are going to be a lot different than the types of answers that would make sense for an embedded device (home routers, settop boxes, in-car devices, ...). – R.. GitHub STOP HELPING ICE – 2014-06-16T04:43:02.117
1*"This program is intended for use in network testing, measurement and management. Because of the load it can impose on the network, it is unwise to use ping during normal operations or from automated scripts."* - from
man ping
. – RedGrittyBrick – 2014-06-16T15:42:41.367@barlop I think you're assuming that he intends or desires the results his particular test happens to get. If so, then his test is, almost by definition, perfect. But without knowing for sure what results he actually wants, there's no way to advise him on what might be a good test. – David Schwartz – 2014-06-16T16:44:30.373
1I guess that if Google didn't want you to ping their DNS server, they just would block incoming ICMP requests from internet and only allow them on VPNs – AlexC – 2014-06-16T17:12:34.690
1@DavidSchwartz I am not assuming that. As I said, we can assume he knows about ISP's DNS servers being down. And, we can assume he doesn't mean a firewall or an ethernet card or anything specific to an individual computer. He -may- mean to include router issue, and he would probably accept anything more upstream(it'd certainly answer his q).I really don't think you'd be going far wrong if you could even name some tests.Maybe he or some reading looking for an answer to the question he wrote, doesn't know specifics about WANs and he'd appreciate some tests he can do that mention some specifics. – barlop – 2014-06-16T21:41:23.227
1@DavidSchwartz I think the definition of "internet is up" is quite clear: "Internet" refers to IP transit (to all Tier 1 networks and their peers). DNS has nothing to do with this. – Navin – 2014-06-17T10:49:33.803
Why not ping more than one ip? That would be more reliable. One of Yahoo, one of Google, one of SE, one of FB, one of Twitter, one of Youtube, one of imdb, one of xkcd, one of imgur, one of Reddit... – user3459110 – 2014-06-17T11:18:19.387
@Navin That's an unusual definition of "Internet is up", though a reasonable one. I certainly wouldn't assume that's what someone means. – David Schwartz – 2014-06-17T17:58:20.000