Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to send a growl to myself after SuSE server finishes the boot process. I got this message socket_sendto(): unable to write to socket [101]: Network is unreachable in.

How can I check from command line if the network is reachable and wait in case it is not?

share|improve this question
Linux one-liner to answer yes or no, are we connected to the internet: ping -c 1 | grep " 0% packet loss". What this does is ping the server with one packet, and greps the output for the string " 0% packet loss". (the space before the 0% is important) If the command returns a row, you are connected, otherwise, not connected. – Eric Leschinski Dec 8 '13 at 2:55

3 Answers 3

ping to an outside host can fail for a multitude of reasons, only a few of which actually say anything useful about the state of your own network.

As a first step, open a terminal window and type ip route ls

You should see an output along the lines of

shadur@equinox:~$ ip route ls dev eth0  proto kernel  scope link  src 
default via dev eth0 

This indicates that your local network is an ethernet connection (eth0) with the address, and that its default gateway through which it accesses the rest of the internet can be found at

Next, you can try to ping that address:

shadur@equinox:~$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=255 time=0.352 ms
64 bytes from icmp_req=2 ttl=255 time=0.269 ms
--- ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.269/0.310/0.352/0.045 ms

If you see something similiar to the above, your own local network is, at least, fine. At this point you can start looking with more advanced tools like traceroute to see where your connection to the destination might be failing.

However, after a quick google check of what growl is actually supposed to be I get the feeling that there's something else going wrong. Can you expand your question to give us a few more details on what you're trying to do, how you're attempting it, and the full error output? The line you're currently giving us gets cut off abruptly...

share|improve this answer
ip route get is more reliable than just doing ip route ls. The former will take into effect any rules that are in place in addition to routes. It also removes the possibility of misreading the routing table(s). – Patrick Jul 17 '12 at 12:16

mtr is a tool that is similar to ping but gives you more information such as packet lose, statistics on packet travel times, etc...

share|improve this answer

A very simple and quick way is to use the ping command.

You can simply type

 $ ping

(or or any other host) and see if you get any output back. This assumes that hostnames can be resolved (ie dns is working). If not, you can hopefully supply a valid IP address/number of a remote system and see if it can be reached.

Here's the ping man page.


As a quick example, you can check the return value (e.g., with "echo $?") from ping to see if the command succeeded (you could always pipe the output of the command to > /dev/nul). Note I use -c 1 here, but you could use more.

$ ping -c 1
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=52 time=83.5 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 83.593/83.593/83.593/0.000 ms

echo $?

$ ping -c 1
ping: unknown host

$ echo $?
share|improve this answer
But how can I realize from using ping that everything is ok? – Radek Jul 17 '12 at 3:23
@Radek Have you tried running it yet? ping tells you if it gets replies. – jw013 Jul 17 '12 at 3:26
What if the server is on intranet only and doesn't have access to outside world? – Radek Jul 17 '12 at 3:35
@jw013: I haven't tried...I don't know to use ping from an unattended script. – Radek Jul 17 '12 at 3:36
@Radek it's quite simple. I assume by 'connectivity' you mean it can talk to some other host on the intranet. So run ping -c 2 -n <other host's IP> and operate on the return code: if true (0), then it has connectivity; if false (1), then it can't talk to that machine. – lxop Jul 17 '12 at 5:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.