Setting Up a PPP Server


Setting Up a PPP Server

The preceding sections describe how your Linux PC can establish a PPP link with another system that offers PPP service. After a PPP link is set up, both ends of the PPP link behave as peers. Before a PPP link is established, you can think of the end that initiates the dial-up connection as the client because that system asks for the connection. The other end provides the PPP connection when needed, so it's the PPP server.

If you want to enable other people to connect to your Linux PC by using PPP over a dial-up modem, log in as root and perform these steps:

  1. Search through the CD-ROMs to locate the mgetty RPM. Insert each CD-ROM and mount using the mount /dev/cdrom command (or, if you are running GNOME, wait for the magicdev process to mount the CD). Then type the following commands to see if the CD contains the mgetty RPM file:

    cd /mnt/cdrom/RedHat/RPMS
    ls -l mgetty*.rpm
  2. After you find the mgetty RPM, install it with the following command:

    rpm -ivh mgetty*.rpm
    
  3. At the end of the /etc/mgetty+sendfax/mgetty.config file, add the following lines for the serial port connected to a modem for dial-in users (this example assumes that the modem is connected to the second serial port, COM2):

    # For US Robotics Sportster 56K with speaker off
    port ttyS1
    init-chat "" ATZ OK AT&F1M0E1Q0S0=0 OK
    answer-chat "" ATA CONNECT \c \r

    The AT&F1 modem command sets hardware flow-control mode on many modems. For other modems use appropriate initializations in the init-chat line. Note that the serial port device names may change depending on your serial communications hardware (for example, multiport serial boards would have their own device names).

  4. Edit the text file /etc/mgetty+sendfax/login.config and search for the line that starts with /AutoPPP/. Uncomment it by deleting the # character at the beginning of the line. Edit the line so that it looks like this:

    /AutoPPP/ - a_ppp /usr/sbin/pppd file /etc/ppp/options

    As the last part of that line shows, automatic PPP startup involves running pppd with the options listed in the file /etc/ppp/options.

  5. Edit the file /etc/ppp/options and make sure that it contains the following lines:

    asyncmap 0
    auth
    crtscts
    -detach
    lock
    login
    modem
    ms-dns 192.168.0.1 #put the IP address of the DNS server here
    proxyarp
    refuse-chap
    require-pap

    Here is what these options mean:

    • asyncmap 0-Causes pppd not to set up and use escape control sequences

    • auth-Causes pppd to require the peer to authenticate itself

    • crtscts-Causes pppd to use hardware flow control

    • -detach-Causes pppd not to become a background process (which pppd will do if a serial device is specified)

    • lock-Creates a lock file so that pppd can have exclusive access to the particular modem

    • login-Causes pppd to use the system password file to authenticate the peer using PAP

    • ms-dns DNS_IP-Specifies the IP address of the name server that pppd can send to the system that dials in

    • modem-Causes pppd to use modem control lines

    • proxyarp-Causes the other end of the PPP connection to appear as if it is on the LAN with this system

    • refuse-chap-Causes pppd to not use CHAP for authentication

    • require-pap-Causes pppd to use PAP for authentication

  6. Open the /etc/ppp/pap-secrets file in a text editor and locate the following lines:

    # Secrets for authentication using PAP
    # client    server        secret        IP addresses
    Then add the following line just below these two lines:
         *        *        ""        *    

    That basically says that pppd won't use any secrets (because it uses the system password file instead).

  7. To set up a specific IP address for each serial port, create a file for that serial port with the name /etc/ppp/options.ttyXX where ttyXX is the serial port device name. In that file list the local IP address and the remote end's IP address, separated by a colon. For example, if for the ttyS1 serial port, the local IP address is 192.168.0.100, and the remote IP address is 192.168.0.200, then add the following line to the file /etc/ppp/options.ttyS1:

    192.168.0.100:192.168.0.200
  8. Open the /etc/inittab file in a text editor and add a line of the following form (this example assumes that the modem is on the second serial port, ttyS1):

    s1:235:respawn:/sbin/mgetty -D -x 3 ttyS1

    The -D option tells mgetty to treat the modem as a data modem, not fax. The -x 3 option turns on logging-the log file is /tmp/log_mg.ttyS1 (for modem device /dev/ttyS1).

  9. Connect the modems to the serial ports, turn them on, and then make init reload the /etc/inittab file (thereby running the mgetty command) with the following command:

    init q

Now, you can test this PPP server setup by dialing in from another PC. You will need to have your Red Hat Linux system connected to a modem, that, in turn, is connected to the phone line. You should turn on the modem, then you or a friend can dial in to that modem and establish a PPP connection using the user name and password of any existing user on the Red Hat Linux system.