LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   adsl down reload by itselve ? (https://www.linuxquestions.org/questions/linux-networking-3/adsl-down-reload-by-itselve-58694/)

saavik 05-08-2003 02:12 AM

adsl down reload by itselve ?
 
Hy!

I have a problem everytime my isp is down.

How can i make my pc redial the internetconnection so about 5 minutes after the internetconnection is down.

My problem is that i have to restart the adsl-connection manual by typing /etc/adsl start.

Any idea ?

cu

HappyTux 05-08-2003 02:22 AM

Use a cron job to check if the connection is up if it is not then the script would start the connection.

saavik 05-08-2003 02:50 AM

so i will do something like:

ip=`ifconfig -a ppp0 | grep "inet addr" | cut -f2 -d ":" | cut -f1 -d "P"`

with this i will get the ip but how can i compare the ip to the default (down) ip ?

if ip = 1.1.1.1 then /etc/init.d/adsl restart ????

i don not know how i can compare the default ip to the real ip!

thanks

shahriars 05-08-2003 03:27 AM

you can use the following script

#!/bin/sh
getIP=`/sbin/ifconfig eth0 | grep "inet addr" | cut -d ":" -f2 | cut -d " " -f1`
if [ "$getIP" == "1.2.3.4" ] ; then
/path/to/diallingScript.sh
fi

copy it in a file in /root, say, dialInterNet.sh, chmod +x, then run crontab -e, and put the following entry

*/2 * * * * /root/dialInterNet.sh

that should solve your problem.

all the best.

saavik 05-08-2003 04:25 AM

thank you, for your help!
i will trie that and write back!

nice day!

saavik 05-08-2003 04:44 AM

sorry,
 
unfortunately i can not check if the ip is xx.xx.xx.xx because the dev is down if the isp is offline!

ppp0: error fetching interface information: Device not found

idea?

shahriars 05-09-2003 08:58 AM

sorry, made a mistake. you should be dialing if the line is down, right? so the script should be

#!/bin/sh
getIP=`/sbin/ifconfig ppp0 | grep "inet addr" | cut -d ":" -f2 | cut -d " " -f1`
if [ "$getIP" != "1.2.3.4" ] ; then
/path/to/diallingScript.sh
fi


even if you don't get an IP address, i.e., if the link is down, the value for getIP will be null -- or in other words, they will not match the IP designated by your ISP (replaced with 1.2.3.4) and will dial.

hope this helps

mawdryn 05-09-2003 09:43 AM

Hi,

This script could prove very useful as I have a similar problem :)

Sorry to hijack the thread, but what if it's a dynamic ip address? Would it not then always try reconnecting until it matched the specified ip address? Would there be a way to get it to check whether ppp0 is present full stop?

shahriars 05-09-2003 09:55 AM

if you are having dynamic IPs, then you don't need to set rules to check the IP, you simply check if you have ppp0 up or not (in fact, I should have thought about it when the thread first arose, but i was thinking eth0 . . . :-( )

what you do is,


#!/bin/sh
getDev=`/sbin/ifconfig | grep ppp0`
if [ "$getDev" == "" ] ; then
/path/to/diallingScript.sh
fi


thus, if there is a ppp0, then the getDev will yeild some result and no scritp will run, on the other hand, if there _is_ no ppp0, then the result will be null and the script will run -- despite any IP conditionaing :-)

hope this solves your problem.

all the best.

mawdryn 05-09-2003 10:51 AM

thanks very much for your help there :D


All times are GMT -5. The time now is 02:26 PM.