Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set up an Ubuntu router with automatic fail-over to a 3G link. I can probably set up routing and link aggregation, but I don't know how to monitor link status and dial the 3G link in case it is down. Pointers to helpful resources greatly appreciated.

share|improve this question
(Congratulations, I believe you have asked question #1000 on the site!) – 8128 Sep 8 '10 at 16:22
Congrats go to stackexchange -- i rolled back the edit because i am specifically looking on a script that will dial the 3g link; i can grep ping's stdout pretty well. – user2132 Sep 8 '10 at 17:19
Welcome to SE. Please be more specific in the question body, not the title. Also tags in titles are strongly discouraged unless they can be made part of the title text. Otherwise, try and avoid rolling back moderator edits. Try and use tags to target the type of answers you expect – Diago Sep 8 '10 at 17:36

I'm not sure there's anything out there that could do this for you... However, you could, with a bit of scripting, a bit of Googling, cobble together a script that:

  • Every 10 minutes, pings google with a timeout of 2 seconds and only from your "fixed" connection (not the 3G one) (use the -I flag).
  • If the ping succeeds, and you're on the fixed connection, do nothing.
  • If you're on 3G and the ping over the fixed connection works, take the 3G adapter down.
  • If it fails, bring up the 3G adaptor.

Here's my quick attempt:

#! /bin/bash


    if ping -q -c 1 -w 1 -I eth0 > /dev/null ; then
        echo "Connection is ok!"

        if [ $CONNECTION -eq 0 ] ; then
            # take the 3g connection down
            ifconfig 3GADAPTERNAME down
        echo "Connection is dead! Long live the connection!"

        if [ $CONNECTION -eq 1 ] ; then
            # turn the 3g connection on
            ifconfig 3GADAPTERNAME up

    sleep 5


Obviously replace 3GADAPTERNAME with your adapter's name. switch out eth0 if your main connection is different. Make sure it is set to automatically connect (so when it's allowed to, it does). The script will need to run as root.

share|improve this answer

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.