Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Setting Up a Dial-In PPP Server

You can also set up a simple service on your Linux system to provide PPP for dial-in users. Although commercial ventures such as ISPs must necessarily invest in leased lines, switching service, modem pools, and routers, you can easily configure a standalone Linux box to answer a modem and start PPP. The general steps may include

In general, and for many modems, the ATE1Q0V1&C1&S0S0=1&W modem string will set up a modem to autoanswer calls using different terminal monitors. (Some, such as uugetty, have configuration files to automatically set up the modem for a particular serial port.) The next step is to make an appropriate entry in the /etc/inittab file:

001 3:2345:respawn:/sbin/uugetty ttyS1 38400 vt100
002 

This entry assumes you have a modem attached to /dev/ttyS1. If you use the uugetty command to monitor your modem's serial port, you'll also need to copy the file uugetty.autoanswer from the /usr/doc/getty_ps-2.0.7j/Examples/default directory to the /etc/default directory. You should then edit this file and look for the ALTLOCK entry:

# alternate lockfile to check... if this lockfile exists, then uugetty is
# restarted so that the modem is re-initialized
ALTLOCK=cua2

Change the ALTLOCK entry to match your modem's serial port. Using the previous /etc/inittab entry, the string cua2 would be changed to ttyS1. The file should then be saved in the /etc/default directory with the name uugetty and a suffix to match the serial port (such as uugetty.ttyS0). You should then dial in from a remote computer to check the login process.

The next step is to create a user to test PPP service. Use the adduser command to create a user named ppp and then assign a password. Although users can log in to your system and then start pppd from the command line (assuming you've set pppd to SUID), you can have the pppd daemon started automatically by creating a short shell script and then assigning the shell script in the user's /etc/passwd entry like this:

ppp:x:501:501::/home/ppp:/usr/local/bin/doppp

In this instance, the script doppp (made executable with chmod +x) would contain the following:

exec /usr/sbin/pppd -detach

Using this approach, pppd will start automatically after the ppp dial-in user connects and logs in (using the ppp-on scripts or other clients, such as netcfg or kppp).

You should also edit the file options under the /etc/ppp directory to include general dial-in options for PPP service on your system, and create specific options files (such as options.ttyS1 for this example) for each enabled dial-in port. For example, /etc/ppp/options could contain

asyncmap 0
netmask 255.255.255.0
proxyarp
lock
crtscts
modem

There are many approaches to providing PPP service. You may want to assign IP addresses dynamically, or assign static IP addresses for your users. You should probably have DNS enabled, although you will still be sharing hostnames via /etc/hosts and providing static address assignment by using options.ttyX files (where X is the serial port). For example, /etc/ppp/options.ttyS1 could contain

IPofPPPserver:assignedIPofdialinuser

After you set up your /etc/ppp/options and /etc/ppp/options.ttyS files, dial in from a remote computer (perhaps using netcfg, kppp, or the ppp-on script). If your chat script uses pppd's debug option, you can watch the progress of your connection by using the tail command on /var/log/messages:

...
May 21 17:05:55 aptiva pppd[7761]: Serial connection established.
May 21 17:05:56 aptiva pppd[7761]: Using interface ppp0
May 21 17:05:56 aptiva pppd[7761]: Connect: ppp0 <--> /dev/modem
May 21 17:06:02 aptiva pppd[7761]: local  IP address 198.168.2.36
May 21 17:06:02 aptiva pppd[7761]: remote IP address 198.168.2.34

For more information about using PPP, see Robert Hart's PPP-HOWTO, available through http://www.linuxdoc.org.

Share ThisShare This

Informit Network