Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2010

    Message when network goes offline

    My provider sometimes kicks me and assigns a new IP address.

    I'd like to write a little script which displays a message when I fall offline. What is the most reliable way to check whether I'm offline with a (bash?) script?

  2. #2
    If online means "connected to the network", ping your default gateway. If it means connected to the Internet, ping an internet server. If it is successful, you are "online".

  3. #3
    Just Joined! NightShade03's Avatar
    Join Date
    Apr 2010
    New York

    if ! ping -c 1 -w 2 &>/dev/null ; then

    echo "The internet appears to be down"

    echo "The internet appears to be up"


    Save as, chmod 775 and you are good to go.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts