How to test if online?

Christian Tischler mail at myunix.net
Tue Aug 2 08:08:29 GMT 2005


Hi all,
I am using a FreeBSD box as an DSL router. Sometimes the inet connection
does down and ppp is unable to reconnect. I want to detect via a cron
script if I am online and if not reinitilize the connection. The script
works ok when run manually, but when executed from cron it sometimes
reinitializes the connection even when it is not neccessary.
Now my question would be how I could improve the script, or if there is
a better way. As you can see from the script I am not really a
programmer, but I tried what I could.
------------------------
#!/bin/sh
if !(/sbin/ping  -c 1 freebsd.org) then
        /usr/bin/killall ppp
        /bin/sleep 1
        /sbin/ifconfig xl1 down
        /sbin/ifconfig xl1 up
        /bin/sleep 1
        /usr/sbin/ppp -quiet -ddial -nat tdsl
fi
-------------------------

thanks in advance

Christian Tischler



More information about the freebsd-questions mailing list