What is a external reliable IP address to ping to check if internet is available?

54

13

Is there any common always up server, which I can setup to ping in automatic mode to detect internet is available? Like Google or something? May be 8.8.8.8?

My specific situation is that I am using dual WAN router. Each WAN is connected to one of ISPs. When my money is ending on one of ISP, it is not blocking the channel. Instead, it redirects to a warning page. So, router thinks internet is on, because data is traveling. Other option for this router is to ping for some address to check if internet is on.

I wonder, if I ping 8.8.8.8, won't I be banned by Google for inappropriate usage? I suspect, that Google might have some quotas. If I will ping it's name servers too often, then I will sometimes get DNS rejects .

Dims

Posted 2014-06-15T08:51:41.083

Reputation: 8 464

Question was closed 2014-06-19T19:03:32.163

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.393

1I 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

5ping stackexchange.com ;) – None – 2014-06-15T13:16:14.200

6@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

Answers

56

Try to ping 8.8.8.8, it's Google primary DNS server. I always ping it to verify my connection and I never found it down. Alternatively you can try 8.8.4.4, which is Google secondary DNS.

AlexC

Posted 2014-06-15T08:51:41.083

Reputation: 662

@AlexC Whats the complete command to use here if you can send?Thanks – pal4life – 2017-02-16T01:32:32.187

@pal4life 'ping 8.8.8.8 -t' in cmd.exe – AlexC – 2017-03-09T13:54:16.920

@CaptainCodeman, ping does not work behind a proxy. So if you're at work or anywhere with proxy, ping will never work for external addresses (only for intranet addresses that don't require a proxy). – wisbucky – 2017-12-01T01:34:28.660

When behind a proxy and can't use ping, an alternative is to use curl 8.8.8.8:53 or wget. If it works, you'll get a 503 response back. (53 is the dns server port). – wisbucky – 2017-12-01T02:02:50.833

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:50:50.853

3ping accepts TLDs as well. Hence ping google.com should do the trick, in case you don't want to remember quadruple eight. – Johannes Pille – 2014-06-15T15:40:04.600

38@JohannesPille Pinging a domain name requires a working DNS server. It could thus fail if the DNS request failed, which does not imply that your internet connection is actually down. – Jonathan – 2014-06-15T15:53:47.750

3If your authoritative name server would be down, the net in your zone wouldn't be of much use, would it? – Johannes Pille – 2014-06-15T16:50:42.293

6@JohannesPille you could override your primary DNS to 8.8.8.8 instead of the DCHP default – ratchet freak – 2014-06-15T17:37:50.920

Auth servers and DNS server are completely different things. You can have a fully working connection to your ISP auth server, but the DNS server could be unreachable for some reason. That's why it's a good habit to edit the router settings to use Google's DNS servers instead of the ones the ISP provides. – AlexC – 2014-06-15T17:39:48.173

1Fair enuff, argument bought. ;) – Johannes Pille – 2014-06-15T17:59:41.800

1

+1 I always use 8.8.8.8 as well, with 8.8.4.4 as a backup. For non-Google, large ISP nameservers are usually a good bet (e.g. also this guy's strategy). Incidentally, I also always override my DNS servers with Google's, as my ISP's nameservers aren't very reliable.

– Jason C – 2014-06-15T18:46:32.310

Ping more than one IP, better if they're in very different network (ie: try not using two server from the same company) this way, if they all go down, there is a good chance you're internet is screwed, but if only one is down, it can be the server. Choosing them in different organization means that if that particular organization has networking problems (say, google has problem with their advertisement all of their network, which is possible) you won't think that YOUR link is down – Remi Letourneau – 2014-06-15T19:24:43.600

Good choice... Google Public DNS (8.8.8.8 and 8.8.4.4) are located in more than a dozen locations around the world using anycast for IP routing: https://developers.google.com/speed/public-dns/faq#locations

– David – 2014-06-15T20:47:44.017

6@JohannesPille ping doesn't accept TLDs. It also doesn't accept domain names. It is just so that most domain names are also host names and resolve to an IP address. So people could type http://example.com instead of http://www.example.com, before browsers were so smart to prepend www. to a hostname if it didn't work in the first place. (Try to ping army.mil if you don't believe me.) – Dubu – 2014-06-15T21:50:58.487

1When authoritarian countries "block Google", do they block 8.8.8.8 too? – 200_success – 2014-06-16T03:07:32.987

@200_success Possibly. I just tried to ping 8.8.8.8 from work and it timed out. – CaptainCodeman – 2014-06-16T06:57:00.607

The trouble with this is that the servers you are pinging are dedicated DNS servers. It's common for servers dedicated to a specific purpose to block ping requests (ICMP echo). Google's DNS servers do answer to ping, but is that reliable? I'm not sure that a DNS server responding to ping is a future-proof test of "Is the Internet reachable?" – Brandon – 2014-06-16T13:01:17.910

Also, it will claim the Internet is reachable just because you can ping Google's DNS servers. If, for example, you're on a purely private IP network where 8.8.8.8 is pingable, this will claim the Internet is reachable. – David Schwartz – 2014-06-16T16:45:51.607

1@David Isn't that true for any possible solution? Someone could create a shadow net that perfectly mirrored the existing internet in every way and form after all. In practice pinging google's DNS is extremely reliable for now and an easy to remember test. Could it stop working in the future? Sure, but again: Every solution has that problem in this case. – Voo – 2014-06-17T00:01:34.673

2How much did Google pay to get 8.8.8.8. Who owns 1.1.1.1 :)? – CMCDragonkai – 2014-06-17T08:16:37.323

