667-669.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 103 行

HTML
103
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:SLIP and PPP</TITLE>

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

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

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

<!--IMPRINT=Sams//-->

<!--CHAPTER=38//-->

<!--PAGES=667-669//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="665-667.html">Previous</A></TD>

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

<TD><A HREF="669-672.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Configuring SLIP</FONT></H4>

<P>For SLIP connections, two Linux programs are involved: <TT>dip</TT> and <TT>slattach</TT>. Both programs can be used to initiate the SLIP connection. You cannot dial into a SLIP line with a standard communications program because of the special system calls that SLIP uses.</P>

<P><TT>dip</TT> and <TT>slattach</TT> have different purposes. The <TT>slattach</TT> program, which simply connects to the serial device, is used when there is a permanent connection to the SLIP server (no modem or setup handshaking is required). The <TT>dip</TT> program handles the initiation of the connection, the login, and connection handshaking. If you use a modem to connect to a SLIP server, you should use <TT>dip</TT>. The <TT>dip</TT> program can also be used to configure your own system as a SLIP server, allowing others to call in to it.</P>

<P>SLIP is a fairly simple network protocol because only two devices are involved: yours and the server&#146;s. When the connection is established, SLIP sends an IP address that will be used for that connection. Some systems use the same IP address (static), while others have a different IP address each time a connection is made (dynamic). The configuration is slightly different for each type.</P>

<P>The easiest way to dedicate a serial port for SLIP is the <TT>slattach</TT> program. This command is supported by most Linux versions. The <TT>slattach</TT> command takes the device name of the serial port as an argument. For example, to dedicate the second serial port (<TT>/dev/cua1</TT> or <TT>/dev/tty2A</TT>, depending on the operating system) to SLIP, issue the following command or a similar command with the proper device name instead of /<TT>dev/cua1</TT> (which is the Linux convention for modem serial ports):</P>

<!-- CODE SNIP //-->

<PRE>

slattach /dev/cua1 &#38;

</PRE>

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

<P>The <TT>slattach</TT> command is sent into background mode by the ampersand. Failure to send to background means the terminal or the console the command is issued from is not usable until the process is terminated. You can embed the <TT>slattach</TT> command in a startup file such as the <TT>rc</TT> files or a session shell startup file if you want.</P>

<P>Once the <TT>slattach</TT> command has executed successfully, the serial port is set to the first SLIP device (usually <TT>/dev/sl0</TT>). If you are using more than one serial port for SLIP lines, you need to issue the command for each line. By default, most Linux systems set the SLIP port to use CSLIP (compressed SLIP). If you want to override this action, use the <TT>-p</TT> option and this device name:</P>

<!-- CODE SNIP //-->

<PRE>

slattach -p slip /dev/cua1 &#38;

</PRE>

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

<P>It&#146;s important to make sure that both ends of the connection use the same form of SLIP. There is <TT>slip6</TT> (a 6-bit version of SLIP) and adaptive SLIP (which adjusts to whatever is at the other end of the connection). For example, you cannot set your device for CSLIP and communicate with another machine running 6-bit SLIP.</P>

<P>After the serial port is set for SLIP usage, configure the network interface using the same procedure as normal network connections. For Linux, the commands used are <TT>ifconfig</TT> and <TT>route</TT>. For example, if your machine is called <TT>merlin</TT> and you are calling the remote machine <TT>arthur</TT>, issue the following commands:</P>

<!-- CODE SNIP //-->

<PRE>

ifconfig sl0 merlin-slip pointopoint arthur

route add arthur

</PRE>

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

<P>The <TT>ifconfig</TT> command above configures the interface <TT>merlin-slip</TT> (the local address of the SLIP interface) to be a point-to-point connection to <TT>arthur</TT>. The <TT>route</TT> command adds the remote machine called <TT>arthur</TT> to the routing tables.</P>

<P>If you want to use the SLIP port for access to the Internet, it must have an IP address and an entry in the <TT>/etc/hosts</TT> file. That gives the SLIP system a valid entry on the Internet.</P>

<P>After the <TT>ifconfig</TT> and <TT>route</TT> commands execute, you can test and use your SLIP network. If you decide to remove the SLIP interface in the future, you must first remove the routing entry, use <TT>ifconfig</TT> to take down the SLIP interface, and then kill the <TT>slattach</TT> process. The first two steps are done with these commands:</P>

<!-- CODE SNIP //-->

<PRE>

route del arthur

ifconfig sl0 down

</PRE>

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

<P>The termination of the <TT>slattach</TT> process must be done by finding the process ID (PID) of <TT>slattach</TT> (with the <TT>ps</TT> command), and then issuing a <TT>kill</TT> command. (See Chapter 34, &#147;Processes,&#148; for more information on killing a process if you are unsure of the method.)</P>

<P>If you have a dedicated connection to the SLIP server and you want to use <TT>slattach</TT>, the <TT>rc.inet1</TT> file is modified to have the following lines in it:</P>

<!-- CODE SNIP //-->

<PRE>

IPADDR=&#148;123.12.3.1&#148;     # Your machine&#146;s IP address

REMADDR=&#148;142.12.3.12&#148;   # The SLIP server IP address



slattach -p cslip -s 19200 /dev/ttyS0   # set baud and port as needed

/etc/ifconfig sl0 &#36;IPADDR pointopoint &#36;REMADDR up

/etc/route add default gw &#36;REMADDR

</PRE>

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

<P>These lines, or very similar lines, appear in most <TT>rc.inet1</TT> or <TT>rc.inet</TT> files, usually commented out. Amend the information to show the proper IP addresses, ports, and baud rates. The <TT>cslip</TT> argument for <TT>slattach</TT> tells the program to use <TT>slip</TT> with header compression. If this causes problems, change it to <TT>slip</TT>.</P>

<P>If the SLIP server you are connecting to allocates IP addresses dynamically, you can&#146;t put an IP address in the configuration files because it changes each time. Most SLIP servers display a message with the IP address when you connect, and <TT>dip</TT> can capture these numbers and use them to alter the system parameters appropriately.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="665-667.html">Previous</A></TD>

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

<TD><A HREF="669-672.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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