Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to automatically redial if adsl connection is down under RedHat 8?

Posted on 2003-02-19
21
Medium Priority
?
331 Views
Last Modified: 2010-03-17
Hi,
In my house I have two machines, a Redhat8 Linux machine I use aa a server and a windows XP client. My adsl modem (external) is connected to one network card and the connection is established using a simple script that starts a pppd process. Another netwok card attches to the windows XP to allow the XP to see the outside world. My problem is as follows:
If I turn the client machine off, the adsl connection is dropped, why is that?
I need a way to insure that the line is up again if it is dropped. Is there a way to do that in Linux? What script can I use that will take care of that?


Thank you in advance


0
Comment
Question by:isammustafa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
21 Comments
 
LVL 1

Expert Comment

by:djluff
ID: 7981096
If you are using the roaring penguin pppoe client, look into the pppoe.conf file (probably /etc/ppp/pppoe.conf). In it there should be an option something like:

DEMAND=300

Change this to:

DEMAND=no

This tells pppoe to NOT bring the link up on demand, but to leave it up permanently.

If the link is lost it should reconnect automatically.
0
 
LVL 17

Expert Comment

by:psimation
ID: 7988486
Look in your /etc/sysconfig/network-script folder.
You should have a file called ifcfg-pppx where x= 0, 1, 2 etc. depending on how many dial-up configurations you have.

The file should have something like this inside:
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
USERCTL=yes
PEERDNS=yes
TYPE=xDSL
DEVICE=ppp1
BOOTPROTO=dialup
ONBOOT=no
PIDFILE=/var/run/pppoe-adsl.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=60
PERSIST=yes
SYNCHRONOUS=no
DEFROUTE=yes
USER=test
PROVIDER=test
ETH=eth0

The 6th last entry: PERSIST=yes is the one telling pppoe to keep the connection alive by retrying if the connection drops.
Also, I'm not sure if your country has the same policy as mine, but over here, the ISP's "rotate" IP's by randomly disconnecting your connection and then re-assigning a different IP each time you connect. This is in an attemp to prevent people from hosting on their machines. It could explain the disconnects, BUT, it is most probably the CONNECT_TIMEOUT=60 or whatever that disconnects automatically once there has been no activity for x amount of time. Since your Linux box is just the gateway, it is probably not generating activity once you switch off the XP box, hence the timeout. You should be able to prevent the timeout by setting the time to "0".

Also, try to rather use the graphical tools to configure your dial-ups.
Click on "start", "system settings" and Network. It will bring up an GUI to allow you to add new xDSL connections. All the options you see in the file above can be set by graphical toggles, including the timeout and auto-reconnect settings...
Bit easier than to have to create your own script methinks.
0
 
LVL 17

Expert Comment

by:psimation
ID: 7988511
OOPs, should be PPPOE_TIMEOUT=80 and not CONNECT_TIMEOUT=60 dictating the activity.
Anyway, if you use the graphical tool as I mentioned, this file along woth the correct settings in the file will be created for you, and you can simply type ifup pppx (x=0,1,2,...) and ifdown pppx
0
Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

 
LVL 9

Expert Comment

by:majorwoo
ID: 7992090
in

/etc/ppp/

you have

ip-up  and ip-down

which you can make locals for yourself, naming them

ip-ip.local and ip-down.local (make sure to chmod 755 them)

this allows you to do anything you want when your connection comes up or down, (by using the correct script and adding the line you want to it)
0
 

Author Comment

by:isammustafa
ID: 7995652
Hi all,
Thanks for the answers, here is what I have in the files ifcfg-eth0 and eth1.
----------------------------------------------------------
ifcfg-eth0

# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
USERCTL=no
PEERDNS=no
TYPE=Ethernet
DEVICE=eth0
HWADDR=00:50:da:df:f2:88
BOOTPROTO=none
NETMASK=255.0.0.0
ONBOOT=yes
IPADDR=10.200.1.1
NETWORK=10.0.0.0
BROADCAST=10.255.255.255
~
----------------------------------------------------------
ifcfg-eth1
# Please read /usr/share/doc/initscripts-*/sysconfig.txt
# for the documentation of these parameters.
USERCTL=no
PEERDNS=no
TYPE=Ethernet
DEVICE=eth1
HWADDR=00:c1:26:00:0c:4c
BOOTPROTO=none
NETMASK=255.255.255.0
ONBOOT=yes
IPADDR=192.168.0.1
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
~
----------------------------------------------------------

and this is the script I use to establish a connection to the internet:

/usr/sbin/pptp 10.0.0.138 --quirks=BEZEQ_ISRAEL debug user isam1967@INetvision remotename "10.0.0.138 RELAY_PPP1" defaultroute mtu 1452 mru 1452 noauth
~
----------------------------------------------------------

