LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Monitoring ADSL (to keep online), adsl-start (http://www.linuxquestions.org/questions/linux-networking-3/monitoring-adsl-to-keep-online-adsl-start-352227/)

michaelsanford 08-11-2005 12:29 PM

Monitoring ADSL (to keep online), adsl-start
 
I've recently discovered that D-Link isn't officially supported by Bell Sympatico (my IHV provider), so I've canned my router and plugged straight into my linux box, which is now a nice gateway. (My original problem was frequent disconnects, and my router couldn't reconnect unless I cut the power, which I can't do from 1500 km away very easily).

Now that I have adsl-start working, I want to know if there's a way to monitor my connection to mak sure it's online all the time.

I was thinking that calling adsl-status and grepping for "Link is up..." in a cron job would be a good way to go, but my expression evaluation knowledge is not very good for sh/perl; can anyone lend a hand there ?

Of course, if adsl-start monitors the connection itself (I have it set to NO for dial-on-demand) that'll work too.

Sub query: why does adsl-connect keep the tty locked, and not release it once it's connected ? If I background the job by calling it as `adsl-connect &` will it just die when I log out of the shell ?

Half_Elf 08-11-2005 04:48 PM

First of all, don't listen to ANYTHING sympastico tell you, I mean it, they are deep idiot that don't know anything about DSL. I used to be one of their customer, but left because I had enought of their BS. So the "we don't support your router" mostly mean "we don't want to show our tech what a router is". Unless they changed, they don't support linux as well (mean they will refuse to answer your question, even if you ask for the mail server hostname, if they find out that you use linux).

Whatever, first of all, some tips... DSL shouldn't disconnect often usually. If it does, there might be a problem about your phone line. I don't know about Ottawa, but in Montreal, a lot of buildings have crappy phone line. However to make sure, you can ask sympatico to send you a tech to do a "sound test" over your line (mean they will test there is no interference). Back in time it was free, but someone told me they now charge for this... I don't know, thought, you will have to try your luck.
Also, a tech another DSL company (they all share the same phone network) told me you had to reduce you MTU to 1444 on their network, otherwise you could experiment lot of dataloss.


Here is a script I done to keep me online all the time. It is pretty bad and buggy, it was one of the first script I made but I switched to linux. I don't rewrite this because I am too lazy :)
Basically, the script search for "ppp0" in /proc/net/dev (network interface), if it's there, it checks that the ip (in /etc/LstIp in this script) is the same (in case they just dropped you and that adsl-start reconnected you). It also note the date when it does (so you can complain to sympatico saying WHEN you did lost connection). Just add a line in cron about this script every 5 mins or so and you will be fine.

Note it use "pon" and "poff" instead of adsl-start/adsl-stop because I use this on some minimal debian box. Changing this to adsl-start/adsl-stop should work as well.

Code:

#! /bin/sh
# Small bash script to check if I'm connected to the internet
#

# Now, taking care of the DSL
echo "Looking for existing DSL Connection"

Dsl=`awk -F":" '/'ppp0'/{print $1}' /proc/net/dev`
if [ $? != 0 ]; then
        exit 1
fi

if [ ! $Dsl ]; then
        echo "No DSL connection!"
        poff &
        sleep 5
        echo "Starting DSL"
        pon dsl-provider &
        echo -e " `date`" >> /etc/ConnectTime
        sleep 15
        NowIp=`ifconfig ppp0 | grep "inet addr:" | awk -F : '{print$2}'| awk '{print$1}'`

        if [ $? != 0 ]; then
                exit 1
        fi

        echo "$NowIp" > /etc/LstIp
else
        LstIp=`grep . /etc/LstIp`

        if [ $? != 0 ]; then
                exit 1
        fi

        NowIp=`ifconfig ppp0 | grep "inet addr:" | awk -F : '{print$2}'| awk '{print$1}'`

        if [ $? != 0 ]; then
                exit 1
        fi

        if [ "$LstIp" != "$NowIp" ]; then #If the actual Ip is the same of the one in Ip
                echo "Last Ip was $LstIp and Actual Ip is $NowIp"

                poff &
                sleep 5
                echo "Starting DSL"
                pon dsl-provider &
                sleep 15
                echo "Saving New Data"
                echo -e " `date`" >> /etc/ConnectTime

                NowIp=`ifconfig ppp0 | grep "inet addr:" | awk -F : '{print$2}'| awk '{print$1}'`

                if [ $? != 0 ]; then
                        exit 1
                fi

                echo "$NowIp" > /etc/LstIp
                echo "Updating Done"
        else
              echo "Ip is the same,no update"
        fi
fi

[Subquery]
It's the way to do of any script... Backgrounding is somewhat attached to the tty, you can't close it, I can't really tell you why, I suppose it need the TTY information to keep it backgrounded.
Otherwise, if you start the connection from a "system script" (from a bootup script or from a cron job task) it should be good.

michaelsanford 08-12-2005 09:44 AM

Hé merci Half_Elf !

I know I don't trust Sympatico's service team, they're not very competant in my experience (though I have had a few good ones). Telling them I also work for an ISP doesn't seem to help at all...

I have OK line quality. The reason I do think it might be the router is that when I do disconnect it can't reconnect unless I reboot the router, which indicates a software bug in the firmware to me.

And no, they don't officially support Linux, but it seems to work fine.

And as a side note, I did actually put adsl-connect into rc.local and it wouldn't release the tty, so it got stuck at boot prompt. I managed to get the WAN IP, drove to my school and used their wireless to log in and fix and reboot it. :P

Half_Elf 08-12-2005 11:00 AM

Pas de problème :)