33

You can do what microsoft does: check that

http://www.msftncsi.com/ncsi.txt

returns "Microsoft NCSI". (This verifies that you can get the correct data from a site, e.g. not a Wifi portal or something else).

You can also check (e.g. ping) that dns.msftncsi.com

points to 131.107.255.255 (this verifies that DNS is working).

See http://technet.microsoft.com/en-us/library/ee126135

NB: You can also visit http://www.msftconnecttest.com/redirect to get yourself through a captive portal if needed.

Mark Sowul

Posted 2014-06-15T08:51:41.083

Reputation: 2 877

1No longer works – user2924019 – 2017-06-09T09:18:58.540

1What doesn't work? The site still returns the right text, the dns still resolves to the right IP, the documentation still returns the right info – Mark Sowul – 2017-06-09T18:19:38.443

FYI you can't ping 131.107.255.255 - it times out. www.msftncsi.com goes through a1961.g2.akamai.net, which resolves to 23.59.182.83 at time of writing - I don't know whether that's a static IP or not. While this is a good answer to the question "what's a good URL to reliably test my internet connection" with e.g. cURL or a browser, it's not an IP than can be checked with a simple ping command so is not an answer to this specific question. – iono – 2018-09-17T10:30:51.747

You seem to be comingling the two different parts. You should be pinging dns.msftncsi.com; the purpose is to make sure DNS is working right (ensure it resolves to 131.107.255.255). You check the contents of http://www.msftncsi.com/ncsi.txt to make sure that you're actually able to get the correct data from a site (e.g. not a wifi login page or something else)

– Mark Sowul – 2018-09-24T12:47:27.163

NCSI is the abbreviation of "network connectivity status indicator" – Martin Thoma – 2019-06-05T08:56:02.357

1+1. IIRC, Windows also has an API for checking the level of internet connectivity using this method. – Navin – 2014-06-17T10:59:20.653

7Why isn't this more upvoted? one of the few really good ways, especially for the specific Question. If your ISP redirects your traffic to a warning page, checking the answer like this is one of the few reliable options! – Falco – 2014-06-17T15:35:02.647

13

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.

LSerni

Posted 2014-06-15T08:51:41.083

Reputation: 7 306

If you can ping 8.8.8.8, just switch your DNS server to that so ISP DNS problems don't matter – Zeb McCorkle – 2014-06-15T19:16:19.823

2Yes, but you should do that only after you have verified that the problems are, indeed, DNS based. Other kind of problems exist, and they might well leave routing to 8.8.8.8 (or the ICMP protocol) intact while wrecking something else. Conversely, failure to ping 8.8.8.8 might not indicate a routing or DNS problem at all. – LSerni – 2014-06-15T20:10:26.987

6

As a couple have said, you can ping, say, the Google primary DNS to obtain a response but do not rely on one address. The address (for a number of reasons) may be down for a period of time, during which your software will report "no connectivity", when, in fact, your network connectivity may not be experiencing any problems. You should always attempt to communicate with more than one address so you can rule out false negatives.

I would write a function that pings an address once, if that fails move on to another (up to, say, three IPs) and the moment you get a couple of positive replies the function should notify your application/script that Internet is available and continue.

Kinnectus

Posted 2014-06-15T08:51:41.083

Reputation: 9 411

4

I've been using 4.2.2.1 for more than over 10 years.. Before there was Googles' public DNS service. It seems to be a reliable DNS cache and ICMP responder.

rsenn

Posted 2014-06-15T08:51:41.083

Reputation: 41

This https://www.tummy.com/articles/famous-dns-server/ mentions it is not intended for public use.

– kevinf – 2018-02-14T18:11:24.447

34.2.2.2 is easier to type – user1886419 – 2014-06-17T15:41:18.790

3

When I worked for an organization with a flakey internet connection, I had a script which tested several "always up" servers for connectivity: first the LAN router/switch, then the local file server, then the T1 router, then the ISP's DNS, then Google. I tested the latter two as numeric addresses and as domains, to check DNS problems vs ping per se. If any of the pings failed too often, I got an idea of where the problem in connecting to the internet was most likely to exist.

For the numeric address for Google, I just used one I had gotten from nslookup previously - I never ran into a case where it was down. I suppose 8.8.8.8 would be simpler.

Fairly often, when people called to say the "internet was down", it turned out that only DNS was down; we might call those different things, but from the viewpoint of my colleagues, the internet wasn't available in either case.

Zeph

Posted 2014-06-15T08:51:41.083

Reputation: 131

2

Try your DNS server, you'll need it anyway (and your ISP's outside connection might be down). It really depends on what you want. If you need to access s specific service, check it.

vonbrand

Posted 2014-06-15T08:51:41.083

Reputation: 2 083

This is only valid if you know that ISPs DNS server is responding to ping. It may well be working but block ICMP. – Olli – 2016-03-07T13:51:28.867

This is the simplest and best answer, IMO. – njbair – 2016-09-22T15:22:39.603