So I guess I am not using the roaring penguin pppoe client. also, here is the output of the command "ps -aef |grep pp"

[root@anter root]# ps -aef |grep pp

root      5570     1  0 17:17 ?        00:00:04 /usr/sbin/pptp pptp: GRE-to-PPP

root      5572     1  0 17:17 ?        00:00:00 /usr/sbin/pptp pptp: call manage

root      5573     1  0 17:17 pts/1 00:00:00 /usr/sbin/pppd /dev/pts/1 38400
-------------------------------------------------------

In this case, what I need is that a way (script or changing some parameters) to execute the pptp or pppd again if it fails.
I hope this will help you more understand my problem. The main goal is to have the adsl line on as long as possible.

Regards,
Isam
0
 
LVL 17

Expert Comment

by:psimation
ID: 7999974
isammustafa
Have you not read my comments?

If you use the example I gave you in my comments, and just place your details in there, eg. USER= and PROVIDER= then it should work. So, just copy the example I posted into your /etc/sysconfig/network-scripts as ifcfg-ppp0. Then just do ifup ppp0 to connect adsl.

IN your last comment you mention the contents of the eth0 and eth1 scripts. That has little to do with getting the adsl to work. Usually you connect the adsl modem to your eth1 device, but you need to bring up the ppp0 interface, not the eth1 interface.

If you use the graphical configuration util as I explain in my comments, you will not need to worry about editing or creating these scripts. The GUI util will create the correct files and options for you, and you will simply need to do a ifup ppp0 to connect.


 
0
 
LVL 17

Expert Comment

by:psimation
ID: 7999983
PS
If there is some reason why you cannot use the gui, then you can simply try to append your current connect script by including the PERSIST=yes option, and playing around with the PPOE_TIMEOUT value.
0
 

Author Comment

by:isammustafa
ID: 8000313
Hi psimation,
If I could find the file you refer to there would be no problem, but as you can see these are all files I have in network-scripts dir.

[root@anter network-scripts]# ls
ifcfg-eth0    ifdown-post   ifup-ipv6    ifup-sit
ifcfg-eth1    ifdown-ppp    ifup-ipx     ifup-sl
ifcfg-lo      ifdown-sit    ifup-isdn    ifup-wireless
ifdown        ifdown-sl     ifup-plip    init.ipv6-global
ifdown-cipcb  ifup          ifup-plusb   network-functions
ifdown-ippp   ifup-aliases  ifup-post    network-functions-ipv6
ifdown-ipv6   ifup-cipcb    ifup-ppp     old-ifcfg_eth1
ifdown-isdn   ifup-ippp     ifup-routes
[root@anter network-scripts]#
---------------------------------------------------------

So please be patient with me. If I was an expert in the subject I would'nt be asking questions like those :-);

What I understand so far is that pppd and pptp are called to establish the connection., but the connection terminates after an hour or two, sometime after a day, and so my downloads go to a halt.
I want to get over this problem by ensuring that even if the connection is terminated then the connect.sh script that i use to connect to the internet is called to establish the connection or that pppd and pptp are called to do the job.
Please forgive my poor desribtion of the problem or my lack of knowledge in linux and help me solve this problem.
Thanks again


0
 
LVL 17

Expert Comment

by:psimation
ID: 8002211
Hi isammustafa

Firstly, I did not mean to sound impatient, seems like I chose the wrong words. All I meant was that it didn't look like you read my comments as you did not mention anything in your reply.

So, now I think I understand what you don't understand...

The main problem here is that you don't have a ifcfg-ppp0 file in your folder. You see, the script that you use at the moment is in some way replacing the correct method. The "correct" method for bringing up interfaces is with the ifup command. Now for the ifup command to work in this case, you need to have a ifcfg-ppp0 file in the network-scripts folder. If you don't, then you cannot use ifup, and you need to write your own script as you did.
So, my suggestion was and still is not to use the script that you use at the moment, but to a) create the ifcfg-ppp0 script by hand (hard work) or b) let RedHat create it for you with the graphical tool you can find by clicking on the red-hat icon in the bottom left of your screen, then click on "System Settings", and then click on "Network".
This will bring up a tool that will allow you to add new network interfaces to your system. Just click on "Add", and then on "xDSL", it will ask you all the right questions, such as the username, provider name, and yes, it will also allow you to select the options that will keep the connection alive, and to re-dial if the connection is dropped. Using this tool will place the correct ifcfg-ppp0 file in the network-scripts folder, and once that is done, you can simply say "ifup ppp0" in future instead of having to use the script that you wrote.

Again, if for some reason you cannot use the graphical tool ( for which you must be in X (type startx to get into it from a prompt)) or if you cannot find this tool, you can try to create the file by hand by copying the contents of the example file I posted in my first coment to your PC, and to just make the correct changes to the parameters, as in USER= and ETH= etc. so that they match your system, for instance, ETH= should probably be ETH=1 on your system if the adsl is connected to the second network card. Also remember to make PERSIST=yes, this is the "key" to have the connection stay active and to re-dial should it drop for any reason.

I hope this makes things clearer?
Please post back if you don't understand something, I will try to explain better.

PS, again sorry if you got the idea that I am getting impatient. I would not post long comments like these if I grew impatient, I promise you. I and the rest of the experts are here to help.
0
 

Author Comment

by:isammustafa
ID: 8003970
Hi,

Ok the way we connect our linux machines to ADSL here in Israel is complicated and most of us use this script to connect. Ofcourse we manually change the chaps-secret file and ifcfg-ethx (0,1,..).
That is the reason we do not use the adsl-start, adsl-stop, .... commnads or the GUI.

In my previous comments I showd all the info and configuration paramters I have relative to adsl connection.
So, I hope that will give you more info on how to automate this proccess.

Regards,
Isam
0
 

Author Comment

by:isammustafa
ID: 8003991
PS: I do not have pppoe, what should I do?
0
 
LVL 17

Expert Comment

by:psimation
ID: 8004028
OK, then what you need to do is to add the PERSIST=yes to the script that you are currently using. Also, you can still try to use the graphical configuration utility to configure your adsl connection. From the parameters of the script that you posted previously, it seems that there are a couple of extra parameters you are sending, but those can still be set manually, as they have more to do with the mtu size, and I'm sure you can set that in the ifcfg-eth0 file.

So, either try this:
/usr/sbin/pptp 10.0.0.138 --quirks=BEZEQ_ISRAEL debug user isam1967@INetvision remotename "10.0.0.138 RELAY_PPP1" defaultroute mtu 1452 mru 1452 noauth PERSIST=yes

or,

Configure your adsl with the graphical utility in order to create the ifcfg-ppp0 file, then before you do a connect, you can set the mtu and mru with the following command:

ifconfig eth1 mtu xxx mru xxx

Then try to connect with the ifup ppp0 command.
0
 
LVL 17

Expert Comment

by:psimation
ID: 8004037
Also, is the pptp util a script? If so, can you post the contents?
0
 
LVL 17

Expert Comment

by:psimation
ID: 8025273
Are you still there?
0
 

Author Comment

by:isammustafa
ID: 8032075
Yes I am still here. We had Snow here in Jerusalem and this is rare in the middle east :-); Ofcourse Snow not only means happenis, romance and a beutiful change, it also means having electricity for almost 48 hours in my house and others in the neighbourhood :-(; So I was in the past two days living the days of caveman but it was beutiful.
Now back to our problem. I took your advice and added "PESRSIST=yes" in the pppd/options file and the connect.sh script and they did not like it. I foud out that I should just use the word "persist" without the "=yes" option. A good thing happend after this, now if the client machine is turned of or network connection is disabled on the client machine, it does not cause the server (Redhat machine) to turn the adsl line down. That is a major enhancement but it does not solve the original problem which is that I need the connection to rstart automatically if it fails for any reason. I noticed that even after I added the persist option, if I kill the pptp and pppd proccesses, still the connection does not restart  by itself. How to do that?
0
 
LVL 17

Accepted Solution

by:
psimation earned 2000 total points
ID: 8032387
Unfortunately, that is what the persis option is meant to do...

I think you might have better luck if you try add your current dial-up script's options into the redhat dial-up script and then use the ifup ppp0 method. IOW, configure your adsl with teh network utility as I explained previously. This will create a ifcfg-ppp0 file in the /etc/sysconfig/network-scripts folder. Now try to incorporate the extra settings you need into this file.
As previously said, the mtu size you can set with the ifconfig command, so you don't need to try and add that into the ifcfg-ppp0 file, just the rest (as in username and provider), but the network tool will ask for those anyway and will include it into the file.
Try to do the ifcongif mtu 1452 mru 1452 first, then configure your dial-up with the network tool. It might be that it is only the mtu and mru sizes that needed to be changed, and once done, the connection could be configured by normal means...
The advantage of this is that the pppd daemon will then manage your connection, and because pppd runs as a daemon, it can restart if killed, else you will have to run your script as one too, but I cannot remeber how to do that.
 
0
 

Author Comment

by:isammustafa
ID: 8032777
I will try to do that and let you konow what happens.
0
 

Expert Comment

by:CleanupPing
ID: 9077806
isammustafa:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question