Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bootstrap.php(430) : eval()'d code on line 123
[ask] disconnect and reconnect
Results 1 to 1 of 1

Thread: [ask] disconnect and reconnect

  1. #1

    [ask] disconnect and reconnect

    i want to make a script to simulate the disconnect and connect form the web ui(status page) if my internet down.

    every time my internet down, i need to disconnect and then connect the wan for it to work again.

    i want to automate this by make a script that will try to ping to google every 10 minutes and if the result is rto, than the script will disconnect wan and than reconnect it.

    what i found so far is this
    for myHost in $HOSTS
      count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
      if [ $count -eq 0 ]; then
        # 100% failed 
        echo "Host : $myHost is down (ping failed) at $(date)"
    correct script
    test=$(ping -c 2 google.com)
    if [ -z $test ]; then
            pid=$(ps | grep udhcpc | awk '{print$1}')
            kill $pid
            /sbin/udhcpc -i eth1 -p /var/run/udhcpc0.pid -bN61 -O33 -O121 -O249
    just need to add it to crontab -e and run crond
    Last edited by mataanjin; 10-05-2012 at 14:53. Reason: solved

Posting Permissions

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