home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / ppp-howt < prev    next >
Encoding:
Text File  |  1996-07-11  |  61.9 KB  |  1,531 lines

  1.   Linux PPP HOWTO
  2.   Robert Hart, hartr@hedland.edu.au
  3.   v1.0, 23 March 1996
  4.  
  5.   This document shows how to connect your Linux PC to a PPP server.
  6.  
  7.   Copyright
  8.  
  9.   The copyright of this document is retained by the author.  Permission
  10.   is granted to distribute the document by electronic means and  on CDs
  11.   provided that it is kept entirely in its original format. Permission
  12.   is also granted to print a copy of this document for personal use.
  13.  
  14.   The republishing of this document in part or in whole without the
  15.   permission of the copyright holder by any means other than as noted
  16.   above is prohibited.
  17.  
  18.   Distribution
  19.  
  20.   This document will be posted to comp.os.linux.answers on a monthly
  21.   basis or more frequently as new versions of the document are produced.
  22.  
  23.   1.  Introduction
  24.  
  25.   PPP (Point to Point Protocol) is a mechanism for creating and running
  26.   the Internet Protocol - IP (and other network protocols) over a serial
  27.   link - be that a direct serial connection or a link made using modems
  28.   and telephones. Using PPP, you can connect your Linux PC to a PPP
  29.   server and access the resources of the network to which the server is
  30.   connected (almost) as if you were directly connected to that network.
  31.  
  32.   One major difference is of course speed - an Ethernet connection
  33.   operates at 10 M bits per second (maximum theoretical throughput)
  34.   whereas a modem operates at speed up to 33.6k bits per second.
  35.   Depending on the type of PPP connection, there may be some limitations
  36.   in usage of some applications and services.
  37.  
  38.   1.1.  Clients and Servers
  39.  
  40.   When you dial into a site to establish a PPP connection, you are a
  41.   client. The machine to which you connect is called the server.
  42.  
  43.   When you are setting up a Linux box to receive and handle dial in PPP
  44.   connections, you are setting up a PPP server.
  45.  
  46.   Any Linux PC can be both a PPP server and client - even simultaneously
  47.   if you have more than one serial port (and modem if necessary). There
  48.   is no real difference between clients and servers as far as PPP is
  49.   concerned, once the connection is made. This means that PPP can (and
  50.   is) used to link together two or more local areas networks - LANs, or
  51.   to link one or more LANs into the Internet.
  52.  
  53.   In the interests of clarity,  this document refers to the machine that
  54.   initiates the call (that "dials in") as the CLIENT, whist the machine
  55.   that answers the telephone, checks the authentication of the dial in
  56.   request (using user ids, passwords and possibly other mechanisms) is
  57.   referred to as the SERVER.
  58.  
  59.   Probably the use of PPP as a client that most people are interested in
  60.   is to link one or more machines at a location into the Internet. The
  61.   procedure described in this document will allow you to establish and
  62.   automate your Internet connection.
  63.  
  64.   2.  IP Numbers
  65.  
  66.   Every device that connects to the Internet must have its own, unique
  67.   IP number. These are assigned centrally by a designated authority for
  68.   each country.
  69.  
  70.   Please note that the IP numbers used throughout this document are
  71.   FICTITIOUS! If you are connecting to the Internet, YOU MUST use an IP
  72.   number from your own assigned range. You MUST NOT pick IP numbers "out
  73.   of the air" and use these whilst connecting to another LAN (let alone
  74.   the Internet) as this will cause total havoc.
  75.  
  76.   There are IP numbers that are specifically dedicated to LANs that do
  77.   not connect to the Internet. One of these sequences is 10.0.0.0 to
  78.   10.255.255.255. This is the sequence I have used as examples in this
  79.   document.
  80.  
  81.   For most users, who are connecting a single machine (or a small LAN)
  82.   to an Internet  service provider via PPP, obtaining an IP number (or
  83.   more accurately, a network number) will not be necessary.
  84.  
  85.   If you wish to connect a small LAN, many Internet service providers
  86.   can provide you with a dedicated subnet (a specific sequence of IP
  87.   numbers) from their existing IP address space.
  88.  
  89.   For users, who are connecting a single PC to the Internet via an
  90.   Internet service provider, most providers use dynamic IP assignment.
  91.   That is, as part of the connection process, the PPP service you
  92.   contact will tell your machine what its IP number is for the current
  93.   session.  You are not given the same IP number each time you connect.
  94.   This has implications for server type applications on your Linux
  95.   machine such as sendmail, ftpd, httpd and so forth. The limitations of
  96.   service due to dynamic IP number assignment (and ways to work around
  97.   these, if possible) are discussed later in the document.
  98.  
  99.   3.  Aim of this Document
  100.  
  101.   This document attempts to assist people who wish to use Linux & PPP to
  102.   dial into a PPP server and set up an IP connection using PPP. It
  103.   assumes that PPP has been compiled and installed on your Linux machine
  104.   (but does cover reconfiguring/recompiling your kernel to include PPP
  105.   support).
  106.  
  107.   Whilst DIP (the standard way of creating a SLIP connection) can be
  108.   used to forge a PPP connection, DIP scripts are generally quite
  109.   complex. For this reason, this document does NOT cover using DIP to
  110.   forge a PPP connection.
  111.  
  112.   Instead, this document describes the standard Linux PPP software
  113.   (chat/pppd).
  114.  
  115.   This document at present does NOT cover :-
  116.  
  117.   ╖  Connecting and configuring a modem to Linux (in detail)
  118.      See the Serial-HOWTO
  119.  
  120.   ╖  Setting up a PPP server on Linux
  121.      A  PPP server HOWTO is in production and will be added to this
  122.      document when ready for release.
  123.  
  124.   ╖  Using DIP to make PPP connections
  125.      Use chat instead...
  126.  
  127.   ╖  Using PAP and CHAP to authenticate PPP connections
  128.      This will be added at a later date...
  129.  
  130.   ╖  Using socks or IP Masquerade
  131.      There are perfectly good documents already covering these two
  132.      packages.
  133.  
  134.   4.  Software versions covered
  135.  
  136.   This HOWTO assumes that you are using a Linux 1.2.x kernel with the
  137.   PPP 2.1.2 software. At present, Linux 1.3.x is still under development
  138.   and the author has yet to experiment with this.
  139.  
  140.   PPP version 2.2 is also available. Whilst this can be used with Linux
  141.   1.2.x, it is designed for Linux 1.3.x and requires kernel patching to
  142.   work with Linux 1.2.x.
  143.  
  144.   As this document is specifically designed to assist new users, it is
  145.   highly recommended that you use a version of Linux and the appropriate
  146.   PPP version that are known to be stable together,
  147.  
  148.   Once the author has the time to experiment with Linux 1.3.x and PPP
  149.   2.2, additional information will be added to this document. (Please
  150.   don't email me for this information as I will release it when it is
  151.   ready - such requests will be assigned to /dev/null).
  152.  
  153.   In the meantime, if you MUST use Linux 1.3.x, read the appropriate
  154.   documents! The information given here regarding kernel configuration
  155.   is completely wrong for 1.3.x kernels. I understand that the operation
  156.   of the PPP-2.2 version with 1.3 kernels is very similar to that
  157.   described here for PPP2.1.2 and 1.2.x kernels, but there are some
  158.   differences.
  159.  
  160.   5.  Other Useful/Important Documents
  161.  
  162.   Users are advised to read :-
  163.  
  164.   ╖  the documentation that comes with the PPP package
  165.  
  166.   ╖  the pppd and chat man pages
  167.  
  168.   ╖  the Linux Network Administration Guide (NAG)
  169.  
  170.   ╖  the Net-2 HOWTO.
  171.  
  172.   Whilst you can use this document to create your PPP link without
  173.   reading any of these documents, you will have a far better
  174.   understanding of what is going on if you do so! You will also be able
  175.   to address problems yourself (or at least ask more intelligent
  176.   questions on the comp.os.linux... newsgroups).
  177.  
  178.   These documents (as well as various others, including the relevant
  179.   RFCs) provide additional and more detailed explanation than is
  180.   possible in this HOWTO.
  181.  
  182.   If you are connecting a LAN to the Internet using PPP, you will need
  183.   to know a reasonable amount about TCP/IP networking. In addition to
  184.   the documents above, you will find the O'Reilly books "TCP/IP Network
  185.   Administration" and "Building Internet Firewalls" of considerable
  186.   benefit!
  187.  
  188.   6.  Configuring your Kernel
  189.  
  190.   In order to use PPP, your Linux kernel must be compiled to include PPP
  191.   support. Obtain the Linux source code for your kernel if you do not
  192.   already have this - it belongs in /usr/src/linux on Linux's standard
  193.   file system.
  194.  
  195.   In this directory you will find at least one README file. This
  196.   contains an excellent explanation of how to go about configuring and
  197.   compiling a new kernel. Read this file (it's a good idea to print it
  198.   out and have a copy handy whilst you are compiling until you have done
  199.   this enough times to know your way around).
  200.  
  201.   One small note - the current (Linux 1.2.13)
  202.  
  203.        make config
  204.  
  205.   dialogue does NOT allow you to go backwards - so if you make a mistake
  206.   in answering one of the questions, exit by typing CTRL C and start
  207.   again...
  208.  
  209.   You MUST know what cards/devices you have inside your PC if you are
  210.   going to recompile your kernel!!!
  211.  
  212.   In order to use PPP, you must configure the kernel to include PPP
  213.   support (PPP requires BOTH pppd AND kernel support for PPP).
  214.  
  215.   The following is an excerpt from the Linux 1.2.13 make config :-
  216.  
  217.   ______________________________________________________________________
  218.     *
  219.     * Network device support
  220.     *
  221.     Network device support? (CONFIG_NETDEVICES) [n] y
  222.     Dummy net driver support (CONFIG_DUMMY) [n] y
  223.     SLIP (serial line) support (CONFIG_SLIP) [n] n
  224.     PPP (point-to-point) support (CONFIG_PPP) [n] y
  225.   ______________________________________________________________________
  226.  
  227.   If you are concerned about security of your computer and/or LAN whilst
  228.   connected to the Internet, you may wish to add support for IP
  229.   firewalls.
  230.  
  231.   Answer the other make config questions according to the hardware in
  232.   your PC and the features of the Linux operating system you want. Then
  233.   continue to follow the README to compile and install your new kernel.
  234.  
  235.   NOTE:
  236.  
  237.   If you want to set up you Linux machine as a PPP server or internet
  238.   gateway, you should also include IP forwarding (you will need it!).
  239.  
  240.   Also, the current kernel creates only 4 PPP devices. For multi- port
  241.   serial cards, you will need to edit the kernel ppp sources to obtain
  242.   more ports. (See the README.linux file that comes as part of the
  243.   PPP-2.1.2 distribution)
  244.  
  245.   Once you have installed and rebooted your new kernel, you can start
  246.   configuring and testing your PPP link.
  247.  
  248.   7.  Getting the Information you need about the PPP service
  249.  
  250.   Before you can establish a PPP connection with a server, you need to
  251.   obtain the following information (from the sysadmin/user support
  252.   people of the PPP server):-
  253.  
  254.   ╖  The telephone number(s) to dial for the service (if you are behind
  255.      a PABX, you also need the PABX number that gives you an outside
  256.      dial tone - this is frequently digit zero)
  257.  
  258.   ╖  Does the server use DYNAMIC or STATIC IP numbers? If the server
  259.      uses STATIC IP numbers, then you need to know what IP number to use
  260.      for your end of the PPP connection.
  261.      Most Internet Service Providers use DYNAMIC IP numbers. As
  262.      mentioned above, this has some implications in terms of the
  263.      services you can use!
  264.  
  265.   ╖  If you are using static IP numbers, ask for the network mask as
  266.      well.
  267.  
  268.   ╖  What are the IP numbers of the server's Domain Name Servers? (There
  269.      should be at least two.)
  270.  
  271.   ╖  Does the server require the use of PAP/CHAP?
  272.  
  273.   ╖  Does the server automatically start PPP or do you need to issue any
  274.      commands to start PPP on the server once you are logged in? If you
  275.      must issue a command to start PPP, what is it?
  276.   Carefully note down this information - you are going to use it!
  277.  
  278.   7.1.  Testing your Modem Connection
  279.  
  280.   You should make sure that your modem is correctly set up and that you
  281.   know which serial port it is connected to.
  282.  
  283.   Remember:-
  284.  
  285.   ╖  DOS com1: = Linux /dev/cua0 (and /dev/ttyS0)
  286.  
  287.   ╖  DOS com2: = Linux /dev/cua1 (and /dev/ttyS1)
  288.      et cetera
  289.  
  290.   Using you terminal communications package (such as minicom), dial into
  291.   the PPP server you want to connect to with a PPP session. (Note: at
  292.   this stage we are NOT trying to make a PPP connection - just establish
  293.   that we have the right phone number and also to find out exactly what
  294.   the server sends to us in order to get logged in and start PPP).
  295.  
  296.   During this process, either capture (log to a file) the entire login
  297.   process or carefully (very carefully) write down exactly what prompts
  298.   the remote server gives to let you know it is time to enter your user
  299.   name and password (and any other commands needed to establish the
  300.   connection).
  301.  
  302.   It is worth dialling in at least twice - some servers change their
  303.   prompts (eg with the time!) every time you log in. The two critical
  304.   prompts your Linux box needs to be able to identify every time you
  305.   dial in are:-
  306.  
  307.   ╖  the prompt that requests you to enter your user name;
  308.  
  309.   ╖  the prompt that requests you to enter your password;
  310.  
  311.   If your server automatically starts PPP, once you have logged in, you
  312.   will start to see garbage on your screen - this is the PPP server
  313.   sending your machine information to start up the PPP connection.
  314.  
  315.   This should look something like this :-
  316.  
  317.        ~y}#.!}!}!} }8}!}$}%U}"}&} } } } }%}& ...}'}"}(}"} .~~y}
  318.  
  319.   (and it just keeps on coming!)
  320.  
  321.   At this point, you can hang up your modem (usually, type +++ quickly
  322.   and then issue the ATHO command once your modem responds with OK).
  323.  
  324.   On some systems PPP must be explicitly started on the server. This is
  325.   usually because the server has been set up to allow PPP logins and
  326.   shell logins using the same username/password pair. If this is the
  327.   case, issue this command once you have logged in. Again, you will see
  328.   the garbage as the server end of the PPP connection starts up - so you
  329.   can now hang up.
  330.  
  331.   If you do NOT see the garbage on your screen when the server starts up
  332.   PPP, it is quite likely (though not certain) that you have done
  333.   something wrong.
  334.  
  335.   Notwithstanding this, some PPP servers are set up to be passive - they
  336.   send nothing until the client (your computer) starts the PPP process.
  337.  
  338.   However, the majority of servers are active and you should see the
  339.   garbage.
  340.  
  341.   If you can't get your modem to work, read your modem manual, the man
  342.   pages for your communications software and the SERIAL HOWTO! Once you
  343.   have this sorted out, carry on as above.
  344.  
  345.   8.  Logging in without entering a user name/password - PAP and CHAP
  346.  
  347.   It is possible for a PPP server to be set up in such a way that the
  348.   user authentication is carried out by PPP itself, using PAP/CHAP. The
  349.   authentication information is exchanged by the two ppp daemons
  350.   themselves.
  351.  
  352.   This section has yet to be added.
  353.  
  354.   9.  A note about Serial Ports and speed capabilities
  355.  
  356.   If you are using a high speed modem (14,400 Baud or above), your
  357.   serial ports needs to be capable of handling the throughput that such
  358.   a modem is capable of producing. This requires your serial port to use
  359.   a modern UART (Universal Asynchronous Receiver Transmitter) such as a
  360.   16550(A).  If you are using an old machine (or old serial card), it is
  361.   quite possible that your serial port has only an 8250 UART, which will
  362.   cause you considerable problems when used with a high speed modem.
  363.  
  364.   Use the command
  365.  
  366.        setserial -a /dev/ttySx
  367.  
  368.   to get Linux to report to you the type of UART you have. If you do not
  369.   have a 16550 type UART, invest in a new serial card (available for
  370.   under $50).
  371.  
  372.   10.  Configuring your modem
  373.  
  374.   You will need to configure your modem correctly for PPP - to do this
  375.   READ YOUR MODEM MANUAL! Most modems come with a factory default
  376.   setting that selects the options required for PPP. The minimum
  377.   configuration specifies:-
  378.   ╖  Hardware flow control (RTS/CTS) (&K3 on many Hayes modems)
  379.  
  380.   Other settings (in standard Hayes commands) you should investigate
  381.   are:-
  382.  
  383.   ╖  E1 Command Echo ON (required for chat to operate)
  384.  
  385.   ╖  Q0 Report result codes (required for chat to operate)
  386.  
  387.   ╖  S0=0 Auto Answer OFF
  388.  
  389.   ╖  &C1 Carrier Detect ON only after connect
  390.  
  391.   ╖  &S0 Data Set Ready (DSR) always ON
  392.  
  393.   ╖  (depends)   Data Terminal Ready
  394.  
  395.   Use your communications software (eg minicom) to find out about your
  396.   modem configuration and set it to what is required for PPP. Many
  397.   modems report their current settings in response to AT&V, but you
  398.   should consult your modem manual. If you completely mess up the
  399.   settings, you can return to sanity (usually) by issuing an AT&F -
  400.   return to factory settings. (For most modem modems I have encountered,
  401.   the factory settings include all you need for PPP - but you should
  402.   check).
  403.  
  404.   Save your modem configuration in non-volatile RAM (usually the modem
  405.   command AT&W will do this - but check in your modem manual).
  406.  
  407.   With the correct modem configuration already in the modem, resetting
  408.   the modem will activate this. Arringing things this way considerably
  409.   simplifies the chat script necessary for the PPP connection.
  410.  
  411.   10.1.  Note on Serial Flow Control
  412.  
  413.   When data is travelling on serial communication lines, it can happen
  414.   that data arrives faster than a computer can handle it (the computer
  415.   may be busy doing something else - remember, Linux is a multi-user,
  416.   multi- tasking operating system). In order to ensure that data is not
  417.   lost (data does not over run in the input buffer and hence get lost),
  418.   some method of controlling the flow of data is necessary.
  419.  
  420.   There are two ways of doing this on serial lines:-
  421.  
  422.   ╖  Using hardware signals (Clear To Send/Request to Send - CTS/RTS)
  423.  
  424.   ╖  Using software signals (control S and control Q).
  425.  
  426.   Whilst the latter may be fine for a terminal (text) link, data on a
  427.   PPP link is 8 bits - and it is quite probable that somewhere in the
  428.   data there will be data bytes that translate as control S and control
  429.   Q. So, if a modem is set up to use software flow control, things can
  430.   rapidly go beserk!
  431.  
  432.   For PPP (which uses 8 bits of data) hardware flow control is vital.
  433.  
  434.   11.  Setting up the PPP options file
  435.  
  436.   The options to use when PPP is started up can be controlled using
  437.   command line options to the pppd command or stored in a file that the
  438.   PPP daemon (this is what pppd is) reads when it is invoked.
  439.  
  440.   11.1.  Using PPP and root privileges
  441.  
  442.   Because PPP needs to set up networking devices, change the kernel
  443.   routing table and so forth, it requires root privileges to do this.
  444.  
  445.   The pppd program should be setuid root on installation :-
  446.  
  447.        -r-sr-xr-x   1 root     root        95225 Jul 11 00:27 /usr/sbin/pppd
  448.  
  449.   If /usr/sbin/pppd is not set up this way, then as root issue the
  450.   command:-
  451.  
  452.        chmod u+s /usr/sbin/pppd
  453.  
  454.   Depending on how you want your system to operate - specifically if you
  455.   want ANY user on your system to be able to initiate a PPP, you should
  456.   make your ppp-on/off scripts world read/execute. (This is probably
  457.   fine if your PC is used ONLY by you).
  458.  
  459.   However, if you do NOT want just anyone to be able to start up a PPP
  460.   connection (for example, your children have accounts on your Linux PC
  461.   and you do not want them hooking into the Internet without your
  462.   supervision), you will need to establish a PPP group (edit /etc/group)
  463.   and :-
  464.  
  465.   ╖  Make the ppp-on/off scripts owned by group PPP
  466.  
  467.   ╖  Make the ppp-on/off scripts read/executable by group PPP
  468.  
  469.   ╖  Make the other access rights for ppp-on/off nill.
  470.  
  471.   ╖  add the users who will be firing up PPP to the PPP group in
  472.      /etc/group
  473.  
  474.          -rwxr-x---   1 root     PPP           587 Mar 14  1995 /usr/sbin/ppp-on
  475.          -rwxr-x---   1 root     PPP           631 Mar 14  1995 /usr/sbin/ppp-off
  476.  
  477.   11.2.  Setting up the files
  478.  
  479.   You now need to be logged in as root to create the directories and
  480.   edit the files needed to set up PPP, even if you want PPP to be
  481.   accessible to all users.
  482.  
  483.   In your /etc directory there should be a directory:-
  484.  
  485.        drwxrwxr-x   2 root     root         1024 Oct  9 11:01 ppp
  486.  
  487.   If it does not exist - create it.
  488.  
  489.   If the directory already existed, it should contain a template options
  490.   file called options.tpl. This file is at the end of this document.
  491.   Print it out as it contains an explanation of all the PPP options
  492.   (these are useful to read in conjunction with the pppd man pages).
  493.   Whilst you can use this file as the basis of your /etc/ppp/options
  494.   file, it is probably better to create your own options file that does
  495.   not include all the comments in the template - it will be much shorter
  496.   and easier to read/maintain.
  497.  
  498.   If you have multiple serial lines/modems (typically the case for PPP
  499.   servers), create an EMPTY /etc/ppp/options file and set up individual
  500.   option files for each serial line on which you will be establishing a
  501.   PPP connection. These are named options.ttyS1, options.ttyS2 and so
  502.   forth. If there are ppp options that are common for all lines, then
  503.   you can put these in the options file and the port specific options in
  504.   the relevant options.ttySx file.
  505.  
  506.   However, for a single PPP connection, you can happily use the
  507.   /etc/ppp/options file. Alternatively, you can put all the options as
  508.   arguments in the pppd command itself.
  509.  
  510.   It is easier to maintain a setup that uses /etc/ppp/options.ttySx
  511.   files.  If you use PPP to connect to a number of different sites, you
  512.   can create option files for each site in /etc/ppp/options.site and
  513.   then specify the option file as a parameter to the PPP command as you
  514.   connect.
  515.  
  516.   11.3.  What options should I use?
  517.  
  518.   Well, as in all things that depends (sigh)...the following is a basic
  519.   options file that should work for most client connections that do NOT
  520.   use PAP/CHAP.
  521.  
  522.   However, if it does NOT work, READ THE TEMPLATE FILE and the pppd man
  523.   pages and speak to the sysadmin/user support people who run the server
  524.   into which you are connecting.
  525.  
  526.   ______________________________________________________________________
  527.   # /etc/ppp/options (NO PAP/CHAP)
  528.   #
  529.   # use the modem control lines
  530.   modem
  531.   # use hardware flow control
  532.   crtscts
  533.   # create a default route for this connection in the routing table
  534.   defaultroute
  535.   # do NOT set up any "escaped" control sequences
  536.   asyncmap 0
  537.   # use a maximum transmission packet size of 552 bytes
  538.   mtu 552
  539.   # use a maximum receive packet size of 552 bytes
  540.   mru 552
  541.   #
  542.   #-------END OF SAMPLE /etc/ppp/options
  543.   ______________________________________________________________________
  544.  
  545.   12.  Setting up your /etc/resolv.conf file
  546.  
  547.   Whilst we humans like give names to things, computers really like
  548.   numbers. On a TCP/IP network (which is what the Internet is), we call
  549.   machines by a particular name - and every machine lives in a
  550.   particulalar dquot;domaindquot;. For example, my Linux workstation is
  551.   called archenland and it resides in the hedland.edu.au domain. Its
  552.   human readable address is thus archenland.hedland.edu.au. In order for
  553.   this machine to be findable by other computers on the Internet, it is
  554.   actually known by its IP number (203.19.8.7).
  555.  
  556.   Translating (resolving) machine (and domain) names into the numbers
  557.   actually used on the Internet is the business of machines that offer
  558.   the Domain Name Service.
  559.  
  560.   When you forge a PPP connection, you need to tell your Linux machine
  561.   where it can get host name to IP number (address translation)
  562.   information so that you can use the machine names but your computer
  563.   can translate these to the IP numbers it needs to work.
  564.  
  565.   One way is to enter every host that you want to talk to into the
  566.   /etc/hosts file (which is in reality totally impossible if you are
  567.   connecting to the Internet); another is to use the machine IP numbers
  568.   as opposed to the names (an impossible memory task for all but the
  569.   smallest LANs).
  570.  
  571.   The best way is to set up Linux so that it knows where to go to get
  572.   this name to number information - automatically. This service is
  573.   provided by the Domain Name Server system. All that is necessary is to
  574.   enter the IP numbers in your /etc/resolv.conf file.
  575.  
  576.   Your PPP server sysadmin/user support people should provide you with
  577.   at least two DNS IP numbers (only one is necessary - but two gives
  578.   some redundancy in the event of failure).
  579.  
  580.   Your /etc/resolv.conf should look something like :-
  581.  
  582.   ______________________________________________________________________
  583.   domain your.isp.domain.name
  584.   nameserver 10.25.0.1
  585.   ______________________________________________________________________
  586.  
  587.   Edit this file (creating it if necessary) to represent the information
  588.   that your ISP has provided. It should have ownership and permissions
  589.   as follows :-
  590.  
  591.        -rw-r--r--   1 root     root           73 Feb 19 01:46 /etc/resolv.conf
  592.  
  593.   If you have already set up a /etc/resolv.conf because you are on a
  594.   LAN, simply add the IP numbers of the PPP DNS servers to your existing
  595.   file.
  596.  
  597.   13.  Setting up the PPP connection manually
  598.  
  599.   Now that you have created your /etc/ppp/options and /etc/resolv.conf
  600.   files, you can test the settings by manually establishing a PPP
  601.   connection. (Once we have the manual connection working, we will
  602.   automate the process).
  603.  
  604.   To do this, your communications software must be capable of quitting
  605.   WITHOUT resetting the modem. Minicom can do this - ALT Q (or in older
  606.   version of minicom CTRL A Q)
  607.  
  608.   Make sure you are logged in as root.
  609.  
  610.   Fire up you communications software (such as minicom), dial into the
  611.   PPP server and log in as normal. If you need to issue a command to
  612.   start up PPP on the server, do so. You will now see the "garbage" you
  613.   saw before.
  614.  
  615.   Now quit the communications software without resetting the modem (ALT
  616.   Q in minicom) and at the Linux prompt (as root) type
  617.  
  618.        pppd -d -detach /dev/cuaX &
  619.  
  620.   (for dynamic IP numbers) or
  621.  
  622.        pppd -d -detach <your IP number>: /dev/cuaX
  623.  
  624.   (for static IP numbers - NOTE the colon after the IP number here)
  625.  
  626.   The -d option turns on debugging - the ppp connection start up
  627.   "conversation" will be logged to your system log - which is useful if
  628.   you are having trouble.
  629.  
  630.   Your modem lights should now flash as the PPP connection is
  631.   established.  It will take a short while for the PPP connection to be
  632.   made.
  633.  
  634.   At this point you can look at the PPP interface, by issuing the
  635.   command
  636.  
  637.   ifconfig ppp0
  638.  
  639.   You should see something like :-
  640.  
  641.   ______________________________________________________________________
  642.     ppp0     Link encap:Point-Point Protocol
  643.              inet addr:10.144.153.104  P-t-P:10.144.153.51 Mask:255.255.255.0
  644.              UP POINTOPOINT RUNNING  MTU:552  Metric:1
  645.              RX packets:0 errors:0 dropped:0 overruns:0
  646.              TX packets:0 errors:0 dropped:0 overruns:0
  647.   ______________________________________________________________________
  648.  
  649.   Where
  650.  
  651.   ╖  inet addr:10.144.153.10 is YOUR IP number
  652.  
  653.   ╖  P-t-P:10.144.153.5 is the SERVER's IP number
  654.  
  655.   (Naturally, ifconfig will not report these IP numbers, but the ones
  656.   used by your PPP server.)
  657.  
  658.   Note: ifconfig also tells you that the link is UP and RUNNING!
  659.  
  660.   If you get something like
  661.  
  662.   ______________________________________________________________________
  663.     ppp0     Link encap:Point-Point Protocol
  664.              inet addr:0.0.0.0  P-t-P:0.0.0.0  Mask:0.0.0.0
  665.              POINTOPOINT  MTU:1500  Metric:1
  666.              RX packets:63287 errors:0 dropped:0 overruns:0
  667.              TX packets:62187 errors:0 dropped:0 overruns:0
  668.   ______________________________________________________________________
  669.  
  670.   Your PPP connection has not been made...see the later section on
  671.   debugging!
  672.  
  673.   Now test the link by 'ping'ing the server at its IP number as reported
  674.   by the ifconfig output, ie
  675.  
  676.        ping 10.144.153.51
  677.  
  678.   You should receive output like
  679.  
  680.        PING 10.144.153.51 (10.144.153.51): 56 data bytes
  681.        64 bytes from 10.144.153.51: icmp_seq=0 ttl=255 time=328.3 ms
  682.        64 bytes from 10.144.153.51: icmp_seq=1 ttl=255 time=190.5 ms
  683.        64 bytes from 10.144.153.51: icmp_seq=2 ttl=255 time=187.5 ms
  684.        64 bytes from 10.144.153.51: icmp_seq=3 ttl=255 time=170.7 ms
  685.  
  686.   This listing will go on for ever - to stop it press CTRL C), at which
  687.   point you will receive some more information :-
  688.  
  689.        --- 10.144.153.51 ping statistics ---
  690.        4 packets transmitted, 4 packets received, 0% packet loss
  691.        round-trip min/avg/max = 170.7/219.2/328.3 ms
  692.  
  693.   So far so good.
  694.  
  695.   Now try pinging a host by name (not the name of the PPP server itself)
  696.   but a host at another site that you KNOW is going to be up and
  697.   running...). For example
  698.  
  699.        ping hedunx.hedland.edu.au
  700.  
  701.   This time there will be a bit of a pause as Linux obtains the IP
  702.   number for the host you have 'ping'ed from the DNS you specified in
  703.   /etc/resolv.conf - so don't worry (but you will see your modem lights
  704.   flash). Shortly you will receive output like
  705.  
  706.    PING hedunx.hedland.edu.au (10.144.153.3): 56 data bytes
  707.   64 bytes from 10.144.153.3: icmp_seq=0 ttl=254 time=190.1 ms
  708.   64 bytes from 10.144.153.3: icmp_seq=1 ttl=254 time=180.6 ms
  709.   64 bytes from 10.144.153.3: icmp_seq=2 ttl=254 time=169.8 ms
  710.   64 bytes from 10.144.153.3: icmp_seq=3 ttl=254 time=170.6 ms
  711.   64 bytes from 10.144.153.3: icmp_seq=4 ttl=254 time=170.6 ms
  712.  
  713.   Again, stop the output by pressing CTRL C and get the statistics...
  714.  
  715.        --- hedunx.hedland.edu.au ping statistics ---
  716.        5 packets transmitted, 5 packets received, 0% packet loss
  717.        round-trip min/avg/max = 169.8/176.3/190.1 ms
  718.  
  719.   If you don't get any response, check in the debugging section of this
  720.   document.
  721.  
  722.   If everything works, shut down the connection by typing
  723.  
  724.        ppp-off
  725.  
  726.   If that does not work, either turn off your modem or fire up your
  727.   communications software and interrupt the modem with +++ and then hang
  728.   up with ATH0 when you receive the modem's OK prompt.
  729.  
  730.   14.  Automating your connections - Creating the chat script
  731.  
  732.   A chat script automates the log in and PPP start up so all you have to
  733.   do (as root or as a member of the ppp group) is issue a single command
  734.   to fire up your connection.
  735.  
  736.   A chat script basically consists of expect send pairs. For example,
  737.   once the modem has dialled and connected to the remote modem, we
  738.   expect to receive a login prompt (possibly preceded by a lot of text -
  739.   such as the /etc/issue.net file on the server machine). Once we have
  740.   received this, we send our user name. Next we expect the password
  741.   prompt and send our password.
  742.  
  743.   Quite simple in principle really.
  744.  
  745.   If the ppp package installed correctly, you should have two files
  746.   in/usr/sbin called
  747.  
  748.   ppp-on
  749.   ppp-off
  750.  
  751.   These contain templates for establishing a PPP session using chat. The
  752.   ppp-off file was the one we used in the previous section to shut down
  753.   our manually established PPP session (so we know it worked - if it
  754.   did!).
  755.  
  756.   Just in case you DON'T have these templates, here are modified and
  757.   commented ones that we will be using:-
  758.  
  759.   ______________________________________________________________________
  760.   /usr/sbin/ppp-on-----------------
  761.   #!/bin/sh
  762.   #
  763.   #       ppp-on
  764.   #
  765.   #       Set up a PPP link
  766.   #
  767.   LOCKDIR=/var/lock   # Change this to suit your set up
  768.   DEVICE=cua1         # Change this to reflect the com port you are  using
  769.   PHONE=XXXXXXXX      # Change this to your ISP's phone number
  770.   USER=XXXX           # Your user name on the ISP's machine
  771.   PASSWORD=password
  772.   OUR_IP_ADDR=x.x.x.x # Your IP address for STATIC IP numbers, else 0.0.0.0
  773.  
  774.   if [ -f $LOCKDIR/LCK..$DEVICE ]
  775.   then
  776.      echo "PPP device is locked"
  777.      exit 1
  778.   fi
  779.  
  780.   fix-cua $DEVICE
  781.   (
  782.      stty 19200 -tostop
  783.   # Change this to 115200 if your modem serial port can handle it!
  784.  
  785.      if chat -v -l LCK..$DEVICE ABORT "NO CARRIER" ABORT BUSY "" ATZ OK\
  786.         ATDT$PHONE CONNECT "" ogin: $USER ssword: \\q$PASSWORD
  787.      then
  788.          pppd -d -detach asyncmap 0 modem crtscts $OUR_IP_ADDR: /dev/$DEVICE
  789.          rm -f LCK..$DEVICE
  790.          exit 0
  791.      else
  792.          echo "PPP call failed" 1>&2
  793.          exit 1
  794.      fi
  795.   ) < /dev/$DEVICE > /dev/$DEVICE
  796.   #------END
  797.   ______________________________________________________________________
  798.  
  799.   /usr/sbin/ppp-off------------------
  800.  
  801.   ______________________________________________________________________
  802.   #!/bin/sh
  803.   DEVICE=ppp0
  804.   #
  805.   # If the ppp0 pid file is present then the program is running. Stop  it.
  806.   if [ -r /var/run/$DEVICE.pid ]; then
  807.          kill -INT `cat /var/run/$DEVICE.pid`
  808.   #
  809.   # If unsuccessful, ensure that the pid file is removed.
  810.   #
  811.          if [ ! "$?" = "0" ]; then
  812.                  echo "removing stale $DEVICE pid file."
  813.                  rm -f /var/run/$DEVICE.pid
  814.                  exit 1
  815.          fi
  816.   #
  817.   # Success. Terminate with proper status.
  818.   #
  819.          echo "$DEVICE link terminated"
  820.          exit 0
  821.   fi
  822.   #
  823.   # The link is not active
  824.   #
  825.   echo "$DEVICE link is not active"
  826.   exit 1
  827.   #--------END
  828.   ______________________________________________________________________
  829.  
  830.   The file permissions and ownerships should be :-
  831.  
  832.        -rwxr-xr-x   1 root     PPP          502 Sep  3 20:04 /usr/sbin/ppp-off
  833.        -rwxr-xr-x   1 root     PPP          612 Sep  3 20:04 /usr/sbin/ppp-on
  834.  
  835.   14.1.  What a Chat script means...
  836.  
  837.   The chat command bears some discussion. A chat script is a sequence of
  838.   "expect string" "send string" pairs". In particular, note that we
  839.   ALWAYS expect something before we send something. If we are to send
  840.   something WITHOUT receiving anything first, we must use an empty
  841.   expect string (indicated by "") and similarly for expecting something
  842.   without sending anything!. Also, if a string consists of several
  843.   words, (eg NO CARRIER), you must quote the string so that it is seen
  844.   as a single entity.
  845.  
  846.   The chat line in our template is:-
  847.  
  848.        if chat -v -l LCK..$DEVICE ABORT "NO CARRIER" ABORT BUSY "" ATZ OK\
  849.           ATDT$PHONE CONNECT "" ogin: $USER ssword: \\q$PASSWORD
  850.  
  851.   Basically, this says...
  852.  
  853.   ╖  chat -v -l LCK..$DEVICE
  854.      invoke chat and set up a lock on the serial device to ensure
  855.      exclusive access ($DEVICE is a shell variable set to the port
  856.      name). The -v tells chat to copy ALL its I/O into the system log
  857.      (usually /var/log/messages)
  858.  
  859.   ╖  ABORT "NO CARRIER" ABORT BUSY
  860.      If you receive either of these two responses, abort the connection
  861.      attempt.
  862.  
  863.   ╖  "" ATZ
  864.      expect nothing ("") then send ATZ (resets the modem).
  865.  
  866.   ╖  OK ATDT$PHONE
  867.      expect OK (the modem response to ATZ) then dial $PHONE (another
  868.      shell variable defining the phone number to dial).
  869.  
  870.   ╖  CONNECT ""
  871.      expect CONNECT (the modem at the other end has answered and the
  872.      modems have successfully negotiated baud rate etc) and send nothing
  873.      ("").
  874.  
  875.   ╖  ogin: $USER
  876.      expect "ogin:" - the login prompt (minus the leading 'l' - this
  877.      needs to be edited to reflect exactly the propt that your ISP uses)
  878.      and send $USER (a shell variable set to your user name).
  879.  
  880.   ╖  ssword: \q$PASSWORD
  881.      expect "assword:" the password prompt (minus the leading `p') and
  882.      send $PASSWORD (another shell variable set to your password). The
  883.      \q tells chat NOT to place the password in syslog if chat is
  884.      invoked with -v.
  885.  
  886.   This is a very simple chat script. chat has considerable error
  887.   recovery capability and a number of other option. For more information
  888.   consult the chat manual page (man 8 chat).
  889.  
  890.   15.  Creating your ppp-on file
  891.  
  892.   Copy the ppp-on file to a new name (I tend to use ppp-sitename for
  893.   convenience and as an aid to memory as I have quite a few). This way,
  894.   you can also go back to the original if you mess up the copy you have
  895.   created.
  896.  
  897.   Now, we are going to edit this, using the information we gathered from
  898.   the sysadmin of the PPP server.
  899.  
  900.   ppp-on is a Bourne shell script. It first sets up a number of shell
  901.   variables for later use.
  902.  
  903.   15.1.  Lock file directory (LOCKDIR)
  904.  
  905.   Have a look in /var and below for your lock file directory. For a
  906.   Linux standard file system, this will be /var/lock (older systems may
  907.   use /var/spool/lock).
  908.  
  909.   Edit the LOCKDIR= line so it points at the lock directory your system
  910.   uses..
  911.  
  912.   15.2.  Serial device (DEVICE)
  913.  
  914.   This is the serial device to which you have connected you modem -
  915.   without the /dev/ prefix.
  916.  
  917.   Edit the DEVICE= line so it points at the serial port on which you
  918.   have your modem.
  919.  
  920.   15.3.  PPP server phone number (PHONE)
  921.  
  922.   This is the phone number to dial to reach the PPP server (don't forget
  923.   any leading numbers necessary to get past a PABX - you can insert the
  924.   standard dial pause command ',' if necessary.
  925.  
  926.   Edit the PHONE= line so it is the PPP server's phone number
  927.  
  928.   15.4.  User name (USER)
  929.  
  930.   This is the user name you use to log into your PPP server.
  931.  
  932.   Edit the USER= line so it is your PPP server user name (don't forget,
  933.   Unix and most PPP servers are case sensitive - so get the
  934.   capitals/lower case right!).
  935.  
  936.   15.5.  Password (PASSWORD)
  937.  
  938.   This is the password you use to log into your PPP server.
  939.  
  940.   Edit the PASSWORD line so it contains your password, as you would type
  941.   it in at the password: prompt (again, remember that passwords can be
  942.   both upper and lower case!).
  943.  
  944.   Now, this is a bit of a problem! As the file permissions are currently
  945.   set up, anyone can read the ppp-on (or whatever you called it) file -
  946.   and can thus obtain your password! So, when you have finished editing
  947.   this file change its permissions to be 700 (chmod 750 /usr/sbin/ppp-
  948.   on) so that only the root user and members of the PPP group can read
  949.   this file!
  950.  
  951.   Remember, even if you are the only user of your machine, you are
  952.   setting up a link that connects it to the Internet (or some other
  953.   network).  Linux is a multi-user operating system and whilst you are
  954.   connected, anyone on the Internet may try to get into your system - if
  955.   they get hold of your user name and password, they can log into your
  956.   account - at the very least costing you money if not severe
  957.   embarrassment or worse if they do "naughty things" using your account!
  958.  
  959.   15.6.  Your IP address (OUR_IP_ADDR)
  960.  
  961.   If the server you are connecting to uses DYNAMIC IP numbers, set this
  962.   to 0.0.0.0 - or better, delete this line altogether (in which case you
  963.   must also remove $OUR_IPADDR: from the pppd invocation).
  964.   If your PPP server sysadmin has given you your own IP number, you are
  965.   using STATIC IP numbers. So edit this line so it is set to the IP
  966.   number you have been given.
  967.  
  968.   15.7.  Edit the 'chat' line
  969.  
  970.   The entire chat command must be on one line - no line breaks allowed
  971.   (except as specified in the chat man page).
  972.  
  973.   The chat line starts with options to chat itself.
  974.  
  975.        -l LCK..$DEVICE
  976.  
  977.   This sets up the lock file.
  978.  
  979.   One other VERY useful option for debugging is '-v' which tells chat to
  980.   log the entire chat "expect send" conversation to the system log. When
  981.   you are first setting up the connection, I strongly suggest you use
  982.   the -v option, so the start of the chat line would be
  983.  
  984.        -v -l LCK..$DEVICE
  985.  
  986.   The expect/send pairs start with
  987.  
  988.        "" ATZ
  989.  
  990.   This means "expect nothing and send ATZ" (which resets the modem,
  991.   loading its default configuration).
  992.  
  993.   Now we have
  994.  
  995.        OK ATDT$PHONE
  996.  
  997.   which "expects" an OK response (the result of the ATZ) and then sends
  998.   the tone dial command and phone number. If you cannot configure your
  999.   modem so that its reset state is the one used for PPP, you can include
  1000.   a modem initialisation string here (consult your modem manual). For
  1001.   example:-
  1002.        OK ATDT&K3S0=0DT$PHONE
  1003.  
  1004.   As we have set our modem to be correctly configured once it receives
  1005.   an ATZ, we do not have to include a modem initialisation string.
  1006.  
  1007.   The next pair is
  1008.  
  1009.        CONNECT ""
  1010.  
  1011.   which means expect CONNECT (our modem sends this when it connects) and
  1012.   send nothing.
  1013.  
  1014.   Now we get to the login process itself.
  1015.  
  1016.        ogin: $USER
  1017.  
  1018.   which looks for the login prompt and sends our user name. Edit this
  1019.   expect string to reflect the login process you carefully captured when
  1020.   you logged in before.
  1021.  
  1022.   We now look for the password prompt
  1023.  
  1024.        assword: \\q$PASSWORD
  1025.  
  1026.   which looks for the password prompt and then sends our password. The
  1027.   \q tells chat NOT to log the actual text of our password to the system
  1028.   log file (instead ?????? is recorded instead) if we are using the -v
  1029.   option to chat.
  1030.  
  1031.   If you need to issue a command to start up PPP on the server, add an
  1032.   additional "expect send" pair - this one would look for your login
  1033.   prompt (beware of characters that have a special meaning in the Bourne
  1034.   shell - such as $ and  or  (open and close square brackets) - and
  1035.   issue the ppp start up command.
  1036.  
  1037.   In my case, my PPP server uses the standard Linux Bash prompt
  1038.  
  1039.   [hartr@kepler hartr]$
  1040.  
  1041.   and requires that I type
  1042.  
  1043.        ppp
  1044.  
  1045.   to start up PPP on the server, so my expect/send pair is
  1046.  
  1047.        hartr ppp
  1048.  
  1049.   (NB - chat has significantly more capability than this - including
  1050.   recovering from errors and missed "expects" - read the chat man pages
  1051.   for more information).
  1052.  
  1053.   Unfortunately, some servers produce a very variable set of prompts!
  1054.   You may need to log in several times using minicom to understand what
  1055.   is going on and pick the stable "expect" strings.
  1056.  
  1057.   15.8.  Edit the pppd line
  1058.  
  1059.   Because you have set up a /etc/ppp/options file, you do not need to
  1060.   specify ANY ppp options other than $DEVICE (which tells PPP which
  1061.   serial port to bind to).
  1062.  
  1063.   However, all the PPP options can be specified, and the only
  1064.   requirement is that the pppd command and its options is all on one
  1065.   line AND the device (followed by the baud rate if specified) must be
  1066.   the last options specified.
  1067.  
  1068.   As we have already seen, you can turn on debug information logging
  1069.   with the -d option to pppd. As we are establishing a new connection
  1070.   with a new script, put in the -d as the first (and possibly only
  1071.   option apart from $DEVICE) to pppd. (Warning: if your disk space is
  1072.   tight, logging pppd exchanges can rapidly extend your syslog file and
  1073.   run you into trouble - but to do this you must fail to connect and
  1074.   keep on trying for quite a few minutes).
  1075.  
  1076.   If you have called your ppp options file anything other than
  1077.   /etc/ppp/options or /etc/ppp/options.ttySx, specify the file name with
  1078.   the -f option to pppd - eg
  1079.  
  1080.   -f options.myserver
  1081.  
  1082.   15.9.  Save your script
  1083.  
  1084.   OK that's it - exit the editor and NOW CHANGE THE PERMISSIONS ON YOUR
  1085.   SCRIPT FILE to 750!!!
  1086.  
  1087.   16.  Testing your chat script
  1088.  
  1089.   Open a new root Xterm (if you are in X) or open a new virtual console
  1090.   and log in as root.
  1091.  
  1092.   In this new session, issue the command
  1093.  
  1094.        tail -f /var/log/messages
  1095.  
  1096.   (or whatever your system log file is).
  1097.  
  1098.   In the first window (or virtual console) issue the command
  1099.  
  1100.        ppp-on &
  1101.  
  1102.   (or whatever name you have called your edited version of
  1103.   /usr/sbin/ppp- on). If you do not "put the script into the background"
  1104.   by specifying & at the end of the command, you will not get your
  1105.   terminal prompt back until ppp exits (when the link terminates).
  1106.  
  1107.   Now switch back to the window that is tracking your system log.
  1108.  
  1109.   You will see something like the following (provided you specified -v
  1110.   to chat and -d to pppd)....this is the chat script and responses being
  1111.   logged to the system log file followed by the start up information for
  1112.   pppd :-
  1113.  
  1114.   ______________________________________________________________________
  1115.   Oct 21 16:09:58 hwin chat[19868]: abort on (NO CARRIER)
  1116.   Oct 21 16:09:59 hwin chat[19868]: abort on (BUSY)
  1117.   Oct 21 16:09:59 hwin chat[19868]: send (ATZ^M)
  1118.   Oct 21 16:09:59 hwin chat[19868]: expect (OK)
  1119.   Oct 21 16:10:00 hwin chat[19868]: ATZ^M^M
  1120.   Oct 21 16:10:00 hwin chat[19868]: OK -- got it
  1121.   Oct 21 16:10:00 hwin chat[19868]: send (ATDT722298^M)
  1122.   Oct 21 16:10:00 hwin chat[19868]: expect (CONNECT)
  1123.   Oct 21 16:10:00 hwin chat[19868]: ^M
  1124.   Oct 21 16:10:22 hwin chat[19868]: ATDT722298^M^M
  1125.   Oct 21 16:10:22 hwin chat[19868]: CONNECT -- got it
  1126.   Oct 21 16:10:22 hwin chat[19868]: send (^M)
  1127.   Oct 21 16:10:22 hwin chat[19868]: expect (ogin:)
  1128.   Oct 21 16:10:22 hwin chat[19868]:  57600^M
  1129.   Oct 21 16:10:23 hwin chat[19868]: ^[[;H^[[2J^M^M
  1130.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1131.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1132.   Oct 21 16:10:23 hwin chat[19868]: ^I^I      This is node  kepler.hedland.edu.au^M
  1133.   Oct 21 16:10:23 hwin chat[19868]: ^I^I^I      at Hedland Campus^M
  1134.   Oct 21 16:10:23 hwin chat[19868]: ^I^I^I       Hedland College^M
  1135.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1136.   Oct 21 16:10:23 hwin chat[19868]: ^I^I  Authorised user ONLY are to use this system^M
  1137.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1138.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1139.   Oct 21 16:10:23 hwin chat[19868]: ^I^I For more information, contact ComputerSystems^M
  1140.   Oct 21 16:10:23 hwin chat[19868]: ^I^I^I     on +61 (0)91 72 0400^M
  1141.   Oct 21 16:10:23 hwin chat[19868]: ^I^I^I^I     or^M
  1142.   Oct 21 16:10:23 hwin chat[19868]: ^I^I       email:  help@hedunx.hedland.edu.au^M
  1143.   Oct 21 16:10:23 hwin chat[19868]: ^M
  1144.   Oct 21 16:10:23 hwin last message repeated 3 times
  1145.   Oct 21 16:10:23 hwin chat[19868]: kepler login: -- got it
  1146.   Oct 21 16:10:23 hwin chat[19868]: send (hartr^M)
  1147.   Oct 21 16:10:23 hwin chat[19868]: expect (ssword:)
  1148.   Oct 21 16:10:23 hwin chat[19868]:  hartr^M
  1149.   Oct 21 16:10:23 hwin chat[19868]: Password: -- got it
  1150.   Oct 21 16:10:23 hwin chat[19868]: send (??????^M)
  1151.   Oct 21 16:10:23 hwin chat[19868]: expect (hartr)
  1152.   Oct 21 16:10:23 hwin chat[19868]:  ^M^M
  1153.   Oct 21 16:10:24 hwin chat[19868]: Last login: Sat Oct 21 14:55:53 on  ttyC0^M
  1154.   Oct 21 16:10:24 hwin chat[19868]: ^M
  1155.   Oct 21 16:10:24 hwin last message repeated 9 times
  1156.   Oct 21 16:10:24 hwin chat[19868]: ^I^IYou have logged into node  kepler.hedland.edu.au^M
  1157.   Oct 21 16:10:24 hwin chat[19868]: ^M
  1158.   Oct 21 16:10:24 hwin chat[19868]:            This is a Compaq Prolinea 486DX2/50 running Linux 1.1.54^M
  1159.   Oct 21 16:10:24 hwin chat[19868]: ^M
  1160.   Oct 21 16:10:24 hwin chat[19868]:        This computer operates as the main Hedland Campus communications^M
  1161.   Oct 21 16:10:24 hwin chat[19868]: ^I       node, providing dial-in terminal and SLIP access,^M
  1162.   Oct 21 16:10:24 hwin chat[19868]: ^I^I      Kepler also runs the Hedland end of^M
  1163.   Oct 21 16:10:24 hwin chat[19868]: ^I^I    the Hedland/Newman inter-Campus WAN link^M
  1164.   Oct 21 16:10:24 hwin chat[19868]: ^M
  1165.   Oct 21 16:10:24 hwin chat[19868]: ^M
  1166.   Oct 21 16:10:24 hwin chat[19868]: [hartr -- got it
  1167.   Oct 21 16:10:24 hwin chat[19868]: send (ppp^M)
  1168.   Oct 21 16:10:27 hwin pppd[19872]: pppd 2.1.2 started by root, uid 0
  1169.   Oct 21 16:10:27 hwin pppd[19873]: Using interface ppp0
  1170.   Oct 21 16:10:27 hwin pppd[19873]: Connect: ppp0 <--> /dev/cua1
  1171.   Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(LCP): Sent code 1, id 1.
  1172.   Oct 21 16:10:27 hwin pppd[19873]: LCP: sending Configure-Request, id 1
  1173.   Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfreq(LCP): Rcvd id 1.
  1174.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd MRU
  1175.   Oct 21 16:10:27 hwin pppd[19873]: (1500)
  1176.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1177.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd ASYNCMAP
  1178.   Oct 21 16:10:27 hwin pppd[19873]: (0)
  1179.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1180.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd MAGICNUMBER
  1181.   Oct 21 16:10:27 hwin pppd[19873]: (a098b898)
  1182.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1183.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd PCOMPRESSION
  1184.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1185.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd ACCOMPRESSION
  1186.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1187.   Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: returning CONFACK.
  1188.   Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(LCP): Sent code 2, id 1.
  1189.   Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfack(LCP): Rcvd id 1.
  1190.   Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 1, id 1.
  1191.   Oct 21 16:10:27 hwin pppd[19873]: IPCP: sending Configure-Request, id 1
  1192.   Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfreq(IPCP): Rcvd id 1.
  1193.   Oct 21 16:10:27 hwin pppd[19873]: ipcp: received ADDR
  1194.   Oct 21 16:10:27 hwin pppd[19873]: (10.144.153.51)
  1195.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1196.   Oct 21 16:10:27 hwin pppd[19873]: ipcp: received COMPRESSTYPE
  1197.   Oct 21 16:10:27 hwin pppd[19873]: (45)
  1198.   Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
  1199.   Oct 21 16:10:27 hwin pppd[19873]: ipcp: returning Configure-ACK
  1200.   Oct 21 16:10:28 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 2, id 1.
  1201.   Oct 21 16:10:30 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 1, id 1.
  1202.   Oct 21 16:10:30 hwin pppd[19873]: IPCP: sending Configure-Request, id 1
  1203.   Oct 21 16:10:30 hwin pppd[19873]: fsm_rconfreq(IPCP): Rcvd id 255.
  1204.   Oct 21 16:10:31 hwin pppd[19873]: ipcp: received ADDR
  1205.   Oct 21 16:10:31 hwin pppd[19873]: (10.144.153.51)
  1206.   Oct 21 16:10:31 hwin pppd[19873]:  (ACK)
  1207.   Oct 21 16:10:31 hwin pppd[19873]: ipcp: received COMPRESSTYPE
  1208.   Oct 21 16:10:31 hwin pppd[19873]: (45)
  1209.   Oct 21 16:10:31 hwin pppd[19873]:  (ACK)
  1210.   Oct 21 16:10:31 hwin pppd[19873]: ipcp: returning Configure-ACK
  1211.   Oct 21 16:10:31 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 2, id 255.
  1212.   Oct 21 16:10:31 hwin pppd[19873]: fsm_rconfack(IPCP): Rcvd id 1.
  1213.   Oct 21 16:10:31 hwin pppd[19873]: ipcp: up
  1214.   Oct 21 16:10:31 hwin pppd[19873]: local  IP address 10.144.153.104
  1215.   Oct 21 16:10:31 hwin pppd[19873]: remote IP address 10.144.153.51
  1216.   ______________________________________________________________________
  1217.  
  1218.   (Note - I am using STATIC IP numbers - hence my machine sent that to
  1219.   the PPP server - you won't see this if you are using DYNAMIC IP
  1220.   numbers.)
  1221.  
  1222.   This looks OK - so test it out as before with pings to IP numbers and
  1223.   host names.
  1224.  
  1225.   Fire up you web browser or whatever and go surfing - you are
  1226.   connected!
  1227.  
  1228.   17.  Shutting down the PPP link
  1229.  
  1230.   When you have finished with the PPP link, use the standard ppp-off
  1231.   command to shut it down (remember - you need to be root or a member of
  1232.   the PPP group!).
  1233.  
  1234.   In your system log you will see something like:-
  1235.  
  1236.   ______________________________________________________________________
  1237.   Oct 21 16:10:45 hwin pppd[19873]: Interrupt received: terminating link
  1238.   Oct 21 16:10:45 hwin pppd[19873]: ipcp: down
  1239.   Oct 21 16:10:45 hwin pppd[19873]: default route ioctl(SIOCDELRT): Bad address
  1240.   Oct 21 16:10:45 hwin pppd[19873]: fsm_sdata(LCP): Sent code 5, id 2.
  1241.   Oct 21 16:10:46 hwin pppd[19873]: fsm_rtermack(LCP).
  1242.   Oct 21 16:10:46 hwin pppd[19873]: Connection terminated.
  1243.   Oct 21 16:10:46 hwin pppd[19873]: Exit.
  1244.   ______________________________________________________________________
  1245.  
  1246.   18.  I Can't get a connection...
  1247.  
  1248.   There are any number of reasons that this can happen - chat has failed
  1249.   to complete correctly, you have a dirty line, etc. So check your
  1250.   syslog for indications.
  1251.  
  1252.   Now look in the PPP FAQ (which is really a series of questions and
  1253.   answers). This is a very comprehensive document and the answers ARE
  1254.   there! From my own (recent and sad) experience, if the answer to your
  1255.   problems is not there, the problem is NOT ppp's fault! In my case I
  1256.   was using an ELF kernel that I had not upgraded when I had upgraded
  1257.   the kernel modules. I only wasted about 2 days (and most of one night)
  1258.   cursing what had been a perfect PPP server before the light dawned!
  1259.  
  1260.   19.  After the link comes up...
  1261.  
  1262.   19.1.  Special routing, flushing the sendmail queue etc
  1263.  
  1264.   There is one further piece of automation possible. Once the PPP link
  1265.   is established, pppd looks for /etc/ppp/ip-up. If this script exists
  1266.   and is executable, the PPP daemon executes the script. This allows you
  1267.   to automate any special routing commands that may be necessary and any
  1268.   other actions that you want to occur every time the PPP link is
  1269.   activated.
  1270.  
  1271.   For example, you can get sendmail to dispatch any waiting outbound
  1272.   messages in the mail queue.
  1273.  
  1274.   Similarly, you can insert the commands into ip-up to collect (using
  1275.   pop) any email waiting for you at your ISP.
  1276.  
  1277.   20.  Shutting down the link
  1278.  
  1279.   The existing  /usr/sbin/ppp-off script should work just fine. The only
  1280.   changes you may wish to make are for the script to wait for any
  1281.   outgoing email currently being processed by sendmail.
  1282.  
  1283.   In addition, you can create a script file that will be executed once
  1284.   the link has been terminated. This is stored in /etc/ppp/ip-down. It
  1285.   can be used to undo anything special that you did in the corresponding
  1286.   /etc/ppp/ip-up script.
  1287.  
  1288.   21.  Routing issues on a LAN
  1289.  
  1290.   If you are connected to a LAN but still want to use PPP, you need to
  1291.   address some issues of the routes packets need to take from your
  1292.   machine to reach your LAN (through your Ethernet interface) and also
  1293.   to the remote PPP server and beyond.
  1294.  
  1295.   This section does NOT attempt to teach you about routing - it deals
  1296.   only with a simple, special case of (static) routing!
  1297.  
  1298.   I strongly urge you to read the Linux Network Administrator Guide
  1299.   (NAG) if you are NOT familiar with routing. Also the O'Reilly book
  1300.   "TCP/IP Network Administration" covers this topic in a very
  1301.   understandable form.
  1302.  
  1303.   The basic rule of static routing is that the DEFAULT route should be
  1304.   the one that points to the MOST number of network addresses. For other
  1305.   networks, enter specific routes to the routing table.
  1306.  
  1307.   The ONLY situation I am going to cover here is where your Linux box is
  1308.   on a LAN that is not connected to the Internet - and you want to dial
  1309.   out to the Internet whilst still connected to the LAN.
  1310.  
  1311.   First of all, make sure that your Ethernet route is set up to the
  1312.   specific network addresses available across your LAN - NOT set to the
  1313.   default route!
  1314.  
  1315.   Check this by issuing a route command, you should see something like
  1316.   the following:-
  1317.  
  1318.        [root@hwin /root]# route -n
  1319.        Kernel routing table
  1320.        Destination     Gateway         Genmask         Flags MSS    Window Use Iface
  1321.        loopback        *               255.255.255.0   U     1936   0       50 lo
  1322.        10.0.0.0        *               255.255.255.0   U     1436   0      565 eth0
  1323.  
  1324.   If your Ethernet interface (eth0) is pointing at the default route,
  1325.   (the first column will show "default" in the eth0 line) you need to
  1326.   change your Ethernet initialisation scripts to make it point at the
  1327.   specific network numbers rather than the default route (consult the
  1328.   Net2 HOWTO and NAG).
  1329.  
  1330.   This will allow pppd to set up your default route as shown below:-
  1331.  
  1332.   [root@hwin /root]# route -n
  1333.   Kernel routing table
  1334.  
  1335.   Destination     Gateway         Genmask         Flags MSS    Window Use Iface
  1336.   10.144.153.51   *               255.255.255.255 UH    488    0        0 ppp0
  1337.   127.0.0.0       *               255.255.255.0   U     1936   0       50 lo
  1338.   10.1.0.0        *               255.255.255.0   U     1436   0      569 eth0
  1339.   default         10.144.153.51   *               UG    488    0        3 ppp0
  1340.  
  1341.   As you can see, we have a host route to the PPP server (
  1342.   10.144.153.51) via ppp0 and also a default network route that uses the
  1343.   PPP server as its gateway.
  1344.  
  1345.   If your set up needs to be more complex than this - read the routing
  1346.   documents already mentioned and consult an expert at your site!
  1347.  
  1348.   If your LAN already has routers on it, you will already have gateways
  1349.   established to the wider networks available at your site. You should
  1350.   STILL point your default route at the PPP interface - and make the
  1351.   other routes specific to the networks they serve.
  1352.  
  1353.   21.1.  Note on Security
  1354.  
  1355.   When you set up a Linux box on an existing LAN to link into the
  1356.   Internet, you are potentially opening your entire LAN to the Internet
  1357.   - and the hackers that reside there. Before you do this, I strongly
  1358.   urge you to consult your network administrator and site security
  1359.   policy. If your PPP connection to the Internet is used to successfully
  1360.   attack your site, you will at the very least earn the intense anger of
  1361.   your fellow users, network and system administrators. You may also
  1362.   find yourself in very much more serious trouble!
  1363.  
  1364.   Before you connect a LAN to the Internet, you should consider the
  1365.   security implications of even a DYNAMIC connection - hence the earlier
  1366.   reference to the O'Reilly "Building Internet Firewalls"!
  1367.  
  1368.   22.  Debugging
  1369.  
  1370.   If you can't get you PPP link to work, go back through this document
  1371.   and check everything - in conjunction with the output created by
  1372.   "chat-v..."  and "pppd -d" in you system log.
  1373.  
  1374.   Also consult the PPP documentation and FAQ plus the other documents
  1375.   mention herein!
  1376.  
  1377.   If you are still stuck, the comp.os.linux.misc and
  1378.   comp.os.linux.networking newsgroups are reasonably regularly scanned
  1379.   by people that can help you with PPP (including myself) as is
  1380.   comp.protocols.ppp
  1381.  
  1382.   You can try sending me personal email, but I do have a day job and I
  1383.   do not guarantee to respond quickly (if at all) as this depends on my
  1384.   current work load and the state of my private life!
  1385.  
  1386.   In particular - DO NOT POST REAMS OF DEBUGGING OUTPUT TO THE NEWS
  1387.   GROUPS NOR SEND IT TO ME BY EMAIL - the former wastes huge amounts of
  1388.   network bandwidth and the latter will be consigned to /dev/null
  1389.   (unless I have specifically requested it!).
  1390.  
  1391.   23.  Common Problems once the link is working
  1392.  
  1393.   One problem you will find is that many service providers will only
  1394.   support the connection software package that they distribute to new
  1395.   accounts. This is (typically) for Microsoft Windows - and many service
  1396.   provider help desks seem to know nothing about Unix (or Linux). So, be
  1397.   prepared for limited assistance from them!
  1398.  
  1399.   23.1.  I can't see beyond the PPP server I connect to
  1400.  
  1401.   OK - your PPP connection is up and running and you can ping the PPP
  1402.   server by IP number (the second or "remote" IP number shown by
  1403.   ifcongig ppp0), but you can't reach anything beyond this.
  1404.  
  1405.   First of all, try pinging the IP numbers you have specified in
  1406.   /etc/resolv.conf as name servers. If this works, you can see beyond
  1407.   your PPP server (unless this has the same IP number as the "remote" IP
  1408.   number of your connection). So now try pinging the full Internet name
  1409.   of your service provider - eg
  1410.  
  1411.        ping my.provider.net.au
  1412.  
  1413.   If this does NOT work, you have a problem with the name resolution.
  1414.   This is probably because of a typo in your /etc/resolv.conf file.
  1415.   Check this carefully against the information you acquired by ringing
  1416.   your service provider. If all looks OK, ring your service provider and
  1417.   check that you wrote down the IP numbers correctly.
  1418.  
  1419.   If it STILL doesn't work (and your service provider confirms that his
  1420.   name servers are up and running), you have a problem somewhere else -
  1421.   and I suggest you check carefully through your Linux installation
  1422.   (looking particularly for file permissions).
  1423.  
  1424.   If you can't ping you service provider's IP name servers by IP number,
  1425.   either they are down (give them a voice call and check) or there is a
  1426.   routing problem at your service provider's end. Again, ring them and
  1427.   check this out.
  1428.  
  1429.   One possibility is that the "remote end" is a Linux PPP server where
  1430.   the IP forwarding option has not been specified in the kernel!
  1431.  
  1432.   A good general test is to try hooking in to your service provider
  1433.   using the software that most supply for Microsoft Windows. If
  1434.   everything works from another operating system to exactly the same
  1435.   account, then the problem is with your Linux system and NOT your
  1436.   service provider.
  1437.  
  1438.   23.2.  I can send email, but not receive it
  1439.  
  1440.   If you are using dynamic IP numbers, this is perfectly normal. See
  1441.   "Setting up Services" below.
  1442.  
  1443.   23.3.  Why can't people finger, WWW, gopher, talk etc to my machine?
  1444.  
  1445.   Again, if you are using dynamic IP numbers, this is perfectly normal.
  1446.   See "Setting up Services" below.
  1447.  
  1448.   24.  Using Internet services with Dynamic IP numbers
  1449.  
  1450.   If you are using dynamic IP number (and many service providers will
  1451.   only give you a dynamic IP number unless you pay significantly more
  1452.   for your connection), then you have to recognise the limitations this
  1453.   imposes.
  1454.  
  1455.   First of all, outbound service requests will work just fine. That is
  1456.   you can send email using sendmail, ftp from remote sites, finger users
  1457.   on other machines, browse the web etc.
  1458.  
  1459.   However, your machine is NOT connected to the Internet 24 hours a day,
  1460.   nor does it have the same IP number every time it is connected. So it
  1461.   is impossible for you to receive email directed to your machine, set
  1462.   up a web or ftp server! As far as the Internet is concerned your
  1463.   machine does not exist as a unique, permanently contactable machine as
  1464.   it does not have a unique IP number.
  1465.  
  1466.   If you set up a WWW (or any other server), it is totally unknown by
  1467.   any user on the Internet UNLESS they know that your machine is
  1468.   connected AND its actual (current) IP number. There are a number of
  1469.   ways they can get this info, ranging from you ringing them, sending
  1470.   them email to tell them or cunning use of ".plan" files on a shell
  1471.   account at your service provider (assuming that your provider allows
  1472.   shell access).
  1473.  
  1474.   Now, for most users, this is not a problem - all that most people want
  1475.   is to send and receive email (using your account on your service
  1476.   provider) and make outbound connections to WWW, ftp and other servers
  1477.   on the Internet. If you MUST have inbound connections to your server,
  1478.   you should really get a static IP number. Alternatively you can
  1479.   explore the methods hinted at above...
  1480.  
  1481.   24.1.  Setting up email
  1482.  
  1483.   Even for dynamic IP numbers, you can certainly configure sendmail on
  1484.   you machine to send out any email that you compose locally.
  1485.   Configuration of sendmail can be obscure and difficult - so this
  1486.   document does not attempt to tell you how to do this. However, you
  1487.   should probably configure sendmail so that your Internet service
  1488.   provider is designated as you "smart relay" host (the sendmail.cf DS
  1489.   option). (For more sendmail configuation info, see the sendmail
  1490.   documents - and look at the m4 configurations that come with sendmail.
  1491.   There is almost certain to be one there that will meet your needs).
  1492.  
  1493.   Once you have sendmail configured, you will probably want to have
  1494.   sendmail dispatch any messages that have been sitting in the outbound
  1495.   mail queue as soon as the PPP connection comes up. To do this, add the
  1496.   command
  1497.  
  1498.        sendmail -q
  1499.  
  1500.   to your ip-up script.
  1501.  
  1502.   Inbound email is a problem for dynamic IP numbers. The way to handle
  1503.   this is to:-
  1504.  
  1505.   ╖  configure your mail user agent so that all mail is sent out with a
  1506.      "reply to" header giving your email address at your Internet
  1507.      Service provider.
  1508.  
  1509.   ╖  use the popclient program to retrieve your email from your service
  1510.      provider.
  1511.  
  1512.   24.2.  Setting Up a local Name server
  1513.  
  1514.   Whilst you can quite happily use the domain name servers located at
  1515.   your ISP, you can also set up a local caching only name server that is
  1516.   brought up by the ip-up script. The advantage of running a local
  1517.   (caching only) name server is that it will save you time (and
  1518.   bandwidth) if you frequently contact the same sites during a session.
  1519.  
  1520.   DNS configuration for a caching only nameserver (that uses a
  1521.   "forwarders' line in the named.boot file pointing at your ISPs DNS) is
  1522.   relatively simple. The O'Reilly book (DNS and Bind) explains all you
  1523.   want to know about this. I also hear a rumour that there is a DNS
  1524.   (mini) HOWTO in production...
  1525.  
  1526.   One point of Nettiquette: ask permission of your ISP before you start
  1527.   using a secondary, caching only name server in your ISP's domain.
  1528.   Properly configured, your DNS will not cause any problems to your ISP
  1529.   at all, but if you get things wrong, it can cause problems....
  1530.  
  1531.