⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 568-570.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Using SLIP and PPP</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=29//-->

<!--PAGES=568-570//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="566-568.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="571-573.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Using the /etc/diphosts File</FONT></H4>

<P>The /etc/diphosts file controls access to SLIP on your machine and contains the connection parameters for each account allowed to use SLIP. It contains lines that look similar to the following:

</P>

<!-- CODE SNIP //-->

<PRE>

Slinux2::linux2.burwell.com:linux2 SLIP:SLIP,296

</PRE>

<!-- END CODE SNIP //-->

<P>The fields in this file are the user ID, secondary password, host name or IP address of the calling machine, an informational field not currently used, and the connection parameters for this account. The connection parameters field contains the protocol (SLIP or CSLIP) and the Maximum Transmission Unit (MTU) value for this account.

</P>

<P>If the second field isn&#146;t empty, <TT>diplogin</TT> prompts for an external security password when the specified account logs in to your machine. If the response from the remote host doesn&#146;t match the string in this field, the login attempt is aborted.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>CAUTION:&nbsp;&nbsp;</B><BR>The <TT>diplogin</TT> program requires superuser privileges to modify the kernel routing table. If you aren&#146;t running <TT>dip setuid root</TT>, you can&#146;t use a link between <TT>dip</TT> and <TT>diplogin</TT>. You must make a separate copy of <TT>dip</TT> called <TT>diplogin</TT> and have its suid root.<HR></FONT>

</BLOCKQUOTE>

<P>That&#146;s all it takes. Setting up SLIP accounts and the /etc/diphosts file completely configures your system to support incoming SLIP links.

</P>

<H3><A NAME="Heading10"></A><FONT COLOR="#000077">Using PPP</FONT></H3>

<P>Point-to-Point Protocol (PPP) is another protocol for sending datagrams across a serial link. Developed after SLIP, PPP contains a number of features SLIP lacks. It can automatically negotiate options such as IP addresses, datagram sizes, and client authorization. It can also transport packets from protocols other than IP.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Automating PPP Links with <I>pppd</I> and <I>chat</I>

</FONT></H4>

<P>PPP operates in two parts: the PPP driver in the Linux kernel and a program called <TT>pppd</TT> that the user must run. The most basic means of using PPP is to log in manually to the remote host by using a communications program, and then manually start <TT>pppd</TT> on the remote and local hosts. It&#146;s much more convenient to use a <TT>chat</TT> script with <TT>pppd</TT> that handles the modem, logging in to the remote host, and starting the remote <TT>pppd</TT>. Before diving into <TT>pppd</TT>, take a quick look at <TT>chat</TT>.</P>

<P><FONT SIZE="+1"><B>Using the chat Program</B></FONT></P>

<P><TT>chat</TT> is a program for automating the interaction between your computer and a modem. It&#146;s used mainly to establish the modem connection between the local and remote <TT>pppd</TT> daemon processes. The syntax for <TT>chat</TT> is as follows:</P>

<!-- CODE SNIP //-->

<PRE>

chat [<I>options</I>] <I>script</I>

</PRE>

<!-- END CODE SNIP //-->

<P>Table 29.4 lists the command-line options for the <TT>chat</TT> program.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 29.4</B> <TT>chat</TT> Command-Line Options

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Option

<TH WIDTH="80%" ALIGN="LEFT">Description

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD><TT>-f <I>filename</I></TT>

<TD>Uses the <TT>chat</TT> script in the specified file.

<TR>

<TD><TT>-l <I>lockfile</I></TT>

<TD>Makes a UUCP style lock file by using the specified lock file.

<TR>

<TD VALIGN="TOP"><TT>-t <I>num</I></TT>

<TD>Uses the specified number as the timeout in seconds for each expected string.

<TR>

<TD><TT>-v</TT>

<TD>Makes a <TT>chat</TT> log of everything it sends and receives to syslog.

<TR>

<TD><I><TT>script</TT></I>

<TD>Specifies the <TT>chat</TT> script to use.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>You can&#146;t use the <TT>-f</TT> option and specify a <TT>chat</TT> script at the same time&#151;they&#146;re mutually exclusive. If you use the <TT>-l</TT> option for <TT>chat</TT>, don&#146;t use the <TT>lock</TT> option with <TT>pppd</TT> because the lock file created by <TT>chat</TT> causes <TT>pppd</TT> to fail, thinking that the modem device is already in use.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>When debugging <TT>chat</TT> scripts, run <TT>tail -f /var/adm/messages</TT> on one virtual console and use the <TT>-v</TT> option when you run <TT>chat</TT> in another. You can then watch the conversation <TT>chat</TT> is having as it comes up on the first virtual console.<HR></FONT>

</BLOCKQUOTE>

<P><FONT SIZE="+1"><B>Creating chat Scripts</B></FONT></P>

<P><TT>chat</TT> scripts consist of one or more expect-reply pairs of strings separated by spaces. The <TT>chat</TT> program waits for the expected text and sends the reply text when it receives it. Optional subexpect-subreply pairs can be included in the expect portion, separated by hyphens.</P>

<P>Here is a typical <TT>chat</TT> script for logging in to a Linux machine:</P>

<!-- CODE SNIP //-->

<PRE>

ogin:-\r\n-ogin: abbet1 word: costello

</PRE>

<!-- END CODE SNIP //-->

<P>This script says that <TT>chat</TT> should wait for the string <TT>ogin:</TT> to appear. If <TT>chat</TT> times out before receiving it, <TT>chat</TT> should send a carriage return and line feed and wait for the string <TT>ogin:</TT> again. When <TT>chat</TT> sees the <TT>ogin:</TT> string, it sends <TT>abbet1</TT> and then waits for the <TT>word:</TT> and sends <TT>costello</TT> in response.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>Include only the text necessary in expect strings to positively identify what you&#146;re looking for, to minimize the chance of a mismatch or having your script blow up because of garbled text. For example, use <TT>ogin:</TT> instead of <TT>login:</TT> and <TT>word:</TT> instead of <TT>password:</TT>.<HR></FONT>

</BLOCKQUOTE>

<P><TT>chat</TT> normally sends a carriage return after each reply string unless a <TT>\c</TT> character sequence ends the string. Carriage returns aren&#146;t looked for in expect strings unless explicitly requested with the <TT>\r</TT> character sequence in the expect string.</P>

<P>Most modems can report why a call failed when it gets a busy signal or can&#146;t detect a carrier. You can use the <TT>abort</TT> expect string to tell <TT>chat</TT> to fail if it receives the specified strings. Multiple abort pairs are cumulative. The following script is an example of using the <TT>abort</TT> expect string:</P>

<!-- CODE SNIP //-->

<PRE>

abort &#145;NO CARRIER&#146; abort &#145;BUSY&#146; ogin:--ogin: ppp word: be4me

</PRE>

<!-- END CODE SNIP //-->

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="566-568.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="571-573.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -