How to make PPP dial up automatically on RedHat 7.1

This file is available in HTML or formatted as text. I suggest to use the HTML-Version since it offers direct hyperlinks.

I doubt that the contents has a commercial value. If you think so, however, you must agree to abide by the The GNU General Public License before distributing or selling it on a commercial background.
I can't guarantee that by following this guideline you will ever connect or disconnect as desired. Don't blame me if you are charged for excessive connection times or cannot connect at all.
Don't blame me if your PC starts producing crude oil surprisingly. (Maybe you want to share your fortunes with me in this case, though!)

Rationale and History

Our small home network with a shared dial-up connection to the Internet inspired me to the work described below. The idea was to make the server dial up whenever any PC on the network required an Internet link and to disconnect automatically after a certain period of idleness on this link.
More easily said than done. My first efforts were with diald. Though it probably is a great work, several weeks of vain efforts convinced me that it was not my piece of cake. I simply failed to grasp concept and configuration due to my limited understanding. Another search revealed the existence of "Dial on Demand" as part of pppd. One *should* always read the man pages!
This was found in

http://www.icelabs.demon.co.uk/tutorial/redhat/redhat61-1.html.
Definitively, most of the ideas used in my work were inspired by that site. But even though I studied and followed the tutorial word by word, my setup did not want to work.
Therefore I had to study PPP from the ground up and used
http://www.linuxports.com/howto/ppp/ .
I went through all chapters and could nicely dial up manually at the end. Complete satisfaction was only disturbed by the fact that the server still didn't dial automatically.

So I tried to combine my knowledge gained from both sites and devised my own method.

Starting Point

Since there are plenty of very good guides and HOWTOs available, I assume that your PC has RedHat 7.1 already installed; the modem functional and a correct basic network setup done.
You also need some basic ideas on terminals and how to communicate with your modem. My preferred application is minicom, but you can use any other communication software just as well. Let's assume you have minicom running.

In the following, by the way, I will indicate subject matter like this:

This is a normal description and explanation.

This is what you have to enter respectively what your terminal responds.

And {this} is when you have to type in your own parameters and [this] is what you have to hit.

Lets start (communication software is still running):
Type

ATZ [Enter]

You'll probably get OK. Then type

ATDT {your phone number} [Enter]

and your phone should start ringing. If it does, continue here. If not, start somewhere else to get your modem installed.


As little theory as possible: PPP (Point-to-Point-Protocol) is used to connect you to your Internet Service Provider (ISP) using the so-called Dial-Up method: you dial 'up' (or 'in') to the network of your ISP whenever you want access to the Internet. If you are connected via a network (Local Area Network), this HOWTO is not for you. Neither, if you happen to be permanently connected via a modem.

The UNIX/Linux world has no native single application to do this. Rather, a server (=daemon) is used to control the PPP-link, which runs under the name of pppd (point-to-point daemon). Unfortunately, pppd does not know anything about modem communication and authentication (User-ID and password for your ISP), so that a chat script is necessary as second application.

In order to set up the auto-dial, you need administrative privileges. Therefore I suggest to

$ su [Enter]
{Administrator Password} [Enter]

Change to /etc/ppp, because it is from here where pppd takes all its information:

# cd /etc/ppp [Enter]

I wholeheartedly recommend to save all the files in /etc/ppp in a new subdirectory so that you can revert to your original settings whenever you feel like:

# mkdir ppp_save [Enter]
# cp * ppp_save [Enter]

The critical file is the 'options' file. It controls the pppd. Check it

# cat options [Enter]

If it does not exist, continue here.

If it exists, we must make sure to save it:

# mv options options_save [Enter]

Now copy the two files provided here into the working directory (/etc/ppp):

# cp {DirectoryLocation}/pppdd_init . [Enter]
# cp {DirectoryLocation}/chat_param . [Enter]

where {DirectoryLocation} indicates the directory that stores the two files after download.
Make sure the two files are here:

# ls [Enter]

will show these two files.

Now we have to configure the files. Use any editor of your liking; personally, I'd use pico. With an advanced editor, make sure to save the file as text with the extension .txt ! Otherwise you'll get formatting information in the file which will distort the operation. I'd issue

# pico pppdd_init [Enter]

Leave the lines starting with # alone. They are comments only. You see seven lines in which parameters are defined. Fortunately, for the average dial-up, there is not much that needs change.

If you happen to have a fixed IP from your ISP, change the LOCAL_IP accordingly.
On an older machine, your serial port might not be able to handle the speed of 115200. Reduce the number in case your link loses chunks of data.
Make sure to set SER_PORT to the serial device of your modem as used in the communication test above.
You might want to adjust the IDLE_LINK to another value if your dial-up is expensive or just to test the auto-disconnect function. The current value (600) stands for 600 seconds (= 10 minutes), before it relinquishes the line.
The DIALER_SCRIPT might have to be changed only if you use another Linux distribution or you want to deliberately change the location for whatever reason.

#
# These are the network parameters - Change as needed (usually not)
LOCAL_IP=0.0.0.0               # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0            # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0   # The proper netmask if needed
#
# These are the parameters for serial port and modem
SER_SPEED=115200            # Speed of serial port. Change for old UARTS only
SER_PORT=/dev/modem      # Change if different port is used
#
# Here we define the time after which an idle link is disconnected
IDLE_LINK=600                   # in seconds of inactivity
#
# This is the location of the chat-script which dials the phone and logs in
# Please use the absolute file name. Usually no change required
DIALER_SCRIPT=/etc/ppp/chat_param
#

Save the file under the same name (pppdd_init). Try

# less pppdd_init [Enter]

if you feel like checking. You should see the changes.

Next chat_param needs editing. Fill in the parameters for your ISP.

#
# Here you fill in the particulars for the connection to your ISP
TELEPHONE=123654789        # Phone number
ACCOUNT=henrymiller          # Your User-ID at your ISP
PASSWORD=secretword         # Your password for that account
#

Save this file as well under the same name (chat_param).
Done so far.

Before starting the daemon, make the two scripts executable:

# chmod 755 pppdd_init chat_param [Enter]

Time to check the function:

# ./pppdd_init [Enter]

If everything goes well, something like this should show up

Using interface ppp0
local IP address 10.64.64.64
remote IP address 202.202.188.188

Don't be surprised by the wrong IP addresses. Once the link comes up it will rectify the mistake; but pppd needs IP addresses to start with.
The link should not have started yet; the modem lights should not be flickering.

Open a second terminal and

$ ping 170.170.170.170 [Enter]

Now the link should start; the modem should dial.

Once the link is established, whatever the response to the ping command was (we only issued it to check if the link comes up), try if name resolution works:

$ ping www.yahoo.com

You may at any time switch back to the first terminal. The pppd parameters are set to display the activities, which is very helpful to give you some information on debugging if necessary (or insight into the function in case you want to understand it).

If the reply in the second terminal is something like

PING www.yahoo.akadns.net (216.115.102.82) from 192.168.0.21 : 56(84) bytes of data.
64 bytes from w10.snv.yahoo.com (216.115.102.82): icmp_seq=0 ttl=245 time=401.544 msec
64 bytes from w10.snv.yahoo.com (216.115.102.82): icmp_seq=1 ttl=245 time=389.930 msec
64 bytes from w10.snv.yahoo.com (216.115.102.82): icmp_seq=2 ttl=245 time=389.897 msec
64 bytes from w10.snv.yahoo.com (216.115.102.82): icmp_seq=3 ttl=245 time=379.924 msec
64 bytes from w10.snv.yahoo.com (216.115.102.82): icmp_seq=4 ttl=245 time=379.920 msec

a   Ctrl+C   will stop data coming in. You're done! Grab your favourite drink while waiting for the auto-disconnect after the number of seconds defined earlier.
Congratulations!

If the modem lights are on (active), but the reply is something like

ping: unknown host www.yahoo.com

repeat the command. If you still get the same reply, there is a name resolution problem. Check any of the many sites or your favourite Linux book on the settings in /etc/resolv.conf

The last step - once the above is working - might be to start the script pppdd_init automatically when the PC starts up instead of you having to type ./pppdd_init every time your PC starts.
To achieve this, edit /etc/inittab:

# pico /etc/inittab [Enter]

(make sure to be su!)
and add the two following lines *at the end* of inittab:

# added by myself for auto-dial into ppp0
dod:345:wait:/etc/ppp/pppdd_init > /dev/null

The '/dev/null/' prevents all pppd messages from showing up on your terminal(s). If you rather see them, for example to be confident that pppd is up and running, simply remove
' > /dev/null/' from the end of the second line.
With this setting, next time your PC starts it will automatically listen to Internet requests and bring up the link whenever necessary.

Type

# ps aux | grep 'pppd' [Enter]

to check if pppd is running.

Troubleshooting

Chances are that the setup won't work for whatever reasons. I'd divide them into three categories:

  1. The 'thing' doesn't start. That means, it does not show the

    Using interface ppp0
    local IP address 10.64.64.64
    remote IP address 202.202.188.188

    as described above. Then you better check your PC, your settings. There are not so many reasons why it should not start.

  2. The 'thing' starts (shows those lines above), but never establishes the link. There are, unfortunately, many possible reasons. Usually it has to do either with wrong parameters (so check!); or with individual requirements from your ISP. There is a whole bunch of variations ISPs have brought up to get you authenticated and connected. You might try to call them, but usually the knowledge of their support staff for Linux is limited.
    There is a really good description to nicely troubleshoot ppp and reveal all these more or less strange connection approaches in
    http://axion.physics.ubc.ca/ppp-linux.html

  3. The 'thing' links you to the Internet but never disconnects. I can assure you it does! You "simply" have to find the culprit that desperately wants to connect to the Internet. (The Windoze users know the pop-up window both from W9X and NT, asking "Should I dial ...?") Check what your /etc/cron.hourly/ and /etc/cron.daily/ do; in my case it was the RedHat network daemon wanting to look for updates once per 120 minutes and thus initiated the communication. It took me some hard time to find out ... .

    In any case, /etc/host.conf is a good hit when searching for the culprit. Here you define the sequence in which unknown hosts are searched: locally ('hosts') and remotely ('bind'). Of course, hosts, bind is the correct order. And make sure thereafter, that /etc/hosts really contains all the hosts on your network; otherwise they will be searched on the Internet (and dial-up be initiated for this purpose).

Limitations and Advantages

The method is not suitable for PCs that are running as ppp-servers; that is if you want your PC to accept connections from the outside via the phone line.
I don't have the slightest clue if and how it works for non RedHat 7.1 machines.
I am aware of two serious limitations:

  1. Once the pppd has died or been killed for whatever reason, it won't restart on its own. The remedy for that would be to convert pppdd_init into an 'options' file and start pppd in /etc/inittab with respawn. Since this requires a direct list of parameters in an 'options' file, I refrained from this solution in order to offer an easier approach. It should however be possible for you to do it on your own by now.

  2. There is no PAP / CHAP authentication included. In case that is required, you'll have to study the relevant HOWTOs and add parameters (e.g. 'name', 'user', 'remotename' etc.) in pppdd_init plus create / edit the PAP-secrets respectively CHAP-secrets files. For the rest, this method remains valid.

The most serious advantage as far as I can see, is that the function is by now completely de-coupled from the 'options' file. That means you don't have to save it before you can change or experiment. On the contrary: by simply copying the two files with different names it is very easy to change the parameters. There is no limit in creating pairs of modem-/ pppd-control files. You could literally create hundreds of pairs, for different disconnect times, different ISPs, with and without PAP, CHAP, MS-CHAP, whatever you like; without compromising the functionality of earlier devised pairs. Remember to change the DIALER_SCRIPT variable in the first file of each pair to call up the related chat script file, though.

Future

Whenever I'll be bored in future (I haven't been over the last ten years or so, though), I promise to write a script file that creates the whole setup interactively, creating a dialondemand.conf plus the options files, identifying serial port and serial port speed, updating the pap-secrets and chap-secrets, adding the pppd into inittab as respawn, checking and adding the modem initialisation string in the chat_param.
Once I'll have the time... Chances are, there won't be modems around any more by then.

Acknowledgements

I am indebted to the sites mentioned above for valuable insights. I am indebted to RedHat for providing a useful, non-bloated operating system. And to the Linux community as a whole, because without their efforts I'd be stuck to less useful crap.

Encouragement

I am keen to hear about your experience with this method; your opinion is valuable. I can't install some twenty distributions just to check out the functionality on those other distributions.
I am waiting to hear of my errors and mistakes. Feel free to improve the setup!


Uwe Dippel
udippel@uniten.edu.my




UNITEN - COE - IT UD 13-11-2001