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 220.127.116.11?
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 18.104.22.168, 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 .
Try to ping 22.214.171.124, it's Google primary DNS server. I always ping it to verify my connection and I never found it down. Alternatively you can try 126.96.36.199, which is Google secondary DNS.
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.
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.
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 188.8.131.52 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.
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 184.108.40.206 (or any surely external site) that does not respond is 220.127.116.11, 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 18.104.22.168 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.
"internet is available" is a much more complicated thing than simply "Is 22.214.171.124 (or other IP) reachable".
For a quick, dirty and not always reliable check, pinging 126.96.36.199 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.
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 188.8.131.52 -- (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 184.108.40.206
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
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.
I've been using 220.127.116.11 for more than over 10 years.. Before there was Googles' public DNS service. It seems to be a reliable DNS cache and ICMP responder.
You can do what microsoft does: check that
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 18.104.22.168 (this verifies that DNS is working).
NB: You can also visit http://www.msftconnecttest.com/redirect to get yourself through a captive portal if needed.