<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Coldfusion Web Hosting - Tomcat, Jsp, J2Ee, Servlets, Struts Blog</title>
	<link>http://coldfusion.armadillowebhosting.com</link>
	<description>Serious weblog about Java, Tomcat and PHP development</description>
	<pubDate>Mon, 16 Jul 2007 01:08:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>Inside Linux The following shows a sample nfs  (Web hosting services)</title>
		<link>http://coldfusion.armadillowebhosting.com/coldfusion/inside-linux-the-following-shows-a-sample-nfs-web-hosting-services/</link>
		<comments>http://coldfusion.armadillowebhosting.com/coldfusion/inside-linux-the-following-shows-a-sample-nfs-web-hosting-services/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 01:08:12 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>Coldfusion</category>
		<guid isPermaLink="false">http://coldfusion.armadillowebhosting.com/coldfusion/inside-linux-the-following-shows-a-sample-nfs-web-hosting-services/</guid>
		<description><![CDATA[Inside Linux   The following shows a sample nfs script.   #  . /etc/rc.config  nfs=no  while read where what type options rest ; do    case &#8220;$where&#8221; in #*&#124;&#8221;") ;;  *) case &#8220;$options&#8221; in    *noauto*) ;;   *) if test &#8220;$type&#8221; = &#8220;nfs&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Inside Linux   The following shows a sample nfs script.   #  . /etc/rc.config  nfs=no  while read where what type options rest ; do    case &#8220;$where&#8221; in #*|&#8221;") ;;  *) case &#8220;$options&#8221; in    *noauto*) ;;   *) if test &#8220;$type&#8221; = &#8220;nfs&#8221; ; then  nfs=yes  break    fi ;;  esac    esac  done < /etc/fstab  case `uname -r` in    0.*|1.*|2.0.*) RPCSTATD="" ; RPCLOCKD="" ;;   *)  test -x /usr/sbin/rpc.kstatd &#038;&#038; RPCSTATD=/usr/sbin/rpc.kstatd  test -x /usr/sbin/rpc.klockd &#038;&#038; RPCLOCKD=/usr/sbin/rpc.klockd  ;;    esac  return=$rc_done  case "$1" in    start|reload)  test "$nfs" = "yes" || exit 0;  test -n "$RPCLOCKD" &#038;&#038; startproc $RPCLOCKD  test -n "$RPCSTATD" &#038;&#038; startproc $RPCSTATD  echo -n "Importing Network File System (NFS)"  mount -at nfs || return=$rc_failed  sleep 1  ldconfig -X 2>/dev/null  echo -e &#8220;$return&#8221;  ;;    stop)  test &#8220;$nfs&#8221; = &#8220;yes&#8221; &#038;&#038; echo -n &#8220;Remove Net File System (NFS)&#8221;  umount -at nfs &#038;  sleep 2  test &#8220;$nfs&#8221; = &#8220;yes&#8221; &#038;&#038; echo -e &#8220;$return&#8221;  ;;    restart)  $0 stop &#038;&#038; $0 start || return=$rc_failed  ;;    status)  mount -t nfs | while read from x point rest ; do    echo -e &#8220;$from 33[50G$point&#8221;  done  ;;    *)  echo &#8220;Usage: $0 {start|stop|status|reload|restart}&#8221;  exit 1    esac  test &#8220;$return&#8221; = &#8220;$rc_done&#8221; || exit 1  exit 0    As mentioned previously, mountd is the mount daemon and nfsd is the NFS server daemon. On your  distribution, the daemons may be named rpc.mountd and rpc.nfsd. Be sure to check the  documentation for your Linux distribution.   Remember, the portmapper must be invoked and running before the mountd and nfsd daemon.   Exporting Filesystems   There is no broadcast of available filesystems by the server to NFS clients. The NFS server maintains a  list of exported filesystems and the restrictions that are applicable for each export, called the  filesystem table. When a mount request is received from an NFS client, the NFS server checks the  request against its filesystem table. If the filesystem is in the list and the restrictions are satisfied, the  server permits the mount.   The filesystem table and the contents of the /etc/exports file can be different. The NFS server creates  the filesystem table from the contents of the /etc/exports file at the time that it initializes. The  filesystem table is not updated by the NFS server unless the system is rebooted or the exportfs  command is executed.   page 220   #BREAK# Inside Linux   The exportfs command is used to maintain the table of exported filesystems. On some Linux  distributions, the table exists as the /var/lib/nfs/xtab file. Unfortunately, not all Linux distributions  have the exportfs command installed. If you do not have one, you can create a script to perform the  logic. The following demonstrates the minimum for the script:   #!/bin/bash  killall -HUP /usr/sbin/rpc.mountd  killall -HUP /usr/sbin/rpc.nfsd   Be sure that the command name for each daemon is correct for your Linux distribution and that the  directory path is appropriate. The HUP signal is sent to the daemons, effectively telling them to  reinitialize. The net effect is that the /etc/exports file is read from disk by the NFS server and the  filesystem table is regenerated.   For some Linux distributions, the rcnfsserver command can be executed to update the filesystem  table if changes have been applied to the /etc/exports file. A man page may not exist for this  command, so do not count on using that method for verification of rcnfsserver. For example, for the  installed version of SuSE Linux 6.3 (on my machine), no man entry exists for rcnfsserver, but  executing the which command reveals the file&#8217;s existence, as shown in the following dialog:   stimpy $ man rcnfsserver  No manual entry for rcnfsserver  stimpy $ which rcnfsserver  /usr/sbin/rcnfsserver  stimpy $ rcnfsserver  Usage: /usr/sbin/rcnfsserver {start|stop|status|reload|restart}  stimpy $   Another method of updating the filesystem table is to stop and start the daemons using the nfs  command. The following dialog demonstrates this:   stimpy $ cd /etc/rc.d/init.d  stimpy $ nfs stop  stimpy $ nfs start  stimpy $   If the restart option is available for the nfs command, you can invoke the command that way, as in  the following dialog. The previous section, &#8220;The mountd and nfsd Daemons,&#8221; discusses the nfs  command in more detail.   stimpy $ cd /etc/rc.d/init.d  stimpy $ nfs restart  stimpy $   Before you create any script to force a reread of the /etc/exports file, check to see if either the  exportfs or rcnfsserver command exists.   Using the NFS Client   There is not much to using an NFS client. The only requirements are that an NFS server is running,  that at least one filesystem exists to mount, and the proper restrictions are satisfied.   You use the mount command to import a filesystem. This is what the term &#8220;NFS client&#8221; refers to. The  mount command is used to execute a request to the NFS Server for importing a remote filesystem. The  basic usage for the mount command is shown in the following:   mount -t type device dir   This tells the system to attach (or mount) the filesystem found on device (device), which is of type  type, at the dir directory. Conversely, you use the umount command to unmount (or detach) the  filesystem. The following dialog demonstrates the use of the mount command to import an NFS  filesystem:   stimpy $ mount -t nfs sillyhost:home/bill /home/bill   Some distributions of Linux prefer that you execute the mount command with the -F option, as shown  in the following dialog:   stimpy $ mount -F nfs sillyhost:home/bill /home/bill   Be sure to check the mount man page for the proper syntax for your Linux distribution.   page 221   #BREAK# Inside Linux   To enforce that the system mounts an nfs filesystem at boot, you should edit the /etc/fstab file as  usual. You should ensure that the -t nfs type is specified. In the following dialog, the contents of the  /etc/fstab file shows an entry to mount an nfs type filesystem.   stimpy $ cat /etc/fstab  /dev/hda7 swap swap defaults 0 0  /dev/hda6 / ext2 defaults 1 1  /dev/hdc /cdrom iso9660 ro,noauto,user,exec 0 0  /dev/hda5 /mnt/rh ext2 defaults 1 1  /dev/fd0 /flop auto noauto,user 0 0  sillyhost:home/bill /home/bill nfs rsize=8192,wsize=8192,timeo=14,intr 0 0  none /proc proc defaults 0 0   Using our previous example, the sillyhost&#8230; entry will be automatically mounted at system boot.  This sample should work for most all Linux distributions. You should always check the documentation  for your distribution to be certain.   You can also easily mount a filesystem by specifying the mount point, if the device is listed in the  /etc/fstab file. For example, referring to the previous /etc/fstab sample, if you want to mount the  /dev/hda5 device, you simply issue the mount command as shown in the following dialog:   stimpy $ mount /mnt/rh  stimpy $   Because the entry exists in the /etc/fstab file, all the proper parameters are available to mount the  device to the identified mount point.   From here, all you do is access the filesystem as you normally would with any mounted filesystem.   The mount Command   The following section details the mount command. The mount command, these days, consists of many  options. I hope to clarify the usage for mount.   The official usage for the mount command is shown as follows:   mount [-hV]  mount -a [-fFnrsvw] [-t vfstype]  mount [-fnrsvw] [-o options [,&#8230;]] device | dir  mount [-fnrsvw] [-t vfstype] [-o options] device dir   As you can see, four variant usages exist for the mount command, each one for a specific application.   All UNIX and Linux files are organized within a filesystem that is a hierarchical tree starting at /,  known as root. This is not to be confused with the root user. Normally, the filesystem consists of more  than one device; the mount command is used to import (or attach) these devices to the root filesystem.  To unmount a filesystem, you use the umount command.   The most common form of usage for mount is as follows:   mount -t type device dir   This execution mounts the device device of type -t type onto the dir directory. The local directory  (mount point) becomes the root of the mounted device.   Ironically, four usages for the mount command do not perform a device mount. They are as follows:   mount -h  mount -V  mount [-t type]  mount   The first form prints only help text associated with the mount command. The second form displays the  version of mount and exits. The third form of mount lists all the filesystems of the type identified that  are mounted. The last form lists all the filesystems that are mounted.   The form of the identified device is a block special device by filename. Some examples are /dev/hdc for  a CD-ROM and /dev/fd0 for a floppy disk. Another example is /dev/hdb11 representing the tenth  logical drive on the second IDE hard drive or /dev/hda5 representing the fourth logical drive on the  first hard disk (these do exist on my system). You are not restricted to identifying a device as  previously shown. You can also identify devices as some.domain.name:/directoryName.   page 222   #BREAK# Inside Linux   You can add devices that are continually mounted at boot to the /etc/fstab file. The /etc/fstab file  can be helpful in several ways. If an entry for a device exists in the file, you can mount it manually by  specifying only the device or the mount point. The following example demonstrates this. The first  dialog shows an entry in the /etc/fstab file:   stimpy $ cat /etc/fstab  &#8230;    /dev/hda5 /mnt/rh ext2 defaults 1 1  &#8230;   Assuming that the /dev/hda5 entry exists as shown, you can mount the device onto the /mnt/rh  directory by issuing one of the two following mount commands:   stimpy $ mount /dev/hda5   stimpy $ mount /mnt/rh   You do not need to specify the device type, device, and mount points because this information is  already specified in the /etc/fstab file. Customarily, the superuser (root) is the only user that can  execute the mount command. With the /etc/fstab file, however, you can use the user option, allowing  anyone to mount the corresponding device. You should know that only the user that mounted the  device is allowed to unmount the device. If you want any user to be able to unmount a device, you  should use the users option rather than the user option.   Options for mount   A whole host of options are available for the mount command. In this section, I explore the options  available, providing descriptions for each. Table 12.4 outlines the various options available to you.   Table 12.4. Options for the mount Command  Option Description  -V Show the version.  -h Show a help message.  -v Verbose mode.  -F  This option will fork an individual invocation of mount for each device. The  advantage is speed.  If you are mounting NFS devices, the timeouts will be concurrent. The downside is  that the order of mounts is arbitrary.  -f This option is a sort of &#8220;test&#8221; (or fake) mode. If you are having problems with  mount, this option acts as a debugger (use with the -v option).  -n Perform the mount and exclude writing the entry in /etc/mtab.  -s Mainly used for the Linux autofs-based automounter. This tells mount to allow for  awkward mount options versus failing.  -r Mount the filesystem as read-only; synonymous with the -o ro option.  -w Mount the filesystem as read/write; synonymous with -o rw. This is the default.  -L label Mount the partition possessing the specified label.  -U uuid Mount the partition possessing the specified uuid.  -t vfstype  This option identifies the filesystem type.  The currently supported filesystem types are (shown in linux/fs/filesystems.c)  adfs, affs, autofs, coda, coherent, devpts, ext, ext2, hfs, hpfs, iso9660, minix, msdos,  ncpfs, nfs, ntfs, proc, qnx4, romfs, smbfs, sysv, ufs, umsdos, vfat, xenix, xiafs. The  coherent sysv, and xenix types are equivalent.  Both the coherent and xenix types will be removed sometime in the future.   page 223   #BREAK# Inside Linux   Option Description  -o  Options are specified with a -o flag, using a comma to separate the options. The  options are:    atime Update  the inode access time for every access; the default.    auto Specify  that the mount is acceptable with the -a option.    defaults Use  the default options, which are rw, suid, dev, exec, auto, nouser,  and async.    dev Interpret  character or block special devices.    exec Allow  execution of binaries.    noatime Do  not allow updates to the inode access times on the filesystem.    noauto The  filesystem can only be explicitly mounted.    nodev Do  not interpret character or block special devices.    noexec Disallow  the execution of binaries on the mounted filesystem.    nosuid Disallow  set-user-id or set-group-id bits to occur.    nouser Prohibit  a non-root user to mount the filesystem; this is the default.    remount Used  to attempt a remount of an already mounted filesystem. Used to  change the mount flags for a filesystem.    ro Mount  the filesystem as read-only.    rw Mount  the filesystem as read/write.    sync Synchronize  I/O to the filesystem.    user Permit  an ordinary user to mount the filesystem; implies the options  noexec, nosuid, and nodev.   The man page for the mount command provides more level of detail for filesystem-specific mounts. Be  sure to refer to it for any special needs you may have.   page 224   #BREAK# Inside Linux   Optimizing NFS on Low-Bandwidth Connections   So many variables are at work when you analyze network activity that a whole chapter can be written  about it. This section touches on only three options for adjusting the performance of NFS on low- bandwidth connections. The section is short and sweet to keep things simple.   Admittedly, the NFS protocol is a sluggish protocol. Therefore, if you throw NFS over a sluggish line  such as a modem or ISDN line, expect poor performance. Some of the TCP/IP protocols, such as FTP,  are quicker than NFS. The advantage to using NFS is that you do not have to copy files back and forth  as you do with FTP. You access the mounted filesystems as if they were native to the machine.   You will have to adjust the NFS parameters to allow its use over sluggish lines. If you do not adjust the  settings, NFS will report errors. First, you should refrain from using the soft mount option, because  timeouts will begin to surface. Using the hard mount option will force retries. Two other options need  to be altered: retrans and timeo.   The format for retrans is retrans=n, in which n is a number. This number represents the number of  times to repeat a request before the request is aborted.   The format for timeo is timeo=n, in which n is a number. This number represents the RPC timeout  period in tenths of a second. The default value is vendor specific, normally ranging from 5 to 10 tenths  of a second. Under Linux, the default value is 7 tenths of a second. If a reply does not occur within the  time identified by timeo, a minor timeout has occurred. At this time, the timeo value is doubled and  the request is re-sent. This process continues until the retrans count is reached. If the client does not  receive a reply, a major timeout has occurred.   What, then, is the general rule? You should concentrate on varying the timeo value versus the retrans  option. Increasing the retrans value will generate more requests to the NFS server, which creates a  load on the server. Generally, doubling the timeo value will solve timeout issues.   Summary   In this chapter, you explored the use of the Network File System (NFS), beginning with an overview of  NFS, developed by Sun Microsystems, which advertises an installed base of about eight million  systems. NFS is a protocol used for file sharing.   NFS consists of a client program and the server program. The NFS server responsibility is to export a  file or directory. The NFS client then mounts the required filesystem.   Next, I discussed the NFS client, including the automounter. The automounter, which is a client-side  enhancement, provides the functionality to automatically mount a filesystem. When the operation is  complete, the automounter unmounts the device.   The NFS server was discussed next. The role of the NFS server is to make filesystems available by  exporting them. I then covered setting up the NFS server, including the portmapper, mountd, and nfsd  daemons. The /etc/exports file was covered, which contains the filesystems that the NFS server can  export to clients.   The NFS client was covered, consisting of the mount command. The success of the mount command is  dependent on a running NFS server and a filesystem that can be mounted. Finally, the mount  command was discussed in a fair amount of detail.   page 225   #BREAK# Inside Linux   Chapter 13. Dial-Up Networking Services: SLIP  and PPP   Linux provides two protocols for serial-line connectivity. Specifically, connectivity is through a  modem, whether it is an asynchronous, an ISDN, or a synchronous modem. The two protocols are  Serial Line Internet Protocol (SLIP) and Point-to-Point (PPP). Both protocols provide the  functionality to establish connectivity with a remote system. The connection is made to an Internet  service provider (ISP) or through a gateway.   The first part of this chapter focuses on the SLIP protocol. The last part of the chapter examines PPP  in detail.   Serial Line Internet Protocol (SLIP)   In this first section, we examine SLIP in detail. Although PPP is the more widely used dial-up protocol,  SLIP continues to be a contender and is supported by most public and private ISPs.   We begin the SLIP journey with a brief overview and then jump into the configuration and use of  SLIP.   SLIP Overview   The only hardware requirements for SLIP are a serial port with a FIFO buffer and a modem. If you are  using an older computer - an 80286 (or compatible), for example, you may want to check your serial  port UART chip set. At a minimum, you want to have a 16550 UART.   SLIP supports the TCP/IP protocols over a serial line, whether it&#8217;s over a dial-up phone line or a  dedicated leased line. You should contact your ISP to obtain the configuration requirements for SLIP  connectivity with their system. Configuring SLIP is a fairly straightforward task, and you should be up  and running with a minimal amount of fuss.   Logically, the network for a SLIP connection consists of only two machines: the SLIP server (provided  by your ISP) and the SLIP host, which is your end. We refer to SLIP as a point-to-point network  connection because only two endpoints are within the network. Think of SLIP (and PPP) in the same  light as the phone system. You pick up your receiver and dial the destination phone number. When  your party answers at the other end of the line, a network connection is established. This is also  considered a point-to-point connection. If either end disconnects, the network connection is broken.   When a connection is established from the host to the server, a logon sequence is initiated to verify  your identity. After the verification process is complete, the server furnishes an IP address for your  host. This IP address can either be dynamic or static. If the address given to your host is a static  address, that address is the same every time you establish a SLIP connection. If your SLIP server  provides for dynamic IP addresses, every time you establish a SLIP connection your host will receive a  different IP address. The SLIP server will output the IP addresses (among other data) that are  assigned for the current session. The Dial-Up IP Protocol (dip) program can capture the dynamic IP  address and configure the SLIP driver automatically. The dip program is used to simplify connectivity  to the SLIP server. We discuss the use of dip in a section that follows.   Some information that you must have available, if you&#8217;re using a dial-up connection, includes the ISP&#8217;s  phone number, the authentication type, whether your ISP provides static or dynamic IP addresses, the  ISP domain name, the DNS address list, whether the ISP uses a default gateway or a static gateway,  and the maximum connection speed provided by the ISP. If your ISP is using static IP addressing, you  will need the IP address assigned to your host. Also, if your ISP is using a static gateway, be sure to  obtain the address for it.   Beginning with the next section, we discuss the specifics of SLIP configuration under Linux.   page 226   #BREAK# Inside Linux   SLIP Preflight Checklist   Setting up your Linux system to enable SLIP is fairly easy. SLIP configuration is a one-time setup; you  should not have to change any of your settings unless you switch to another service provider or your  service provider&#8217;s configuration changes.   In the following sections, we discuss the prerequisites that must be addressed before jumping into the  actual use and setup of SLIP. We also examine the various configuration files and requirements of  TCP/IP networking to enable SLIP.   Verifying the Loopback Interface   The loopback interface, sometimes called the dummy interface, is used to provide an IP address for  your machine, provided that the only network interface you are using is SLIP or PPP. Also, some  applications require the loopback interface in order to run. In addition, other TCP/IP services require  an IP address to be functional. If your machine is part of a real ethernet network, the loopback  interface is not required.   The loopback interface is specified by the network name lo - that is, LO is lowercase. To activate the  loopback interface, the ifconfig command is used. The IP address that is designated for loopback is  127.0.0.1; this is an address designated by the InterNIC as reserved for no entity. The syntax for the  ifconfig command is   ifconfig interface [aftype] options | address &#8230;   To enable the lo interface with the address 127.0.0.1, you invoke the ifconfig command, as shown in  the following dialog:   stimpy $ ifconfig lo 127.0.0.1   This will execute ifconfig and its result will be to assign the IP address 127.0.0.1 to the loopback  address. You can obtain the status of any active interfaces by invoking ifconfig without any  arguments. Check the man page for ifconfig for a complete rundown of options. The following shows  the output of an ifconfig inquiry:   stimpy $ ifconfig   lo Link encap:Local Loopback   inet addr:127.0.0.1 Mask:255.0.0.0   UP LOOPBACK RUNNING MTU:3924 Metric:1   RX packets:25 errors:0 dropped:0 overruns:0 frame:0   TX packets:25 errors:0 dropped:0 overruns:0 carrier:0   collisions:0 txqueuelen:0   ppp0 Link encap:Point-to-Point Protocol   inet addr:32.100.174.75 P-t-P:32.96.116.18 Mask:255.255.255.255   UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1   RX packets:15 errors:0 dropped:0 overruns:0 frame:0   TX packets:17 errors:0 dropped:0 overruns:0 carrier:0   collisions:0 txqueuelen:10   stimpy $   The ifconfig command responds that two interfaces are active: lo and ppp0. Next, you should verify  the contents of your /etc/hosts file for the loopback entry. The following is the contents of an  /etc/hosts file:   # hosts This file describes a number of hostname-to-address  # mappings for the TCP/IP subsystem. It is mostly  # used at boot time, when no name servers are running.  # On small systems, this file can be used instead of a  # &#8220;named&#8221; name server.  # IP-Address Full-Qualified-Hostname Short-Hostname    127.0.0.1 localhost  The name is not necessarily important as long as you map the corresponding interface name to the  logical hostname.   Verifying /etc/resolv.conf File   The /etc/resolv.conf file is used for name resolution. Entries found in this file designate a DNS  server and its associated IP address. More than one DNS server can be specified in this file. As  mentioned previously, your ISP can provide you with the DNS server(s) and their associated IP  address. The following is sample output from a /etc/resolv.conf file:   # /etc/resolv.conf  nameserver 165.87.194.244  nameserver 165.87.201.244   page 227   #BREAK# Inside Linux   The /etc/resolv.conf file identifies the DNS servers that the resolver can contact to resolve  hostnames.   You can also set up your Linux to use DNS locally. Many Linux power users do this because it can cut  down on name-resolution traffic from your host to the server (and vice versa). Doing this will provoke  your DNS to cache DNS lookups, thereby decreasing accesses to the remote DNS for name resolution.   Setting Up SLIP   As mentioned previously, SLIP is used to establish a network connection between two machines: the  server (remote machine) and the host (your machine). SLIP is so firmly entrenched that most ISPs  support the protocol.   A number of variations of SLIP exist, most notably CSLIP. CSLIP is a compressed version of SLIP that  utilizes the Van Jacobson header-compression algorithm on outbound IP packets. The result is  increased throughput, especially for interactive network sessions. Before implementing CSLIP, check  with your ISP because most ISPs do not support CSLIP.   Although SLIP is easy to configure and use, the core mechanism can seem complicated. For most  distributions of Linux, the SLIP driver is an integral part of the kernel. This provides faster response  and is more efficient. A special tty line discipline, SLIPDISC, is used to convert the specified serial line  to SLIP mode. Under this discipline, the serial line cannot be used for any other purpose, other than to  communicate with SLIP-aware applications. Effectively, any non-SLIP applications are blocked from  using the device when SLIP is active.   To establish a SLIP network connection, a pair of programs are utilized, specifically slattach and dip.  You cannot use a generic communications application to dial up a remote SLIP server and establish a  network connection. Both slattach and dip are used collectively to initiate and establish a SLIP  network connection on a serial device using special system calls. The slattach command is used to  convert a specified serial line to SLIP mode. Subsequently, the dip command is used to establish the  network connection, login negotiation, and to initiate the SLIP connection on the serial line.   Using slattach   The following shows the syntax for the slattach command:   slattach [option] [-c command] [-p protocol] [-s speed] [tty]   Several options are available, such as enabling debug output and operating in quiet mode. Check the  slattach man page for more details.   The -c command switch is used to execute the specified command after the line is hung up  (disconnected). This can be utilized to run one or more scripts or to automatically maintain  (reestablish) a network connection if the line was severed.   The -p protocol switch identifies the protocol to use for the serial line. For many versions of slattach,  the default value is cslip (compressed SLIP). Other values that can be specified are adaptive (adaptive  CSLIP/SLIP), kiss (a special protocol used to communicate with AX.25 packet radio terminal node  controllers), ppp (Point-to-Point Protocol), slip (standard SLIP), and tty. The tty argument is used to  return the serial device back into normal serial operation. Do not use the ppp argument to establish a  PPP network connection, because PPP requires the pppd daemon to be active on the specified serial  line. The adaptive option leaves it to the kernel to decide the type of SLIP protocol that the remote end  uses.   The -s speed switch simply designates a line speed to be used for the serial device.   The following dialog switches /dev/cua3 to assume SLIPDISC line discipline and then attaches the  device to the next active SLIP network interface:   stimpy $ slattach /dev/cua3 &#038;  stimpy $   This assumes that the modem is on /dev/cua3. If no active SLIP connections exist, the line is attached  to sl0 (that&#8217;s SL0, not S10). The second SLIP connection will be attached to sl1, and so on. Most  Linux kernels support up to eight simultaneous SLIP links.   page 228   #BREAK# Inside Linux   As mentioned previously, the default protocol for slattach assumes CSLIP. The following dialog  demonstrates invoking slattach to use normal SLIP:   stimpy $ slattach -p slip /dev/cua3 &#038;   If you&#8217;re not sure which protocol option to use (SLIP or CSLIP), it is recommended to use adaptive  because this leaves the decision to the kernel.   You may have noticed in the dialogs that the ampersand (&#038;) is used to put slattach into the  background. Obviously, if you are invoking slattach from a terminal, you will want that terminal  back. Otherwise, slattach will rob the terminal until such time that slattach is terminated. You can  terminate slattach using the kill command - simply use the ps command to locate the process ID for   slattach.   The slattach command is not specific to SLIP. You can use slattach to enable other TCP/IP protocols  such as KISS and PPP.   Using ifconfig and route   After we have a SLIP connection and we have associated our serial device for SLIP usage, we must  configure the network interface. This is done the same as with any other (normal) network  connection. The two commands we use for this purpose are ifconfig and route.   The ifconfig command is used to configure the network interfaces. It is used at boot time to set up the  required interfaces. The ifconfig command can be used from the command line, which is usually  done only during debugging or testing, or during system tuning. If you execute ifconfig with no  arguments, ifconfig shows the status of any active interfaces. If a single interface argument is given, it  displays the status of the given interface only; if a single -a argument is given, it displays the status of  all interfaces, even those that are down. If you recall from the earlier section &#8220;Verifying the Loopback  Interface,&#8221; we used ifconfig to configure the loopback interface. We repeat the syntax here to jog your  memory:   ifconfig interface [aftype] options | address &#8230;   The route command is used to manipulate the IP routing table. The core functionality of route is to set  up the static routes to specific hosts or networks via an interface. This interface should have already  been configured with the ifconfig command. To add a route to the table, use the following syntax for   route:   route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw] [metric N]   [mss M] [window W] [irtt I]   [reject] [mod] [dyn] [reinstate] [[dev] If]   To delete a route from the table, use the following syntax for route:   route [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric N] [[dev]  If]   After control of the line is in possession of the SLIP driver, the network interface will have to be  configured. You configure the network interface using the ifconfig and route commands. Let&#8217;s  assume that the host is stimpy and we dialed a server with the name ren. The following dialog shows  the commands to execute:   stimpy $ ifconfig sl0 stimpy pointopoint ren  stimpy $ route add ren   As you can see, the first command configures the (first serial) interface as a point-to-point link to ren.  The second command, route invocation, adds the machine ren to the routing tables. Some  implementations of Linux may require that you identify the device (with the dev option) to the route  command.   To take down the interface, use the same commands but in reverse order. For example, you first  execute route to remove the entries from the routing tables. Second, you execute ifconfig to take  down the serial interface. Finally, you need to terminate the slattach process. You can run the ps  command to locate the process ID for the running slattach process and then issue the kill command  to terminate it. For example, the following dialog demonstrates the commands to execute and the  order in which to execute them:   stimpy $ route del ren   stimpy $ ifconfig sl0 down   stimpy $ ps a | grep slattach   4918 p1 S 0:00 slattach /dev/cua1   stimpy $ kill 4918   In the next section, we take a look at the dip command, which is the Dial-Up IP Protocol driver.   page 229   #BREAK# Inside Linux   Using dip for SLIP Automation   Looking back on the last sections, you are probably thinking, &#8220;Getting connected is fairly easy, but I&#8217;d  like to automate that whole process.&#8221; Well, that is what computers are all about, right? And Linux  offers just the program for you; the program is called the Dial-Up IP Protocol (dip).   In this section, we explore the use of dip and how it can help with automating the SLIP process. The  dip command supports the processing of a chat script, allowing you to specify a command-response  dialog to help with dialing, connecting, and the login process. You can also include commands to  automate the setup of the SLIP network interface and establish entries to the kernel routing tables.   The following shows the syntax for dip, in its most general form:   dip [options &#8230;] [script file]   A lot of supporting information is given in this section for the dip command. A sample dip script is  supplied at the end of the section, preceded by a variables list and a command list. But first, Table 13.1  lists the most common command-line arguments to dip.   Table 13.1. Common dip Command Arguments  Switch Description  -a Prompt for username and password.  -i Act as a dial-in server.  -k Kill the dip process that has locked the specified tty device or the most recent invocation  of dip.  -l line Indicate the line to be killed.  -m mtu Set the Maximum Transfer Unit (MTU); the default is 296.  -p proto Set the line protocol to be one of these: SLIP, CSLIP, SLIP6, CLSIP6, PPP, or TERM.  -t Run dip in test (interactive or command) mode.  -v Set verbose mode. This enables debug output to include echoing of each line of the script.   As you can see, dip can also be used as a dial-in server, as represented by the -i switch. The dip  command can also be invoked in interactive mode (or command mode), as designated by the -t  switch. This allows you to participate in the dial-up and login process, allowing you to record the  prompts and responses required to establish a modem connection. You can then use the results and  establish a script file to automate the process.   Table 13.2 lists the commands supported by dip. Simply type the command, plus any required  arguments, and press Enter. These commands can be included in a chat script or executed while you  are in command mode:   Table 13.2. Common dip Commands  Command Description  label: Defines a label.  beep [times] Beeps on user&#8217;s terminal [times] times.  bootp [howmany [howlong]] Uses the BOOTP protocol to fetch both local and remote  IP addresses.  Break Sends a BREAK.  chatkey keyword [code] Allows you to add to dip&#8217;s modem response words.  config  [interface|routing][pre|up|down|post] Stores interface configuration {arguments&#8230;} parameters.  databits 7|8 Sets the number of data bits.   page 230   #BREAK# Inside Linux   Command Description  dec $variable [decrementvalue|$ variable] Decrements a variable; the default is 1.  Default Instructs dip to set the default route to the remote host it  connected to.  dial phonenumber [timeout]  Transmits the string in the init variable as the modem  initialization string and then dials the specified number.  The default timeout is 60 seconds. Dip will parse any  strings returned by the modem and will set $errlvl  accordingly. The standard codes are as follows: 0 - OK, 1 CONNECT,  2 - ERROR, 3 - BUSY, 4 - NO CARRIER, 5 NO  DIALTONE. You can change or add to these with the  chatkey command.  echo on|off Enables or disables the display of modem commands.  exit [exit-status] Exits script leaving established [C]SLIP connection intact  and dip running.  flush Flushes input on the terminal.  get $variable [value|ask|remote  [timeout_value| $variable]]  Gets the value for a specified variable. If the second  parameter is ask, a prompt is printed and the appropriate  value is read from standard input. If the second parameter  is remote, the value is read from the remote machine.  Otherwise, the second parameter is a constant or another  variable that will supply the value.  goto label Transfers control to the specified label within the chat  script.  Help Prints a list of commands.  if expr goto label  Tests a result code. The expr must have the form  $variable op constant where op is one of the following:  ==, !=, <, >, <=, or >=.  inc $variable [incrementvalue|$ variable]  Increments the specified variable. The default increment  value is 1.  init init-string  Sets the initialization string to the indicated string (default  is AT E0 Q0 V1 X4). Note that the initialization string is  sent before the dialing command is issued.  mode  [SLIP|CSLIP|SLIP6|CSLIP6|PPP|TERM] Sets the line protocol.  modem modem-name Sets the type of modem.  netmask xxx.xxx.xxx.xxx Indicates the netmask address to use.  onexit  Executes the specified command upon dip&#8217;s exit. Works  like the shell command, but is executed (only) when dip  finishes. The onexit command that is executed is the last  one encountered; any previous onexit commands are  replaced by the new ones.  parity E|O|N Sets the type of parity.  password Prompts for a password and transmit it.  proxyarp Requests Proxy ARP to set.  print $variable Prints the contents of some variable.  psend command [arguments]  Sends the output of specified command to the serial  driver, optionally passing arguments to command. The UID  is reset to the real UID before running command.   page 231   #BREAK# Inside Linux   Command Description  port tty_name Sets the name of the terminal port to use. (The path /dev/  is assumed.)  quit Exits with nonzero exit status.  reset Resets the modem. Does not work properly on several  modems.  securidfixed fixedpart Stores the fixed part of the SecureID password.  securid  Prompts for the variable part of the password generated  by the ACE System SecureID card. The fixed part of the  password must already have been stored using a secureidf  command. The two parts are concatenated and sent to the  remote terminal server.  send text-string Sends a string to the serial driver.  shell command [parameters]  Executes command through the default shell (obtained  from the shell variable) with parameters as the  command-line arguments. dip variable substitution is  performed before executing the command. If you don&#8217;t  want a parameter beginning with a $ to be interpreted as a  dip variable, precede it with a .  skey [timeout | $variable]  Tells dip to look for an S/Key challenge from the remote  terminal server. dip then prompts the user for the secret  password, generates the response, and sends it to the  remote host. The optional parameter timeout sets how  long dip is to wait to see the challenge. $errlvl is set to 1 if  the skey command times out. If skey successfully sends a  response, $errlvl is set to 0. Requires S/Key support to be  compiled in.  sleep time-in-secs Waits some time.  speed bits-per-sec  Sets port speed (default is 38400). Note that the actual  speed associated with 38400 can be changed using  setserial(8). Also, you should tell port&#8217;s real speed here  because dip takes care of the set_hi and such bits by itself.  Also, don&#8217;t be afraid, if you told the speed 57600 and it  reports back 38400. Everything&#8217;s okay, the proper flags  were applied, and the real port speed will be what you told  it to be - that is, 57600.  stopbits 1|2 Sets the number of stop bits.  term Enters a terminal mode.  timeout time-in-sec  Sets timeout. This defines the period of inactivity on the  line, after which dip will force the line down and break the  connection (and exit).  wait text [timeout_value | $variable] Waits for some string to arrive.   page 232   #BREAK# Inside Linux   The following table lists the special variables that can be used within a script file. Some of these  variables can be set with a value and some are read-only; all variables can be read for their contents.  Note that the variable names are lowercase and must begin with a dollar sign. Table 13.3 briefly  describes each variable&#8217;s purpose.   Table 13.3. Variables for a dip Chat File  Variable Description  $errlvl Holds the result of the previous command  $locip IP Number of local host in dotted quad notation  $local Fully qualified local hostname  $rmtip IP Number of remote host in dotted quad notation  $remote Fully qualified remote hostname  $mtu Maximum Transfer Unit (maximum number of bytes that are transferred at once)  $modem Modem type (at present, the only valid value is HAYES)  $port Name of the terminal port to use  $speed Transfer rate between the local host and the modem, in bits/sec   Something to note: dip will resolve any hostname to its IP address if you supply the hostname in the  local and remote special variables.   Sample dip Script   The following is a sample dip script:   # bugs.dip  #  top:  # define the name for connection.&#8221;ren.stimpy.net&#8221;  get $local ren.stimpy.net  # set up the remote end &#8220;bugs.bunny.net&#8221;  get $remote bugs.bunny.net  # set up the netmask 255.255.255.0  netmask 255.255.255.0  # define the serial port and speed.  port cua02  speed 38400  # clean up the modem (reset it)  reset  flush  # if your modem doesn&#8217;t respond properly to  # the previous &#8220;reset&#8221;, then comment out  # the reset or delete it altogether. then  # uncomment the following two lines.  # send ATZr  # wait OK 3  # set the initialization string for modem, then dial  get $init ATQ0V1E1X4  dial 123-4567  if $errlvl != 0 goto modem_ERR  wait CONNECT 60  if $errlvl != 0 goto modem_ERR    # if we got to here, we&#8217;re connected &#8230;   # &#8230; log in to the remote system   login:   sleep 2   send rnrn   wait ogin: 10   if $errlvl != 0 goto login_ERR   send THE_USERNAMEn   sleep 2   wait word: 10   if $errlvl != 0 goto pswrd_ERR   send THE_PASSWORDn   page 233   #BREAK# Inside Linux    log-success:   # we&#8217;re logged in, now wait for prompt  wait SOMETEXT 15  if $errlvl != 0 goto prompt_ERR    # if we&#8217;ve gotten here, then we&#8217;ve completed  # all tasks required for SLIP connectivity  fini:    # set up SLIP  get $mtu 296  # Ensure execution of route  default  print CONNECTED $locip == $rmtip  mode CSLIP  goto exit    #   prompt_ERR:  print Time out waiting for login prompt  goto error    #   login_ERR:  print Time out waiting for logon  goto error    #   pswrd_ERR:  print Time out waiting for password prompt  goto error    #   modem_ERR:  print Problem with the modem  goto general_ERR    #   general_ERR:  print Could not connect with the remote system  quit 1    exit:  exit   This sample script can be used to connect to bugs.bunny.net by invoking dip with the script name as  its argument:   # dip bugs.dip   After successfully connecting to bugs and CSLIP has been engaged, dip will detach itself from the  terminal and become a daemon process (or background process). Recall that if you invoke dip with the  -k switch, dip will kill the dip process that has locked the specified tty device or the most recent  invocation of dip. The following dialog demonstrates this:   # dip -k   Let&#8217;s take a look at the script file. The first statement in the script is a get command, which actually  sets a variable to the specified value. In this script, the first statement, $local, is set to  ren.stimpy.net. The second statement sets the variable $remote to bugs.bunny.net. Those lines  follow:   get $local ren.stimpy.net  # set up the remote end &#8220;bugs.bunny.net&#8221;  get $remote bugs.bunny.net   The next line is the netmask statement; this statement and the next four statements (through reset)  configure the terminal and reset the modem. You may experience a problem with the reset command;  this command does not work with all modems. If you do have problems, either comment out the reset  statement or remove the line altogether. Next, uncomment the two lines that read as follows:   # send ATZr  # wait OK 3   The statement following the reset statement, flush, purges any modem strings that may exist in the  (receive) buffer. This ensures that no extraneous strings are in the buffer when the login sequence  executes.   The wait statement instructs dip to wait for the string specified as the first argument to wait. The  second argument specifies a timeout as a number of seconds; if the string is not detected within the  timeout range, the $errlvl variable is set to 1. The $errlvl variable is checked for success; if it is  nonzero, the previous statement failed and we branch out to the appropriate error section. The  following excerpt demonstrates the sequence:   wait ogin: 8  if $errlvl != 0 goto login_ERR   page 234  #BREAK# Inside Linux   The concluding commands that are executed after the login is successful are default, which makes the  SLIP link the default route to all hosts, and mode, which enables SLIP mode on the line and configures  the interface and routing table for you. The next command, goto exit, routes the execution of the  script around the error statements that follow.   The following section of the script deals with exceptional conditions. Each label is used to deal with a  specific error (exceptional) condition. A message is printed and then a goto statement is used to  branch to the generic error message routine. Notice that the modem_ERR: section does not require a goto  statement; it could just fall through to the general_ERR statement. The reason we use a goto statement  is that we may need to add another error statement. If you insert the new statement after modem_ERR,  you might forget to include the goto statement.   prompt_ERR:   print Time out waiting for login prompt   goto general_ERR   #   login_ERR:   print Time out waiting for logon   goto general_ERR   #   pswrd_ERR:   print Time out waiting for password prompt   goto general_ERR   #   modem_ERR:   print Problem with the modem   goto general_ERR   #   general_ERR:   print Could not connect with the remote system   quit 1   The last statement in the script is exit, which is used as an unconditional egress of the script. The  SLIP connection remains valid and dip continues to run. If you recall, the command dip -k is used to  kill the running dip process.   Remember to provide the script filename as an argument to the dip command. If you do not provide  the filename extension, dip assumes an extension of .dip.   Utilizing dip for Static IP Connectivity   This section addresses using dip to establish a SLIP connection when the IP addresses for the local  and remote are well-known (static). The following script is generic in nature and can be modified for  your use.   # static.dip   top:   get $local some.local.name   get $remote some.remote.name   netmask 255.255.255.0   # set up the modem   port cua02   speed 38400   reset   flush   # if your modem doesn&#8217;t respond properly to   # the previous &#8220;reset&#8221;, then comment out   # the reset or delete it altogether. then   # uncomment the following two lines.   # send ATZr   # wait OK 3   # set the initialization string for modem, then dial   get $init ATQ0V1E1X4   dial 123-4567   if $errlvl != 0 goto modem_ERR   wait CONNECT 60   if $errlvl != 0 goto modem_ERR   login:   sleep 2   send rnrn   wait ogin: 10   if $errlvl != 0 goto login_ERR   send USER_NAMEn   sleep 2   wait word: 10   if $errlvl != 0 goto pswd_ERR   send USER_PASSWORDn   page 235   #BREAK# Inside Linux    log-success:   # we&#8217;re logged in, now wait for prompt  wait CONFIRMATION_TEXT 15  if $errlvl != 0 goto prompt_ERR    # if we&#8217;ve gotten here, then we&#8217;ve completed  # all tasks required for SLIP connectivity  fini:    # set up SLIP  get $mtu 296  default  print CONNECTED $locip == $rmtip  mode CSLIP  goto exit    #   prompt_ERR:  print Time out waiting for login prompt  goto error    #   login_ERR:  print Time out waiting for logon  goto error    #   pswd_ERR:  print Time out waiting for password prompt  goto error    #   modem_ERR:  print Problem with the modem  goto general_ERR    #   general_ERR:  print Could not connect with the remote system  quit 1    exit:  exit   It is acceptable to use dotted-quad addresses for the get $local and the get $remote statements, but  as always, you should specify the machine names because dip will resolve the names to IP addresses  automatically.   After name resolution, dip will perform its magic of dialing, connecting, log in, and finally, switching  the line into SLIP mode and configuring the routing tables.   In the section that follows, we will take a look at dip usage for dynamic IP connectivity.   Utilizing dip for Dynamic IP Connectivity   This section demonstrates the use of dip to establish a SLIP connection when the IP address is not  known for the local and remote machines. The dip command will capture the IP addresses through the  serial line after connectivity is established. The following sample script file demonstrates the  functionality required:   # dynamic.dip  top:  # set up the modem  port cua02  speed 38400  reset  flush  # if your modem doesn&#8217;t respond properly to  # the previous &#8220;reset&#8221;, then comment out  # the reset or delete it altogether. then  # uncomment the following two lines.  # send ATZr  # wait OK 3  # set the initialization string for modem, then dial  get $init ATQ0V1E1X4  dial 123-4567  if $errlvl != 0 goto modem_ERR  wait CONNECT 60  if $errlvl != 0 goto modem_ERR  login:    sleep 2  send rnrn  wait ogin: 10  if $errlvl != 0 goto login_ERR  send USER_NAMEn  sleep 2  wait word: 10  if $errlvl != 0 goto pswd_ERR  send USER_PASSWORDn  get $remote remote 10   page 236  #BREAK# Inside Linux   if $errlvl != 0 goto remote_ERR  get $local local 10  if $errlvl != 0 goto local_ERR    log-success:   # we&#8217;re logged in, now wait for prompt  wait CONFIRMATION_TEXT 15  if $errlvl != 0 goto prompt_ERR    # if we&#8217;ve gotten here, then we&#8217;ve completed  # all tasks required for SLIP connectivity  fini:    # set up SLIP  get $mtu 296  default  print CONNECTED $locip == $rmtip  mode CSLIP  goto exit    #   prompt_ERR:  print Time out waiting for login prompt  goto error    #   login_ERR:  print Time out waiting for logon  goto error    #   pswd_ERR:  print Time out waiting for password prompt  goto error    #   modem_ERR:  print Problem with the modem  goto general_ERR    #   remote_ERR:  print Time out getting remote IP address  goto error    #   local_ERR:  print Time out getting local IP address  goto error    #   general_ERR:  print Could not connect with the remote system  quit 1    exit:  exit   In this script, the modem is set up and initialized. Next, the remote SLIP server is dialed and a  connection is established. After the username and password have been submitted and verified, the  remote and local IP addresses are captured by the dip command. The dip command does this by  examining the incoming data for anything that looks like an IP address. The dip command will time  out after 10 seconds if it cannot find an IP address. Finally, if everything passes inspection, dip  switches the line into SLIP mode and configures the routing tables.   Running diplogin as a SLIP Server   Using dip to act as a SLIP server is relatively easy. The basic course of attack is to set up the various  configuration files and then execute the diplogin command.   You need to create an account for each user that will need SLIP connectivity to your system. You will  also need to add an entry for every user to the /etc/diphosts configuration file.   Define Account Entry in /etc/passwd   First, you need to supply an entry in the /etc/passwd file for each user requiring SLIP service. Be sure  to define diplogin as the login shell for each user entry in the /etc/passwd file. The following is a  sample entry:   stimpy:x:1000:100:Stimpson J. Cat:/home/stimpy:/user/sbin/diplogin   In this sample, after stimpy has logged in, the login program sets the current directory to the home  directory specified in the /etc/passwd file, which is /home/stimpy. Next, the diplogin command is  executed, which is a symbolic link to the dip command (dip is run in input mode). Finally, the dip  command scans the /etc/diphosts file for the identified username.   page 237  #BREAK# Inside Linux   Define Username Entry in /etc/diphosts   Each user must be described in the /etc/diphosts file. The following is the template for an  /etc/diphosts entry:   user : password : remote host : local host : netmask : comments : protocol,MTU   The first field, user, is the user name. The entry here must match the logged in user.   The second field permits you to define an encrypted password for the user. If this field is not the null  (empty) string, dip will display a prompt and the user must supply a password. If the special entry  s/key is specified, then S/Key authentication will be enforced. Note that dip must be compiled with  the S/Key option enabled.   The third field of the entry specifies the name of the remote host. This entry may also be the actual IP  address. If the entry is a hostname, name resolution will take place using the name server or the  /etc/hosts file.   The fourth field identifies the name of the local host. Like the third field, this may be the actual IP  address. If the entry is a name, then name resolution will take place using the name server or the  /etc/hosts file.   The fifth field identifies the netmask and must be in dotted notation. If this field is empty, as in this  sample entry that follows, the address 255.255.255.0 is used.   The sixth field is merely used for commentary - it can contain any text. The dip command will not try  to interpret the entry.   The seventh field contains comma-separated flags. Possible flags are as follows:   SLIP - use the SLIP protocol.  CSLIP - use the Compressed SLIP protocol.  SLIP6 - use the SLIP6 protocol.  CSLIP6 - use the Compressed SLIP6 protocol.  PPP - use the PPP protocol.  number - defines the MTU parameter of this connection.   You must specify one of the first five entries, a comma, and finally specify the MTU required.   The following is a sample entry from an /etc/diphosts file for the user named stimpy.   stimpy::stimpynet:localHost::Stimpson J. Cat:SLIP,296   This specifies that stimpy is the username. A password prompt is displayed and awaits user input. The  remote host name is stimpynet and the localhost is named localHost. The netmask is not identified,  so the address 255.255.255.0 is used. The text Stimpson J. Cat only provides additional information  for the reader of the file. The protocol to use is SLIP, with an MTU value of 296.   Execute diplogin   After dip locates the correct line entry for the user, dip sets the terminal into raw mode and sets up the  serial line to the defined SLIP protocol. Finally, after the line is enabled, routing table entries are  defined to complete the connection.   The dip command then continues to run in the background until the connection is dropped. After the  line drops, the entries are removed from the routing table, and the line is returned to normal mode.   Starting with the next section, we begin our journey with Point-to-Point Protocol.   Point-to-Point Protocol (PPP)   As was mentioned in the opening of the previous section, Linux provides two protocols for serial-line  connectivity: Serial Line Internet Protocol (SLIP) and Point-to-Point Protocol (PPP). Both SLIP and  PPP provide facilities to establish connectivity with a remote system. PPP is a protocol that was  developed after SLIP and is now the preferred protocol over SLIP for serial-line connectivity.   page 238   #BREAK# Inside Linux   PPP Overview   PPP is a more powerful and robust protocol than SLIP. It provides features and capabilities that are  lacking with SLIP. You should always prefer PPP to SLIP when establishing a network connection over  a serial line.   The hardware requirements for PPP are the same as for SLIP; a serial port with a FIFO buffer and a  modem are all that is required.   PPP is used to support the TCP/IP protocols over a serial connection, whether it&#8217;s over a dial-up  phone line (or ISDN), a null modem cable, a telnet link, or a dedicated leased line.   At the lower levels, PPP is divided into two parts: the High-Level Data Link Control (HDLC) and the  Link Control Protocol (LCP) . HDLC defines the ground rules for the structure of the PPP frames. This  allows the frame to contain packets from protocols other than IP. A field within the frame identifies  the protocol type. In addition to handling IP datagrams, PPP can also use Van-Jacobson (VJ) header  compression. Effectively, this compresses the TCP packets, allowing increased performance.   At a higher level, PPP functionality is also split into two parts: the HDLC and the pppd daemon. The  pppd daemon delivers the LCP, support for user authentication, and the Network Control Protocols  (NCP) for establishing the IP Control Protocol (IPCP).   Beginning with the next section, we discuss the specifics of PPP configuration under Linux.   PPP Preflight Checklist   This section outlines the prerequisites that must be addressed before jumping into the actual use and  setup of PPP.   Some prerequisites are obvious, and others require explanation. The following list identifies the  requirements for PPP usage:     PPP support is available, either as a loadable module or statically.    The PPP software is installed on your system.    Your Linux system provides TCP/IP support.    You have a modem installed on a known serial port.    You have gathered the following information from your ISP to support PPP connectivity. Be  prepared, some ISP support staff do not understand PPP and what is required for PPP  connectivity, especially if the ISP is Microsoft influenced. Yet other ISPs can provide excellent  support, both verbally and with written documentation. The following is a list of attributes  you should acquire from your ISP for PPP connectivity:  o The phone number to the ISP.  o If using static IP assignment, you will need the IP address for your machine.  Otherwise, you will be using dynamic IP assignment.  o Does the remote server use PAP/CHAP? If so, you will need to obtain the ID and  SECRET entries required for connecting to the ISP. Normally, these entries are your  username and password.  o The Domain Name Service (DNS) server address(es) for hostname resolution.  If PPP is not installed on your system, you should refer to the distribution documentation. To install  support, running the installation program provided with your Linux distribution should install the  necessary components for PPP use. For example, with RedHat, use RPM to install the package that  supports PPP. Under SuSE Linux, you can use YaST to install the PPP package. For Caldera  OpenLinux, you can use the KPackage program to install RPM-compatible packages.   page 239   #BREAK# Inside Linux   You can easily check for the existence of PPP support using the dmesg command. You can invoke it as  shown in the following dialog:   stimpy $ dmesg | grep PPP  PPP: version 2.3.3 (demand dialing)  PPP line discipline registered.  PPP BSD Compression module registered  PPP Deflate Compression module registered  stimpy $   You will need to visit a number of configuration files to enable PPP; these will be examined in sections  that follow.   Verify DNS Support   After the PPP connection is established, your Linux machine will need to use the facilities of hostname  resolution - resolving hostnames into their respective IP addresses. Your ISP should provide you with  the names of its DNS servers. After you have this information, you need to provide entries in the  /etc/resolv.conf and /etc/hosts.conf files.   The /etc/resolv.conf file is used for name resolution. Entries found in this file designate a DNS  server and its associated IP address. More than one DNS server can be specified in this file. As  mentioned previously, your ISP can provide you with the DNS servers and their associated IP  addresses. The following is sample output from an /etc/resolv.conf file:   domain the-isp.domain.name  nameserver 19.265.15.5  nameserver 19.265.15.10   Your ISP will have one or more DNS servers; be sure to enter all DNS servers and their respective IP  addresses.   You can also set up your Linux to use DNS locally. Many Linux power users do this because it can cut  down on name-resolution traffic from your host to the server (and vice versa). Doing this will provoke  your DNS to cache DNS lookups, thereby decreasing accesses to the remote DNS for name resolution.   The following is a sample entry from an /etc/host.conf file:   order hosts,bind  multi on   The first line tells the resolver to query information (resolution) from the /etc/hosts file. If resolution  is not found there, the resolver queries the DNS server(s).   Using PPP   To establish a PPP network connection, a pair of programs are utilized, specifically chat and pppd. In  the next section, we discuss the chat program. The pppd program is discussed in the section that  follows.   Using chat   The chat program provides the automation required to establish a connection between your local  machine and the remote PPP server. The objective of chat is to establish the connection between the  local pppd and the remote&#8217;s pppd process. The syntax for chat is as follows:   chat [options] scriptFile   Table 13.4 lists the options available for chat. Be sure to refer to the man page for chat for more  detailed information.   As mentioned previously, two programs are used to establish PPP connec-ivity: chat and pppd. With  SLIP connectivity, we have to use only the dip program. Unfortunately, pppd does not provide for  dial-up and logging facilities.   The chat program implements UUCP-style chat script functionality. In a nutshell, a chat script  consists of alternating expect-send string sequences, separated by spaces. Optionally, subexpectsubsend  string pairs can be used, separated by a dash. The following example demonstrates this:   ogin:-BREAK-ogin: ppp ssword: myPswd   page 240   #BREAK# Inside Linux   Table 13.4. Common chat Options  Switch Description  -f chat  file  Read the chat script from the chat file. Multiple lines are permitted in the file. To  separate strings, use the space or the tab character.  -t timeout Set a timeout for receipt of the expect string. If the expect string is not received within the  timeout period, reply string is not transmitted.  -r report  file Set the filename for report string output.  -e Echo will be enabled when chat starts up. The ECHO keyword can be used to subsequently  toggle echoing on and off. Output is to stderr.  -v  Verbose mode will be enabled when chat starts up. The chat program will log both text  received from the modem and output strings to the modem, plus the state of chat. See  the -s flag for logfile options.  -V The chat script is executed in stderr verbose mode. The chat program will output all  dialog to the stderr device.  -s Use stderr. All log messages will be sent to stderr.  -S Do not use the SYSLOG for logging. Normally, error messages are sent to SYSLOG. If -S  is used, neither log messages from -v nor error messages are not sent to SYSLOG.  -T phone  number  Pass in a string, normally a phone number, that is substituted for the T meta-character  in a send string.  -U phone  number  Pass in a string, normally a phone number, that is substituted for the U meta-character  in a send string.  script If a script is not specified with the -f option in a file, the script is submitted to the chat  program.   We will now break down and analyze what is happening in this script. The first line tells chat to expect  the string ogin:. If chat does not receive the login prompt within the timeout period, chat will send a  BREAK to the remote end and again will wait for the string ogin:. If ogin: is received, the break is not  transmitted.   When the login prompt is received (ogin:), chat will send the string ppp and wait for the string  ssword:. If the prompt is received, chat will transmit the password myPswd. You should note that a  carriage return character is sent immediately after the reply string.   Chat scripts are fairly straightforward. The previous script is not a comprehensive one because it does  not include the expect-send strings required to perform modem initialization, dial-up, and the login  dialog. The following demonstrates a more comprehensive script, from start to finish.   stimpy # chat -v &#8216;&#8217; ATZ OK ATDT1234567 CONNECT &#8216;&#8217; ogin:-BREAK-ogin: ppp word: stimpy3   The chat program anticipates that the first string is an expect string, but because the modem won&#8217;t  expel text before we have sent something to it, the empty string (&#8221;") is specified as the (first) expect  string. The first send string is ATZ, which is a modem reset for Hayes-oriented modems. Next, we  expect to see the string OK as a response to the reset command. We follow up by submitting the dial  command and the phone number to dial. The chat program then waits for the CONNECT string to return  from the modem. The empty string is transmitted because we want to wait only on the login prompt.  Finally, the login sequence is executed as shown in the previous example.   You have probably noticed that most expect strings are not complete words. For example, instead of  expecting the string Login, the string ogin: is used. Or, instead of expecting Password, the string word:  is identified. The main reason to do this is expectation of the incoming text. It is possible that instead  of Login, the text string is actually login (with a lowercase l). Or, instead of Password, the text string is  actually password (with a lowercase p). You have to think about these seemingly insignificant details  when developing chat scripts. Even if you are positive that your PPP server is sending Password,  nothing prevents them from changing the text string. Suffice it to say that standard practice dictates  using the few letters of the expect string.   page 241   #BREAK# Inside Linux   The chat program offers a number of escape sequences. Table 13.5 lists the escape sequences offered  by chat. Any of the escapes can be in the send string.   Table 13.5. Escape Sequences for chat  Switch Description  &#8216;&#8217; Expects or sends the null (empty) string. Although no characters are transmitted, the  implied return character is still sent.  b Represents a backspace character.  c Suppresses the newline character at the end of the reply string. Use this to send a string  without a trailing return. It must be at the end of the send string.  d Delays for one second.  K Inserts a BREAK  n Sends a newline (linefeed) character.  N Sends the null character.  p Pauses for 1/10 of a second.  q Suppresses writing the string to SYSLOG.  r Sends or expects a carriage return.  s Represents a space character in the string.  t Sends or expects a tab character.  \ Sends or expects a backslash character.  ddd Used to represent an ASCII character using the equivalent octal digits.  ^C Substitutes the sequence with the control character represented by C.   Some of the escape sequences may not be identified in the expect string. Be sure to consult the man  page for chat for more information.   We need to touch on the subject of security. Executing the chat program with the script dialog is  subject to inspection by other users on the system. Anyone can execute the ps -ef command sequence  and view the complete command line. You say you have not tried these switches to the ps command?  Try it now to see the results. So, how do you deflect any users from examining the chat script? The  solution is rather simple - you put the chat dialog into a file and then tell chat to use the contents of  the file for the dialog. Referring back to Table 13.1, you will see that using the -f switch and supplying  the script file as an argument will instruct chat to use the file&#8217;s contents for the chat dialog. The  following demonstrates the syntax:   stimpy $ chat -f chat_script_filename   It is also easier to modify and maintain a script within a file, rather than modifying the command line.  You cannot identify a chat file (with -f) and specify a chat dialog on the command line, because  they&#8217;re mutually exclusive. The following is a sample chat script file:   &#8216;&#8217; ATZ  OK ATDT1234567  CONNECT &#8216;&#8217;  ogin:-BREAK-ogin: ppp  word: stimpy3   The expect-send pairs reside on the same line. This makes maintenance and troubleshooting much  easier.   It is always good to expect potential failure and to be able to recover from it. You can specify that a  script should be aborted if some failure is detected. For example, chat cannot determine the difference  between CONNECT and BUSY; chat does not know that the string BUSY is considered an exceptional  condition. So, how do you inform chat of exceptional conditions? You do this by specifying abort  strings.   page 242   #BREAK# Inside Linux   The chat keyword ABORT is used to specify an abort sequence. The following sample script  demonstrates the use of ABORT:   ABORT BUSY  ABORT &#8216;NO CARRIER&#8217;  &#8216;&#8217; ATZ  OK ATDT5551212  CONNECT &#8216;&#8217;   The chat will abort execution of the script if it detects any of the identified ABORT sequences as an  expect string.   Using pppd   The pppd command is the Point-to-Point Protocol Daemon. The syntax for pppd is as follows:   pppd [tty_name] [speed] [options]   Table 13.6 lists the more common options for the pppd command.   Table 13.6. Common Options for pppd  Option Description  asyncmap  <map>  Sets the async character map to <map>. The map describes that control characters  cannot be successfully received over the serial line.  auth Specifies that the peer is required to authenticate itself before network packets can be  sent or received.  connect  script Uses the executable or shell command specified by script to set up the serial line.  crtscts Uses hardware flow control (RTS/CTS) on the serial port.  defaultroute Adds a default route to the system routing tables.  disconnect  script  Runs the executable or shell command specified by script after pppd has terminated  the link.  escape  xx,yy,&#8230;  Causes the characters to be escaped on transmission. The characters escaped are  specified as hex numbers, delimited by commas.  file name Reads the options from file name.  lock Uses UUCP-style lock file for the serial device to ensure exclusive access to that  device.  mru n Sets the MRU value to n. The minimum value is 128 and the default is 1500.  mtu n Sets the MTU value to n.  passive Specifies that the passive option be used in the LCP.  debug Enables connection debugging facilities.  local Does not use the modem control lines; ignores the state of CD (Carrier Detect) and  pppd will not change the state of DTR.  login Utilizes the system password database for authenticating the peer using PAP. Also,  records the user in the system wtmp file.  modem  Uses the modem control lines, which is the default. The pppd command will wait for  the CD from the modem to be asserted when opening the serial device, and it will  drop the DTR when the connection is terminated.  netmask n Sets the interface netmask to n.  nodetach Doesn&#8217;t detach from the controlling terminal.  xonxoff Uses software flow control (that is, XON/XOFF) on the serial port.   Be sure to refer to the man page for pppd for an exhaustive list of commands available.   page 243   #BREAK# Inside Linux   Option Files for pppd   After pppd executes and before it scans the arguments on the command line, it scans a number of  configuration files for default options. These files contain any of the valid command-line arguments.  Comments can be included in the files and are delineated by the # sign.   One file is the options file and is found in the /etc/ppp directory. This file is always searched and  parsed when pppd first executes. It is accepted practice to use this file for any global defaults. Doing  this can help with any potential security issues that could arise. For example, you could specify that  PAP authentication be used from the peer; to do this, you include the auth option in the  /etc/ppp/options file. The user cannot override this option. The following is an excerpt from a sample  /etc/ppp/options file:   # /etc/ppp/options  # The name of this server.  name <host>  # Enforce the use of the hostname  usehostname  # If no local IP address is given,  # noipdefault  # Specify which DNS Servers the incoming  # Win95 or WinNT Connection should use  #ms-dns 192.168.1.1  #ms-dns 192.168.1.2  # enable this on a server that already  # has a permanent default route  #nodefaultroute  # Increase debugging level (same as -d). The  # debug output is written to syslog LOG_LOCAL2.  debug  # Require the peer to authenticate itself before  # allowing network packets to be sent or received.  noauth  # Use hardware flow control (i.e. RTS/CTS) to  # control the flow of data on the serial port.  crtscts  # Specifies that pppd should use a UUCP-style  # lock on the serial device  lock  # Use the modem control lines.  modem  # Set the MRU  #mru 542  # Set the MTU to n  #mtu <n>  # Set the interface netmask to <n>, a 32 bit netmask in &#8220;decimal dot&#8221;  # notation (e.g. 255.255.255.0).  netmask 255.255.255.0  # Don&#8217;t fork to become a background process  nodetach    # Specifies that pppd should disconnect  # if the link is idle for n seconds.  idle 600  # &#8212;<End of File>&#8212;   A second file that is read after the /etc/ppp/options file is parsed is .ppprc. This file is found in the  user&#8217;s home directory. Users have the ability to establish their own sets of default options by merely  supplying the required options in the file.   Script Files for pppd Connections   In this section, we introduce a set of scripts to help automate log-in and PPP startup. After these files  are set up, you have to execute only a single command to establish a PPP connection. The following  files are used for version 2.1.2 of PPP:   /usr/sbin/pppd  /etc/ppp/options  / etc/ppp/ppp-on  / etc/ppp/ppp-off   For version 2.2 of PPP, we add a third file to the list, as shown in the following:   /usr/sbin/pppd  /etc/ppp/options  /etc/ppp/ppp-on  /etc/ppp/ppp-off  /etc/ppp/ppp-on-dialer   page 244   #BREAK# Inside Linux   The following is a sample ppp-on script. You should use this script file no matter whether you are using  version 2.1.2 or 2.2 of PPP.   #!/bin/sh  # Script to initiate a PPP connection.  # Change as required.  TELEPHONE=123-4567 # The telephone number to the remote  ACCOUNT=theAccount # Account name  PASSWORD=thePassword # Password to use  LOCAL_IP=0.0.0.0 # Local IP addressl; if dynamic = 0.0.0.0  REMOTE_IP=0.0.0.0 # Remote IP address; usually 0.0.0.0  NETMASK=255.255.255.0 # Netmask, if required  # Export  export TELEPHONE ACCOUNT PASSWORD  # Location of the script which dials the phone and logs  DIALER_SCRIPT=/etc/ppp/ppp-on-dialer  # Initiate the connection  exec /usr/sbin/pppd debug /dev/ttySx 38400   $LOCAL_IP:$REMOTE_IP connect $DIALER_SCRIPT   You will have to modify the ppp-on script; the script previously shown is really a template. Starting  from the top and moving down, you first have to supply the proper phone number to your ISP. Next,  the ACCOUNT field is your username that is registered with your ISP. The field that follows ACCOUNT,  PASSWORD, is the password you use for login purposes. You may need to alter the following lines:   DIALER_SCRIPT=/etc/ppp/ppp-on-dialer  &#8230;  exec /usr/sbin/pppd debug /dev/ttySx 38400   If your pppd executable and ppp-on-dialer file exist in a different directory path, you will need to  change those paths in the script file.   Next, a sample ppp-on-dialer script is supplied as follows:   #!/bin/sh  #  /usr/sbin/chat -v   TIMEOUT 3   ABORT &#8216;nNO CARRIERr&#8217;   ABORT &#8216;nNO ANSWERr&#8217;   ABORT &#8216;nBUSYr&#8217;   &#8216;&#8217; rAT   &#8216;OK-+++c-OK&#8217; ATH0   TIMEOUT 60   OK ATDT$TELEPHONE   CONNECT &#8216;&#8217;   ogin:&#8211;ogin: $ACCOUNT   sword: $PASSWORD   The ppp-on-dialer script file contains the actual dialog that is required to dial up and log in to the  remote PPP server. In this sample, three ABORT sequences are identified; be sure to add any other abort  sequences you may require. Check your modem manual for any exceptional conditions (error strings)  that may need to trigger an abort sequence. Also, pay close attention to the value for the TIMEOUT  variable - you may need to extend this time.   Finally, a sample ppp-off script is supplied as follows:   #!/bin/sh  # Find device to kill.  if [ &#8220;$1&#8243; = &#8220;&#8221; ]; then  DEVICE=ppp0  else  DEVICE=$1  fi  # If the ppp0 pid file exists, then it&#8217;s running  if [ -r /var/run/$DEVICE.pid ]; then  kill -INT `cat /var/run/$DEVICE.pid`  # If kill didn&#8217;t work, then no process  # is running for this pid  if [ ! &#8220;$?&#8221; = &#8220;0&#8243; ]; then  rm -f /var/run/$DEVICE.pid  echo &#8220;ERROR: Deleted pid file&#8221;  exit 1  fi  #  echo &#8220;Terminated PPP link: $DEVICE&#8221;  exit 0  fi  #  # ppp not running  echo &#8220;ERROR: Invalid PPP link: $DEVICE&#8221;  exit 1   This last script is used to shut down PPP in a graceful fashion. You should not have to alter this file.   page 245   #BREAK# Inside Linux   And now, the moment of truth. After you have made all the required adjustments to the scripts, it is  time to execute and test for success. First, you need to execute the ppp-on script file, as the following  dialog demonstrates:   stimpy $ ppp-on &#038;  stimpy $   The trailing ampersand (&#038;) puts the execution of the script into the background and returns the  command prompt.   Testing the PPP Scripts   At the end of the previous section, we executed the ppp-on script. An effective method of debugging the  fruits of our labor is to examine the /var/log/messages file (or /var/adm/messages). You use the tail  command to reveal the last messages written to the log. In the example that follows, I have requested  an extract of the previous 200 messages written to the log file. I have parsed out only the lines that  pertain to the PPP dialog.   stimpy $ tail -200 /var/log/messages  Oct 11 04:24:26 stimpy pppd[13718]: pppd 2.3.5 started by root, uid 0  Oct 11 04:24:26 stimpy pppd[13718]: Using interface ppp0  Oct 11 04:24:26 stimpy pppd[13718]: Connect: ppp0 <--> /dev/modem  Oct 11 04:24:26 stimpy pppd[13718]: sent [LCP ConfReq id=0&#215;1 <asyncmap 0x0> &#8230;  Oct 11 04:24:26 stimpy pppd[13718]: rcvd [LCP ConfAck id=0&#215;1 <asyncmap 0x0> &#8230;  Oct 11 04:24:26 stimpy pppd[13718]: rcvd [LCP ConfReq id=0&#215;1 <mru 1500> &#8230;  Oct 11 04:24:26 stimpy pppd[13718]: sent [LCP ConfAck id=0&#215;1 <mru 1500> &#8230;  Oct 11 04:24:26 stimpy pppd[13718]: sent [PAP AuthReq id=0&#215;1 user=&#8221;user&#8221; &#8230;  Oct 11 04:24:29 stimpy pppd[13718]: sent [PAP AuthReq id=0&#215;2 user=&#8221;user&#8221;  Oct 11 04:24:32 stimpy pppd[13718]: sent [PAP AuthReq id=0&#215;3 user=&#8221;user&#8221;  Oct 11 04:24:34 stimpy pppd[13718]: rcvd [PAP AuthAck id=0&#215;3 &#8220;&#8221;]  Oct 11 04:24:34 stimpy pppd[13718]: Remote message:  Oct 11 04:24:34 stimpy pppd[13718]: sent [IPCP ConfReq id=0&#215;1 <addr 0.0.0.0>]  Oct 11 04:24:34 stimpy pppd[13718]: sent [CCP ConfReq id=0&#215;1 <deflate 15>&#8230;  Oct 11 04:24:34 stimpy pppd[13718]: rcvd [IPCP ConfReq id=0&#215;2 <addr 32.96 ...  Oct 11 04:24:34 stimpy pppd[13718]: sent [IPCP ConfRej id=0x2 <compress VJ ...  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [IPCP ConfNak id=0x1 <addr 32.100 ...  Oct 11 04:24:35 stimpy pppd[13718]: sent [IPCP ConfReq id=0x2 <addr 32.100 ...  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [CCP ConfRej id=0x1 <deflate 15> &#8230;  Oct 11 04:24:35 stimpy pppd[13718]: sent [CCP ConfReq id=0&#215;2]  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [IPCP ConfReq id=0&#215;3 <addr 32.96 ...  Oct 11 04:24:35 stimpy pppd[13718]: sent [IPCP ConfAck id=0x3 <addr 32.96 ...  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [IPCP ConfAck id=0x2 <addr 32.100 ...  Oct 11 04:24:35 stimpy pppd[13718]: local IP address 32.100 ...  Oct 11 04:24:35 stimpy pppd[13718]: remote IP address 32.96 ...  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [CCP ConfAck id=0x2]  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [CCP ConfReq id=0x4 < 04 02>]  Oct 11 04:24:35 stimpy pppd[13718]: sent [CCP ConfRej id=0&#215;4 < 04 02>]  Oct 11 04:24:35 stimpy pppd[13718]: rcvd [CCP ConfReq id=0&#215;5]  Oct 11 04:24:35 stimpy pppd[13718]: sent [CCP ConfAck id=0&#215;5]  Oct 11 04:24:41 stimpy pppd[13718]: rcvd [IPCP ConfReq id=0&#215;6 <addr 32.96 ...  Oct 11 04:24:41 stimpy pppd[13718]: sent [IPCP ConfReq id=0x3 <addr 0.0.0.0>]  Oct 11 04:24:41 stimpy pppd[13718]: sent [IPCP ConfAck id=0&#215;6 <addr 32.96 ...  Oct 11 04:24:41 stimpy pppd[13718]: rcvd [IPCP ConfNak id=0x3 <addr 32.100.175.196>]  Oct 11 04:24:41 stimpy pppd[13718]: sent [IPCP ConfReq id=0&#215;4 <addr 32.100 ...  Oct 11 04:24:41 stimpy pppd[13718]: rcvd [IPCP ConfAck id=0x4 <addr 32.100 ...  Oct 11 04:24:41 stimpy pppd[13718]: local IP address 32.100 ...  Oct 11 04:24:41 stimpy pppd[13718]: remote IP address 32.96 ...  stimpy $   As you can see, the PPP dial-up and login is successful. Your output from the log file will no doubt look  different from that shown previously. If the results from your connection are successful,  congratulations! Execute your favorite browser and surf to your heart's content.   When you have finished your surfing, issue the ppp-off command (script). The following is the output  from the log file after disconnecting:   Oct 11 04:38:59 stimpy pppd[13718]: Terminating on signal 15.  Oct 11 04:38:59 stimpy pppd[13718]: sent [LCP TermReq id=0x2 "User request"]  Oct 11 04:38:59 stimpy pppd[13718]: Hangup (SIGHUP)  Oct 11 04:38:59 stimpy pppd[13718]: Modem hangup  Oct 11 04:38:59 stimpy pppd[13718]: Connection terminated.  Oct 11 04:38:59 stimpy pppd[13718]: Exit.  stimpy $   Tracing through the /var/adm/messages file allows you to see just where you might be having  problems.   page 246   #BREAK# Inside Linux   Summary   In this chapter, we discovered that the Serial Line Internet Protocol (SLIP) is used to provide dial-up  network connectivity between your local machine and a remote host.   We learned that a number of prerequisites must be fulfilled in order to utilize SLIP. For hardware, a  serial port with a FIFO buffer and a modem are the only requirements. TCP/IP networking must be  enabled and the SLIP package must be installed. The loopback interface must be configured and  enabled. The /etc/resolv.conf should have entries for any DNS servers for name resolution.   To establish a SLIP network connection, slattach and dip are used. Both slattach and dip are used  collectively to initiate and establish a SLIP network connection.   After the SLIP connection is established, the network interface is configured with the ifconfig and  route commands.   We also learned that the dip command can be used to automate the SLIP process. The dip command  supports scripting, automating the command-response dialog used for dialing, connecting, and the  login process. Commands can be included in the script to automate the SLIP network interface and to  establish entries in the routing tables.   In this chapter, we also discussed what it takes to get connected using PPP.   A number of prerequisites are required to utilize PPP. A serial port with a FIFO buffer and a modem  are the hardware requirements for PPP. TCP/IP networking must be enabled and the PPP package  must also be installed. The dmesg command can be used to verify the existence of the PPP software.  Entries for name resolution must exist in the /etc/resolv.conf and /etc/hosts.conf files. Your ISP  can provide this information for you.   We learned that the chat command is used to automate the PPP dial-up and login process. The chat  command supports scripting, automating the expect-send dialog used for dialing, connecting, and the  login process. The pppd command is the Point-to-Point Protocol Daemon.   We examined the various script files required for instantiating a PPP session, namely: ppp-on, pppon- dialer, and ppp-off.   Finally, we found that we can examine the /var/log/messages file (or /var/adm/messages) to help in  debugging our PPP connectivity.   page 247   #BREAK# Inside Linux   Chapter 14. UNIX-to-UNIX Copy Program   UNIX-to-UNIX Copy Program (UUCP) is one of the long-standing and established protocols within  the TCP/IP suite. The primary use of UUCP is to facilitate the transport of email between systems.   Beginning with the next section, we begin our UUCP journeys by providing an overview of UUCP. In  the sections that follow, we discuss the requirements to set up and use UUCP between your machine  and other machines.   UUCP Overview   UUCP is one of the most widely used TCP/IP protocols on the Internet and has been around a long  time. The UUCP package was developed at AT&#038;T Bell Labs in the mid '70s. The focus was (and still is)  on providing a simple network protocol for the transfer of files and email over standard dial-up phone  lines.   A few implementations of UUCP are available for various flavors of UNIX and Linux. In addition,  implementations of UUCP can be found for other operating systems, such as DOS and Mac OS.  Despite the diversity of platforms and operating systems, the UUCP systems are quite compatible. A  standard UUCP that can be used as a baseline product does not exist.   Two strains of UUCP are in use today: Taylor UUCP and HoneyDanBer (HDB) UUCP. HDB is also  called Basic Networking Utilities (BNU) . The two strains (and variations of those) of UUCP vary  mostly with respect to installation and configuration. For the traditional UNIX user, HDB is usually  the choice. The choice among Linux users seems to be the Taylor strain. Most distributions allow you  to install either version, or both, if you have the patience and nerves to do so.   In this chapter, we discuss both strains so that you can take advantage of both, if the mood strikes you.  After you have read this chapter and sailed both UUCP waters, you can strike out on your own and try  other strains and implementations.   Basic UUCP Configuration   Most new users to UUCP feel overwhelmed by the configuration process. If you approach the  configuration for both UUCP strains in a stepwise fashion, the process will be a smooth one. The good  news is that you can use Taylor on your end and HDB on the remote end, and both will communicate  properly. The difference is in the setup.   For both versions, the stage is set under the directory /usr/lib/uucp. From this base directory, things  start to change rapidly between the two strains. The subdirectories and the contents of those  subdirectories are where the two strains diverge. For some newer versions of Taylor, the directory that  contains the configuration files is /etc/uucp.   Be sure to read the appropriate section for the strain of UUCP you want to use. If you try to force a  Taylor configuration onto HDB implementation, nothing will work properly (and vice versa).   The next section addresses the configuration of Taylor UUCP because most Linux users use that  implementation. The configuration of HDB UUCP follows immediately thereafter. After we have  covered the configuration of UUCP, whether it is Taylor or HDB, the sections that follow address the  use of UUCP. But first, let us be sure our UUCP is configured properly.   Configuration: Taylor UUCP   As mentioned in the previous section, the UUCP road to configuration starts at the /usr/lib/uucp  directory.   Some newer versions of Taylor store the configuration files in the /etc/uucp directory path. A quick  way to discover whether your Taylor UUCP uses /etc/uucp or /usr/lib/uucp is to create a sys file and  place it in one of the directories. Next, run the uuchk command; if it reports No systems, move the file  to the other directory and rerun the uuchk command. It should display the system(s) defined. If your  system does use /etc/uucp instead of /usr/lib/uucp, be sure to adjust the directory references  identified in this chapter accordingly.   page 248   #BREAK# Inside Linux   Table 14.1 shows the configuration files and a brief description of each.   Table 14.1. Taylor UUCP Configuration Files  File Description  /usr/lib/uucp/call This file contains the log name and password for any identified remote  systems.  /usr/lib/uucp/config This is the most important of configuration files. Most of the basic  configuration parameters are set in here.  /usr/lib/uucp/dial This file contains information for the dialers.  /usr/lib/uucp/dialcodes This file maintains a list of translations for representative dialcodes.  /usr/lib/uucp/password The password file contains log names and passwords for remote systems  that will dial your machine.  /usr/lib/uucp/port This file contains the details pertaining to each port for dial out.  /usr/lib/uucp/sys This file details the remote systems and the required instructions to contact  them.   Check Initial Configuration   Before we begin our journey of file configuration in more detail, let us discuss a supporting executable  to help determine the state of our UUCP configuration. The command uuchk, executed without any  parameters or options, reveals some information about your UUCP setup. The following dialog  demonstrates this:   stimpy # uuchk  Spool directory /var/spool/uucp  Public directory /var/spool/uucppublic  Lock directory /var/lock  Log file /var/spool/uucp/Log  Statistics file /var/spool/uucp/Stats  Debug file /var/spool/uucp/Debug  Global debugging level  uucico -l will strip login names and passwords  uucico will strip UUCP protocol commands  Start uuxqt once per uucico invocation  uuchk: no systems found  stimpy #   As you can see, some revealing bits of information are provided. For this system, we can see that the  spool directory is at the /var/spool/uucp directory. The last line tells us that no systems are defined for  dial out. Your output may be different than what is shown previously.   Before we leave this section, execute the uuchk command and direct the output to a file. This way, you  have a record of the UUCP configuration before you make any changes. In the later section "Verify the  Configuration," you will reexecute the uuchk command and compare the outputs.   Configuration File: config   The first file we want to visit is the /usr/lib/uucp/config file. If this file does not exist, use an ASCII  editor to create the file. If you have no other entry in this file, you should at least identify your  machine name to UUCP. The following is a snippet from a /usr/lib/uucp/config file:   stimpy # more config  nodename stimpy  stimpy #   The line entry consists of two parts. The first part is the keyword nodename and the second part is the  name of your machine. If you are creating this file for the first time, enter the nodename keyword, then  whitespace, and then the machine name. Whitespace can be a space or a tab, but it is usually a tab.   The name you choose for your UUCP system does not have to reflect the actual machine name for your  Linux system. Some people prefer to identify their UUCP name as something different than the Linux  machine name. For some people, consistency is important, so those people name their UUCP system  the same as their Linux system name (as I did). One thing to remember is that the name you identify  in the /usr/lib/uucp/config file must be the same as the name expected for any remote UUCP  systems you connect with. If the name is incorrect, a connection will not be established.   page 249   #BREAK# Inside Linux   Other entries can exist in the /usr/lib/uucp/config, but for now, save the file and exit out of your  editor. I will describe some of the other entries (such as identification of the spool directory) that can  exist in this file.   Configuration File: sys   The next file that you should examine is the /usr/lib/uucp/sys file. This file contains information  about remote systems that you want to connect and interact with. Without this file, you will not be  able to contact any remote systems. The following is a snippet from a /usr/lib/uucp/sys file:   # sys file:  # default parameters ...  protocol-parameter G packet-size 1024  # remote entries:  #  system ren  time Any  phone 123-456-7890  port portOne  speed 57600  chat "" rc ogin:-BREAK-ogin:-BREAK-L word: P  #  system toastMan  call-login *  call-password *  time Any  phone 456-789-0123  port portOne  speed 57600  chat "" rc ogin:-BREAK-ogin:-BREAK-L word: P  ...   This file contains all the remote systems that you need to establish a connection with. For each remote  system identified, be sure the parameters required to dial and establish a connection (to the remote  site) are correct.   Take a look at the third line in the file, which is shown here again:   protocol-parameter G packet-size 1024   Any configuration entries that occur before the first system line are considered default configuration  values. These default values are used by all system entries. The defaults can be overridden within the  individual system entries. As a rule, protocol parameters and other similar configuration options are  set in the defaults section.   The sample sys file shown previously contains two remote system entries: ren and toastMan. The line  entries that follow the system entry are the parameters required to establish a connection to the  identified site. For example, the phone number to connect to ren is 123-456-7890; the connection  speed is 57600 baud, and UUCP will use the logical port named portOne. We will discuss the  /usr/lib/uucp/port file in just a moment.   The remote system is identified by the system keyword. This name must be the actual name of the  remote UUCP system. If you use a logical name, when your UUCP system dials and connects with the  remote system, the verification process will fail. System names are traded by both ends of the UUCP  connection during negotiation. Thus, if the system being called does not match the name presented,  failure will occur.   You can have only one system name in the sys file. There may be times when you would like to have  multiple configurations for a single site; if this is the case, you can utilize the functionality of  alternates. We will discuss the alternates keyword in a moment.   The time keyword is used to restrict the times that the remote system can be contacted. In this sample  sys file, the argument to time is Any, which means that you can dial that system at any time, day or  night. Why would it be important to designate time restrictions? It might be that the remote system is  available only during specific hours and on specific days of the week. Or you might want to dial the  system during off-peak hours to save on long-distance charges.   Next, the phone keyword is used to identify the phone number to dial to reach the remote site. You can  include any special dialing sequences and tokens before and after the phone number. This allows you  to access an outside line, disable call waiting, or insert pauses as appropriate.   page 250   #BREAK# Inside Linux   The port keyword is used to identify the serial port to use for the remote connection. This is not the  actual device as found on your Linux system. The port name identified here is a logical name (or alias)  for an entry in the /usr/lib/uucp/port file, which is covered in the next section.   If you use a direct connection between the two machines, you will want to identify the logical port  name in the /usr/lib/uucp/sys file. The name can be any logical name you like, such as  directPortOne. Be sure to provide the proper entry in the /usr/lib/uucp/port file, which is covered in  the section that follows.   The modem speed is determined by the speed keyword. This is the maximum speed to which the serial  line is set. This should be set to the maximum allowed by the modem.   The chat keyword contains the sequence of instructions to establish the connection. This is the  "conversation" that is held between the two UUCP endpoints after a modem connection is established.  This is sometimes called the login chat sequence. The logic follows the expect-send pattern of tokens  as is used by other TCP/IP protocols (SLIP and PPP come to mind). In other words, an expect string is  anticipated and a send string is transmitted. This alternating sequence of expect and send pairs is  never deviated from. The chat script that follows is taken from the sample sys file shown previously.   chat "" rc ogin:-BREAK-ogin:-BREAK-L word: P   This chat is interpreted as follows: Expect nothing from the remote system (empty string) and send a  carriage return character, followed by $#$#. Next, expect the string ogin: and respond with the login  name, which is designated by the token L. The dash character after the ogin: string means, "if you do  not see the ogin: string after the timeout period, send a BREAK character." The next expect string is  word: -the password is sent to the remote system, which is designated by the token P.   You probably noticed that the words (strings) to expect are not complete. In other words, the strings  Login: and Password: are not specified, but rather ogin: and word: are to be expected. Why is this, you  ask? Well, one system may send the string Password: whereas another system might send password:.  Also, the possibility exists that garbage characters are introduced into the data stream. Therefore, the  best answer in these situations is to specify some least common denominator for a string.   The dash character is referred to as a subchat. The subchat is used to identify a response if the main  expect fails. If the (main) string expected is seen, the subchat is not executed.   One last note concerning any strings that are sent: The carriage return character is automatically sent  after any string that is transmitted.   Configuration File: port   The /usr/lib/uucp/port configuration file contains all the identified port(s) to be used by UUCP. If  you recall from the previous sys section, the port (for some systems) is identified using a logical port  name rather than the device name. This allows you to change the actual port without having to disturb  the sys file. The following is a snippet from a typical port file.   # designation for portOne  port portOne  device /dev/cua0  type modem  speed 57600 dialer Hayes  # designation for portTwo  port portTwo  device /dev/cua1  type modem  speed 115200  dialer Hayes   This snippet is fairly straightforward. Notice that there are two port entries: portOne and portTwo. You  can name the ports any name that you like. The key to a proper name is whether it properly represents  the port designation. Some other names that are easy to remember are serialOne, serialTwo, comOne,  comTwo, and so on.   Some administrators use numbers mixed with the alpha names. Personally, I find that can sometimes  become confusing. A good example is the logical port name serial1. You have to look really hard to see  that the last character is the number 1 and not the lowercase letter L. I find that it is better to explicitly  spell out any numeric portion. Another option is to use the underscore character to precede the  numeric portion. For example, instead of naming the port serialEleven, you could write it as  serial_11. In the end, you should do whatever is most comfortable for you and your system.   page 251   #BREAK# Inside Linux   As mentioned previously, the port keyword is used to uniquely identify the logical port. You can use  whatever name you like, as long as the port name designated in the sys file can be found in the port  file.   The device keyword is used to identify the hardware device. The argument to the device keyword  should be a path designation to the serial device.   The type keyword identifies the hardware device that controls the data stream. The device identified  in the sample snippet is modem.   If you use a direct connection between the two machines, you need to identify a logical port name in   the port line and specify the type to be "direct." You can use any logical name you like, such as  directPortOne.   The speed of the line and the maximum speed allowed is determined by the keyword speed. The speed  should be a value that is enumerated for the device. For example, acceptable speeds for serial lines  would be 300, 1200, 2400, 4800, 9600, 19200, and so on.   The keyword dialer refers to a dialer entry in the /usr/lib/uucp/dial file; this entry initializes the  device identified by the type keyword. In other words, the dialer named Hayes contains entries for  modem initialization, dialing commands, and so forth. The dial file, which contains one or more dialer  entries, is discussed in the later "Configuration File: dial" section.   Configuration File: call   The /usr/lib/uucp/call file contains an entry, consisting of a login and password, for each identified  remote system that you poll. The following provides a simple example:   ren uName pSwd   This identifies ren as a remote system that is polled. The username uName is used for login purposes  and the password is pSwd.   Configuration File: dial   The dial file contains entries for the dialers. Each dialer entry is used to specify how a modem is to dial  the phone. The dialer is identified by a logical name. A chat script is associated with the dialer. The  following sample demonstrates a typical entry in the dial file.   # the Hayes dialer  dialer Hayes  chat "" ATZ OK ATE0V1X4&#038;C1 OK ATDTT CONNECT   As you can see, a dialer entry is straightforward. The most you should be concerned with is the chat  script. You should have a good understanding of the modem and its AT command set. If the modem  does not implement the Hayes AT command set, you will need to apply the proper command(s) in the  chat script.   In the previous example, the dialer is identified using the logical name Hayes. Because chat scripts  begin with an expect string, the empty string is specified (the modem will not speak arbitrarily). Next,  the ATZ command is sent to the modem to reset it. After the modem is reset, it responds with the  string OK. Next, the modem initialization string ATE0V1X4&#038;C1 is sent to the modem, setting the modem  to a known state. Again, the OK string is expected back from the modem. The next string send is the AT  dial string. The token sequence T is replaced with the telephone number identified in the sys file. The  final expect string in the chat is CONNECT.   Most Hayes modems return the connection speed as part of the CONNECT string (if configured  properly). For example, if the two modems establish a connection at 9600 baud, the string returned is  CONNECT 9600. For this chat script, the only concern is that a connection is established - not the speed  of the connection. For this reason, only the CONNECT string is expected. You can, however, check for  specific connect strings if that is a requirement.   Configuration File: dialcodes   The file /usr/lib/uucp/dialcodes maintains a list of translations for representative dialcodes.   page 252   #BREAK# Inside Linux   Configuration File: password   The file /usr/lib/uucp/password contains the log names and passwords for any remote systems that  dial your system. The format is as follows:   # uuguest-login-name password  bbunny bunnyPass   In the previous example, bbunny is the remote username and the associated password is bunnyPass.   Verify the Configuration   One last thing to check is the ownership of the files you have created. For example, the following  dialog shows the effects of file ownership after creating the required files:   stimpy # ls -al  total 468  drwxr-xr-x 2 root root 1024 Oct 25 01:05 .  drwxr-xr-x 58 root root 7168 Oct 13 23:17 .. -rw-r--r--1 root root 16 Oct 24 23:54 config -rw-r--r--1 root root 324 Oct 25 01:05 sys -rwxr-xr-x 1 root root 66444 Jul 22 19:24 uuchk -r-sr-sr-x 1 uucp uucp 223308 Jul 22 19:24 uucico -rwxr-xr-x 1 root root 72640 Jul 22 19:24 uuconv -rwxr-xr-x 1 root root 319 Jul 22 19:24 uusched -r-sr-sr-x 1 uucp uucp 100224 Jul 22 19:24 uuxqt  stimpy #   Notice the files owned by root. The files in this directory require ownership by the uucp user. To fix  this problem, you issue the chown command. The following sample dialog shows how to do this:   stimpy # chown uucp.uucp *  stimpy #   The chown command is used to change the user and group ownership of one or more files. The first  argument to chown is the user and group, and the second argument is the file or files that require  ownership modification. For more information about the usage of chown, check its man page.   Because we want to change ownership for both the owner and the group, we identify the owner name,  a period (.), and then the group name. Because we want all the files in the directory to have the same  owner name and group, we provide the all-files wildcard. The following dialog bears the fruits of our  labor:   stimpy # ls -al  total 468  drwxr-xr-x 2 root root 1024 Oct 25 01:05  drwxr-xr-x 58 root root 7168 Oct 13 23:17 ..  -rw-r--r--1 uucp uucp 16 Oct 24 23:54 config -rw-r--r--1 uucp uucp 324 Oct 25 01:05 sys -rwxr-xr-x 1 uucp uucp 66444 Jul 22 19:24 uuchk -r-sr-sr-x 1 uucp uucp 223308 Jul 22 19:24 uucico -rwxr-xr-x 1 uucp uucp 72640 Jul 22 19:24 uuconv -rwxr-xr-x 1 uucp uucp 319 Jul 22 19:24 uusched -r-sr-sr-x 1 uucp uucp 100224 Jul 22 19:24 uuxqt  stimpy #   As you can see, file ownership is now set to uucp.   To verify the changes you have made, execute the uuchk command as you did in a previous section.  The following dialog demonstrates this:   stimpy $ uuchk  Local node name stimpy  Spool directory /var/spool/uucp  Public directory /var/spool/uucppublic  Lock directory /var/lock  Log file /var/spool/uucp/Log  Statistics file /var/spool/uucp/Stats  Debug file /var/spool/uucp/Debug  Global debugging level  uucico -l will strip login names and passwords  uucico will strip UUCP protocol commands  Start uuxqt once per uucico invocation    System: ren  When called using any login name  Call out using port portOne at speed 9600  The possible ports are:  *** There are no matching ports  Phone number 123-456-7890  Chat script "" rc ogin:-BREAK-ogin:-BREAK-L word: P  Chat script timeout 10   page 253   #BREAK# Inside Linux    Chat script incoming bytes stripped to seven bits   At any time may call if any work   May retry the call up to 26 times   May make local requests when calling   May make local requests when called   May send by local request: /   May send by remote request: ~   May accept by local request: ~   May receive by remote request: ~   May execute rnews rmail   Execution path /bin /usr/bin /usr/local/bin /usr/lib/news /usr/lib/news/bin   Will leave 50000 bytes available   Public directory is /var/spool/uucppublic   Will use any known protocol   stimpy $   The uuchk output should be different than what was captured in the earlier section titled "Check Initial  Configuration." If the output is the same, you should examine the output from uuchk. Are you storing  the configuration files in the proper directory? Are you using the correct configuration filenames? You  should also check the contents of the various configuration files to be sure that you are using the  proper keywords.   If you examine the previous output of uuchk closely, you will notice the message *** There are no  matching ports. If we take a look at both the /usr/lib/uucp/sys and /usr/lib/uucp/port files, we will  see the problem. First, the /usr/lib/uucp/sys file is output and then the /usr/lib/uucp/port file.   stimpy $ cat sys  # sys file:  # remote entries:  #  system ren  time any  phone 123-456-7890  port portOne  speed 9600  chat "" rc ogin:-BREAK-ogin:-BREAK-L word: P  stimpy $   Next, we show the /usr/lib/uucp/port file:   # designation for portOne  port portOne  device /dev/cua0  type modem  speed 57600  dialer Hayes  # designation for portTwo  port portTwo  device /dev/cua1  type modem  speed 115200  dialer Hayes  stimpy $   The problem is obvious: in the /usr/lib/uucp/sys file, the speed identified is 9600, whereas in the  /usr/lib/uucp/port file, the speed identified for portOne is 57600 baud. Assume the  /usr/lib/uucp/sys file has been changed to reflect the speed of 57600. The following is the output  from uuchk after the applied changes.   bash-2.03# uuchk  Local node name stimpy  Spool directory /var/spool/uucp  Public directory /var/spool/uucppublic  Lock directory /var/lock  Log file /var/spool/uucp/Log  Statistics file /var/spool/uucp/Stats  Debug file /var/spool/uucp/Debug  Global debugging level  uucico -l will strip login names and passwords  uucico will strip UUCP protocol commands  Start uuxqt once per uucico invocation    System: ren   When called using any login name   Call out using port portOne at speed 57600   The possible ports are:   Port name portOne   Port type modem   Using port name as device name   Speed 57600   Carrier available   Hardware flow control available   page 254  #BREAK# Inside Linux   Dialer Hayes   Chat script "" ATZ OK ATE0V1X4&#038;C1 OK ATDTT CONNECT   Chat script timeout 60   Chat script incoming bytes stripped to seven bits   Wait for dialtone ,   Pause while dialing ,   Carrier available   Wait 60 seconds for carrier   Phone number 123-456-7890   Chat script "" rc ogin:-BREAK-ogin:-BREAK-L word: P   Chat script timeout 10   Chat script incoming bytes stripped to seven bits   At any time may call if any work   May retry the call up to 26 times   May make local requests when calling   May make local requests when called   May send by local request: /   May send by remote request: ~   May accept by local request: ~   May receive by remote request: ~   May execute rnews rmail   Execution path /bin /usr/bin /usr/local/bin /usr/lib/news /usr/lib/news/bin   Will leave 50000 bytes available   Public directory is /var/spool/uucppublic   Will use any known protocol   stimpy $   You will notice that all of the issues concerning the port have been resolved. The uuchk command is  very useful in determining any problems that might occur with UUCP and its configuration files. Use  uuchk whenever you suspect a problem with UUCP.   Configuration: HoneyDanBer (HDB) UUCP   The most current implementation of UUCP is HoneyDanBer (HDB). HDB UUCP is more prevalent  among UNIX systems and can also be found for Linux. If Taylor UUCP is your UUCP implementation  of choice, configuring HDB UUCP might seem confusing. However, after you learn the format,  configuring HDB is quite painless.   A number of files have to be visited. Table 14.2 lists the files involved.   Table 14.2. HoneyDanBer UUCP Configuration Files  File Description  /usr/lib/uucp/Devices This file describes the devices that participate in connecting with remote  systems.  /usr/lib/uucp/Dialers This file contains the chat script required to dial and establish a  connection with a remote system.  /usr/lib/uucp/Permissions This file maintains the permission settings that are required for file  handling at the remote and local machines.  /usr/lib/uucp/Systems The Systems file contains information about the remote systems and  other attributes relating to each system.   You will recall that the /usr/lib/uucp/sys file, under Taylor UUCP, maintains the name of the system  and is used to identify itself to the remote system. With HDB UUCP, a configuration file is not used to  identify the local system, but relies on the execution of the hostname command to set the name. The  syntax for the hostname command is as follows:   stimpy $ hostname [options][name of host]   You invoke the hostname command using the -S option and supplying the name of your host machine,  as shown in the following sample:   stimpy $ hostname -s goofBall   Let us now take a look at each of the HDB configuration files in turn, beginning with the  /usr/lib/uucp/Systems file.   page 255  #BREAK# Inside Linux   Configuration File: Systems   Each of the remote systems that you wish to connect with, or allow a connection with your machine, is  found in the /usr/lib/uucp/Systems file. Each line in the file describes a single remote system. The line  consists of multiple attributes, each separated by whitespace. The format for a system entry is as  follows:   remoteSystem schedule device speed phoneNumber logScript   The remoteSystem attribute designates the remote system name. As with Taylor UUCP, you must be  sure the name is correct because the name is validated during login negotiation.   The schedule refers to days and times that the remote system can be contacted. The entries here are  similar to the format that Taylor UUCP allows.   The device attribute identifies the device that is used to contact the remote systems. This entry must  correspond to an entry in the /usr/lib/uucp/Devices file.   If you want to identify a direct connection between the remote and the local machine, a logical name  such as directPortOne can be used. Be sure to provide a device entry in the Devices file. A description  of the Devices file follows this section.   The speed identifies the allowable speed or speeds that can be used for the connection. This value  should correspond to the enumerated values allowed for the identified device.   The phoneNumber attribute identifies the phone number that is used to dial the remote system. Any dial  modifiers can be specified here if you so desire. If you modify the dialing sequence, you should specify  this in the /usr/lib/uucp/Dialers file. For example, if you need to disable call waiting when dialing  any remote site, this should be specified in the Dialers file. If you do not specify the call-waiting string  in the Dialers file, you will have to prefix each phone number with the string.   The logScript is the typical expect-send dialog that is used with other TCP/IP protocols utilizing a  chat script, such as SLIP and PPP. A response (string of text) is expected from the remote end and the  send entry is transmitted in response. The focus of this script is for login purposes only. Modem  initialization and dialing is not specified in this script.   The following is a sample entry from a /usr/lib/uucp/Systems file:   rabbit Any ACU 28800 123-456-7890 ogin: uucp sword: pswd   The remote system is identified as rabbit. The remote system can be contacted at any time (24  hours/day, 7 days/week). The acronym ACU stands for Automatic Calling Unit and is an entry found  in the /usr/lib/uucp/Devices file. The phone number to dial is 123-456-7890. Finally, the login script  is interpreted as follows: wait for the string ogin: and respond by sending the string uucp. Next, wait  for the string sword: from the remote system and respond by transmitting the string pswd. Notice that  the complete word is not specified for the expect string. This is common practice with chat scripts. You  can never be sure if the expect string is Password: or password:, so I suggest that you reduce the word  to a known string.   Configuration File: Devices   Next in the relationships among HDP configuration files, we come to the /usr/lib/uucp/Devices file.  As mentioned previously, the Devices file is used to describe the available devices that are used to  contact the remote systems. The structure of the Devices file is the same as it is in the Systems file.  Each line designates a different device, and each line consists of multiple attributes, each separated by  whitespace. The following shows the syntax for a device entry:   device ttyLine dialerLine speed dialer   The device is the logical name that uniquely identifies the actual device. If you have identified a device  in the Systems file, a matching entry (device) should be in the Devices file.   The ttyLine attribute identifies the actual device, such as /dev/modem, that facilitates establishing a  connection to the remote system.   The dialerLine entry is obsolete now, but it is retained for backward compatibility.   The attribute speed is used to identify the maximum speed that is used to establish a connection. This  should match an enumerated value that is understood by the device.   page 256   #BREAK# Inside Linux   Configuration File: Dialers   Next, the dialer entry in the /usr/lib/uucp/Dialers file identifies an entry found in the  /usr/lib/uucp/Dialers file. It can also be used to identify a command file that is used to handle the  initialization and dialing. The following is a sample device entry:   ACU modem - 28800 USR288   The device is identified as ACU. The tty line to be used is /dev/modem and can utilize a line speed of (up  to) 28800 baud. Because the dialerLine attribute is obsolete, a dash is used for its entry. The dialer  entry is identified by the logical name USR288. A corresponding entry can be found in the  /usr/lib/uucp/Dialers file. This leads us to the configuration of the Dialers file.   As with the Systems and Devices files, the /usr/lib/uucp/Dialers file contains one or more unique  entries, each on a separate line. The fields for each entry are separated by whitespace. The following  shows the syntax for a Dialer entry:   dialer translate chatScript   The attribute dialer is the logical name of the Dialer entry. The dialer attribute (in Dialer) matches  the dialer entry found in the /usr/lib/uucp/Devices file.   The translate keyword specifies the conversion of tokens to (other) tokens or commands that are  understood by the device.   Finally, the chatScript is the standard expect-send script dialog that is used to initialize and dial the  modem. The following is a sample entry from a /usr/lib/uucp/Dialer file:   USR288 -, "" ATZ OKr EATDTTr CONNECT   The logical name for this dialer is USR288 and matches an entry in the /usr/lib/uucp/Devices file  previously shown. A dash is interpreted as comma, which translates to a pause by the modem. Next,  the chat script is encountered. The first expect is the empty string, so the first send string is the  modem reset AT command. The modem should send the string OK in response to the reset command.  The AT dial string is sent to the modem followed by the telephone number identified in the  /usr/lib/uucp/Systems file. The token T is replaced with the actual telephone number. Finally, the  string CONNECT is expected.   Configuration File: Permissions   The last configuration file we need to examine is the /usr/lib/uucp/Permissions file. This file is used  to identify the permissions concerning file transfer and remote execution of commands. The following  is a sample Permissions file:   MACHINE=bunny LOGNAME=bugs   READ=/var/spool/uucp   WRITE=/var/spool/uucp   SENDFILES=yes REQUEST=yes   COMMANDS=/bin/rmail:/bin/rnews  #  MACHINE=duck LOGNAME=daffy   READ=/var/spool/uucp:/var/spool/uucp/uucppublic:/files   WRITE=/var/spool/uucp:/var/spool/uucppublic   SENDFILES=yes REQUEST=yes   COMMANDS=/bin/rmail:/usr/bin/rnews   In this sample, you can see that two remote systems are described: bunny and duck. For the sake of  consistency, each entry in the Permissions file consumes only a single line in the file. Here, the  backslash character () is used as a line-continuation identifier. Most people administrating UUCP  follow this convention because breaking the entry into multiple lines makes it more readable.   The attribute named MACHINE identifies the remote machine, which is named bunny and the login is  bugs. The attribute READ identifies a list of one or more directories that files can be read from.  Likewise, the WRITE attribute is used to identify the list of (one or more) directories where files are  written. The SENDFILES attribute states whether the remote site can send files to your site; the values  for SENDFILES are yes or no. Like SENDFILES, the REQUEST attribute specifies whether the remote site  can request files from your site; again, the values are yes or no. The attribute COMMANDS contains a list  of one or more commands that the remote system is allowed to execute on your machine.   page 257   #BREAK# Inside Linux   A UUCP Session   In the previous two sections, we covered the configuration of two strains of UUCP: Taylor and  HoneyDanBer. Each strain diverges significantly with respect to configuration filenames and the  structure and content of those files. Despite these differences of configuration, the outward  functionality of Taylor and HDB UUCP is the same. In other words, a Taylor UUCP system can  connect to and communicate with an HDB UUCP system, and vice versa.   Overview of the uucp Command   When you think about the intent of UUCP - to copy one or more files from one machine to another the  outward functionality required is minimal. This means that the uucp application is uncomplicated.  The following shows the syntax for UUCP's main command, uucp:   uucp [options] source-file destination-file  uucp [options] source-file ... destination-directory   The first form copies the source-file to the destination-file. Using the second form copies all the  files specified as source-file ... to the destination-directory. The source-file can be a pathname  relative to the uucp directory if the file is on the local machine. If the file is on the remote machine, the  syntax for the pathname identification is of the following form:   system!path   This form of pathname specification consists of the remote machine name and the pathname of the  file, using the ! character as a separator. You can also transfer a file from a source destination to your  local machine via a second remote machine (sort of a middleman machine). This can be specified as  follows:   system1!system2!pathname   Any pathname identified with the ~ character by itself will begin relative to the UUCP public directory.  Be careful, however; some systems may interpret a lone ~ as relative to the local home directory of the  current user. If this is the case, you must quote the ~ character. Any pathname that has the following  form will begin relative to the named-user's home director:   ~named-user   The uucp command can be invoked at any time to transfer a file. If the UUCP system is not running,  the file is queued until a connection with the remote system is established. This implies that the copy  is not initiated immediately. If a connection is not currently established, the uucico command is  invoked to transfer the file(s).   Table 14.3 provides a description for each uucp command. Be sure to check the uucp man page for  more information.   Table 14.3. Descriptions for uucp Command Options  Option Description  -c If specified, the local source files are not copied to the spool directory. The files must be  processed by uucico before they are removed, or the copy will fail.  -C If this option is specified, the local source files are copied to the spool directory.  -d This option, when supplied, creates the necessary directories when performing a copy.  -f If specified, the copy is aborted if any required directories do not exist.  -g grade  Specifies a grade to be set for the file-transfer command. Highest grade jobs are  executed first. The grades run from high to low, using the following list: 0 9, A Z, and  a z.  -m Uses the mail system to report on the completion or failure of a file transfer.  -n user Sends mail to the user on the remote system to report on the completion or failure of a  file transfer.  -r This option only queues the file for transfer at a later time; the uucico daemon is not  started immediately.   page 258   #BREAK# Inside Linux   Option Description  -j Using this option will print out the jobid to the standard output. You can use this jobid  to cancel a job later.  -W If you specify this option, the remote relative path-names are not prefixed to the current  directory.  -x type  Specifies specific debugging types to be enabled. The following are typical debugging  types: abnormal, chat, config, execute, handshake, incoming, outgoing uucp-proto,  port, proto, and spooldir.  -I file Identifies the configuration file to be used.  -v Displays the version information.  --help Shows help for the uucp command.   UUCP Scripts   Both strains of UUCP, Taylor and HDB, provide expect-send scripting for the purposes of login. In  Taylor UUCP, login scripting is specified in the /usr/lib/uucp/sys file; in HDB UUCP, scripting is  specified in /usr/lib/uucp/Systems file. The expect string is specified in the same manner for either  Taylor or HDB UUCP. The send string is also treated in the same logical manner for both strains.   Login scripting is critical to the success of a connection. If your machine cannot log in to the remote  system, file transfer will never happen. If you are using direct descendants of Taylor or HDB UUCP,  you should not have a problem. If you are using a special distribution (proprietary) of UUCP, you will  have to examine the documentation provided by the package.   Script logic in UUCP implements the typical expect-send string pairs found in other TCP/IP protocol  packages, such as the Point-to-Point Protocol (PPP). The first string in a script is always the string of  text to be expected. The second string of text in a script is the text to be transmitted in response to the  expect string. These expect-send text pairs continue to alternate until the end of script is encountered.  A typical login script, in its simplest form, follows:   ogin: jqpublic sword: pswd3   A majority of UUCP sites require only this dialog to establish a connection. As is common practice, the  expect strings are shortened to compensate for UUCP login inconsistencies. One system might send  Password and another system might send password.   Table 14.4 briefly describes the escaped characters that are allowed in a chat script.   Table 14.4. UUCP Escaped Character Descriptions  Option Description  \ Transmits (a single) backslash () character for both send and receive  c Specifies that the carriage return character should not be sent  d Pauses the script for one second  p Pauses the script for less than one second  n Transmits the newline character  r Transmits the carriage return character  s Transmits the space character  t Transmits the (horizontal) tab character   page 259   #BREAK# Inside Linux   The s sequence allows you to embed a space in either the expect or the send string. Normally, a space  character delimits the expect-send pair. The sample dialog that follows appears okay, but a problem  exists:   ogin: user name sword: pswd   The intent here is to expect the string ogin: and then send the string user name. Next, the string  sword: is expected and the string pswd is sent in response. The way this script is really executed is as  follows: the first expect string is ogin: and the string name is sent in response. Next, the text name is  expected and the text sword: is sent in response. Finally, the script interpreter will wait for the string  pswd, which never comes.   Logically, the script should bomb out at the second expect string name. Technically, however, the login  will most likely fail when the remote end receives the login name of user. Suffice it to say that this  script will not work.   To fix this script, the s is inserted between user and name, as the following corrected script  demonstrates:   ogin: usersname sword: pswd   Notice that two expect-send pairs are now in the script, which is what we want. If the expect string  ogin: is received, the string user name is transmitted. Lastly, if the text sword: is detected, the text pswd  is transmitted in response.   If the remote UUCP is not transmitting a login prompt, you can send a BREAK or carriage-return  character to initiate a dialog. The following scripts show how this can be done:   ogin:-BREAK-ogin: userName sword: pswd  ...  "" rp ogin: userName sword: pswd   The first sample script specifies an expect string of ogin:, as usual. If that string is not detected within  the timeout period, the subscript is executed. The subscript consists of the BREAK and the 