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?

  • 1
    Linux one-liner to answer yes or no, are we connected to the internet: ping -c 1 www.yourtrustedserver.com | 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. Dec 8, 2013 at 2:55
  • This will fail if 1) yourtrustedserver.com's DNS is down 2) www.yourtrustedserver.com itself is down 3) your DNS recursor is down 4) your DNS recursor is misconfigured. The network might still be reachable in all four of those cases, so it's not a good test. Dec 28, 2022 at 9:51

5 Answers 5


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

  • 3
    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).
    – phemmer
    Jul 17, 2012 at 12:16

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

You can simply type

 $ ping yahoo.com

(or cnn.com 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 yahoo.com
PING yahoo.com ( 56(84) bytes of data.
64 bytes from ir1.fp.vip.sp2.yahoo.com ( icmp_seq=1 ttl=52 time=83.5 ms

--- yahoo.com 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 unicorns.are.here
ping: unknown host unicorns.are.here

$ echo $?
  • But how can I realize from using ping that everything is ok?
    – Radek
    Jul 17, 2012 at 3:23
  • 1
    @Radek Have you tried running it yet? ping tells you if it gets replies.
    – jw013
    Jul 17, 2012 at 3:26
  • What if the server is on intranet only and doesn't have access to outside world?
    – Radek
    Jul 17, 2012 at 3:35
  • @jw013: I haven't tried...I don't know to use ping from an unattended script.
    – Radek
    Jul 17, 2012 at 3:36
  • 3
    @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, 2012 at 5:00

I'd use netcat to the desired service.

For example, testing an IP port, succeding

> nc -zv 80
Connection to 80 port [tcp/http] succeeded!

...and failing

> nc -zv 22
netcat: connect to port 22 (tcp) failed: Connection refused

with 10s timeout

> nc -zv -w 10 80
netcat: connect to port 80 (tcp) timed out: Operation now in progress
  • Hi Muihlinn, welcome to U&L! Could you give an example of how you would do this?
    – Cyclic3
    May 14, 2020 at 15:46

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


I use the following function ... It defaults to quad9 but you can pass a different domain. It will timeout after 15 minutes of trying

wait_for_dns() {

   local fqhn="quad9.net"

   printf "waiting"
   for i in {1..15}; do
      local a_record=$(dig +short +time=2 $fqhn)

      if [[ $a_record != '' ]]; then
         printf "\n"
         return 0

      printf '.'
      sleep 60

   printf "\n"
   return 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .