Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all! After reading lots of forums I decided to create my own script to do that. It has done the job for some hour, but dont know why after ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2012
    Posts
    3

    FAILOVER - 2 Links - 1 Server (Redundant Internet)


    Hi all!

    After reading lots of forums I decided to create my own script to do that.

    It has done the job for some hour, but dont know why after 5, 6 or a bit more hours the internet simply stops

    The ideia is:
    2 Links
    one via DHCP(Cable modem) (eth2) (Dynamic IP)
    one via PPPOE(Fiber modem) (eth1/ppp0) (Static IP)

    When linux boots up automatically starts with eth2 working as I do not run the command: pon dsl-provider

    Alright, so far, the fiber modem keeps in standby.

    My script runs ping command and when it returns (0) it means the internet is OK, it sleeps for 25 seconds and then tests again.

    Any other result the script runs the following:

    ifdown eth2
    pon dsl-provider

    which means the DHCP Cable Modem (Dynamic IP) is disable and the Fiber modem (Static IP) is enable

    After that the script loops itself and runs ping tests again.

    Once it gets a result other than 0, it runs:

    poff -a
    ifup eth2

    Which means, disconnect PPPOE and enable eth2 through DHCP

    I will print my script below

    Does any one see any problem with it?

  2. #2
    Just Joined!
    Join Date
    Nov 2012
    Posts
    3
    ### SCRIPT BEGIN
    INTERNET="LINK1"

    while : ; do

    ping -c 1 200.154.56.80

    if [ $? -eq 0 ]; then
    echo INTERNET OK
    else

    if [ $INTERNET = "LINK1" ]; then
    echo SWITCHING OFF, LINK1 - SWITCHING ON, LINK2
    INTERNET="LINK2"
    ifdown eth2
    sleep 1
    pon dsl-provider
    ddclient
    /etc/init.d/squid restart
    else
    echo SWITCHING OFF, LINK2 - SWITCHING ON, LINK1
    INTERNET="LINK1"
    poff -a
    sleep 1
    ifup eth2
    ddclient
    sleep 1
    /etc/init.d/squid restart
    fi
    fi

    sleep 25
    done
    ### SCRIPT END


    it is run in the /etc/network/interfaces file as below:

    pre-up /bin/script &


    I also have the MASQUERADE line for ppp0 and eth2

  3. #3
    Just Joined!
    Join Date
    Nov 2012
    Posts
    3
    When I unplug the coaxial cable from the modem, the script switches the link correctly and stays there until I unplug the fiber cable from the fibermodem. (after having put back the coaxial cable in the other modem)

    Assuming that the 2 links are DOWN, the script will switch link1 and link2 until one of them comes online again.

    BUT if the one in use is OK, it should not be switched to other link, right?

    Well,,,.. Does any one see any mistake I may have made?

  4. $spacer_open
    $spacer_close

Posting Permissions

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