Some routers or modem (althought Sympastico modem are known to be _very very good_, they don't lend you cheap hardware, just cheap service) do have firmware problem, sometime it's possible to upgrade the firmware (or to send back to the vendors) but most of time you have live with it. In any ways, I would recommend to browse your vendor (d-link?) web site carefully, as they probably hide the return webform very well (if they have any).
I once had a DSL modem that was crashing (litterally crashing, the modem was turning off itself!) because of bad quality phone line (sympastico so-called technician made me empty my cookies during 3 weeks 'til I blow up... then they send a real tech to check the line... it was about time).

Quote:

I did actually put adsl-connect into rc.local and it wouldn't release the tty, so it got stuck at boot prompt.
Don't use "adsl-connect", but "adsl-start", adsl-connect is mostly used to do weird stuff (like starting additionnal new connections... I once got up to 30 connections on the same machine (so 30 different ips) because I had a buggy script that was calling "adsl-connect &" endlessly :) I was using sympastico under slackware with rp-pppoe (adsl-start and this stuff) until 2 month ago and it wasn't locking terminal (I was calling it from rc.local as well... I like slackware KISS bootup scripts).


Oh and... make sure you NEVER mention to them you use linux, a router or an home network... back in time I had the bad idea to tell them I was a linux user so they had wrote it in my customer information and then they was refusing to help me, even if I was just calling to get mail server hostname or because the modem was crashing.

Feel free to send a pv mail... It's always fun to IM chat with linux users that are in the same city :)

ALInux 02-10-2006 03:26 AM

Nice Script helped me out

michaelsanford 02-10-2006 07:28 PM

This is an old question of mine. Slackware 10.2 comes with pppoe-* tools that seem to monitor the connection for you. I now have only this in my rc.local and have never had a disconnect problem since.

Code:

########################
# LAN Configuration
ifconfig eth1 10.0.0.1 up
/usr/sbin/pppoe-start
/usr/sbin/pppoe-status


ALInux 02-11-2006 11:55 AM

pppoe-start and pppoe-status...refer to roaring penguin tools...I installed it on my debian box.. but they did not work properly...so I used to custom debian package for the pppd.

dpajares 07-12-2006 07:43 PM

very good scrit, that work prefeclty.


All times are GMT -5. The time now is 05:29 PM.