Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johannnn

macrumors 68020
Original poster
Nov 20, 2009
2,371
2,768
Sweden
Hi everyone!

When there is internet and I ping like "ping google.com", it keeps pinging. If internet goes down, it changes to "Request timeout for icmp_seq 559" but keeps pinging.
However, if there is no internet connection when I start pinging, it just says "ping: cannot resolve google.com: Unknown host" and stops.

When I start pinging when Internet is down, how do I make it keep pinging so I know when my Internet is back up?

Thanks!
 
The basic problem in your direct question is that your computer does not know the address of "www.google.com", so it has to ask the DNS system. But since you have no connection, that request goes nowhere... and fast.

If you were to have an IP address that you can use (I use the DNS servers of a major University that I have long since memorized), then you could use that.

But the best way would be to use the SystemConfiguration framework to detect when your network comes up. This can be done through the scutil command-line tool. You will need to read the man page and play with it a bit, since it has been a while since I have played with it.
 
As larkost said, use an IP address not a hostname, probably the easiest IP address to use would be one for your ISP's DNS servers: easily found, doesn't affect anyone except your ISP, unlikely to change, and the root cause of the problem you first identified.

Having said that, pinging things constantly is not generally a good idea:
1. Many servers are set to not respond to ICMP requests anyway
2. Constant ICMP requests are sometimes a sign of a DoS attack and therefore are not a very friendly thing to do

If you do it, then make sure to set the interval to something less aggresive than the 1s default, use something like -i 60

You could try using something like Little Snitch. I don't use it, but understand it has a connection monitor.

On another note, how unreliable is your internet connection if you need to do this?
 
Last edited:
Thanks for all answers. This week the Internet is crappy due to construction work so this comes in handy.

As you both recommended, I will use a DNS adress. Googles DNS server 8.8.8.8 is the easiest thing in the world to remember, so it's perfect.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.