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

📄 566-568.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=566-568//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="563-565.html">Previous</A></TD>

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

<TD><A HREF="568-570.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">Using <I>dip</I> with Static IP Addresses

</FONT></H4>

<P>Assigning individual IP addresses to each machine that uses a SLIP provider is very common. When your machine initiates a SLIP link to the remote host, <TT>dip</TT> configures the SLIP interface with this known address. Listing 29.1 is a <TT>dip</TT> script using static IP addresses for initiating a SLIP link from linux2.burwell.com to linux1.burwell.com.</P>

<P><B>Listing 29.1 A Sample <TT>dip</TT> Script for Using Static IP Addresses over SLIP</B></P>

<!-- CODE //-->

<PRE>

# Connect linux2 to linux1 using static IP Addresses

# Configure Communication Parameters

port /dev/cua1 # use modem on /dev/cua1 serial line

speed 38400

modem HAYES

reset                             # Send initialization string to modem

flush                             # Throw away modem response



get $local linux2                 # Set local IP address

get $remote linux1                # Set remote IP address



# Dial number for linux1 modem

dial 555-1234

if $errlvl != 0 goto error        # If the dial command fails, error out

wait CONNECT 75

if $errlvl != 0 goto error        # If we don&#146;t get a CONNECT string

# from the modem, error out



send \r\n                         # Wake up login program

wait ogin: 30                     # Wait 30 seconds for login prompt

if $errlvl != 0 goto error        # Error out if we don&#146;t get login prompt

send Slinux2\n                    # Send SLIP login name for linux2

wait ssword: 5                    # Wait 5 seconds for password prompt

if $errlvl != 0 goto error        # Error out if we don&#146;t get password

send be4me\n                      # Send password

wait running 30                   # Wait for indication that SLIP is up

if $errlvl != 0 goto error        # Otherwise error out



# We&#146;re in, print out useful information

print Connected to $remote with address $rmtip

default                           # Make this link our default route

mode SLIP                         # Turn on SLIP mode on our end



# Error routine in case things don&#146;t work

error:

print SLIP to $remote failed.

</PRE>

<!-- END CODE //-->

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>TIP:&nbsp;&nbsp;</B>Tracking SLIP accounts can be difficult. Traditionally, UNIX user accounts are assigned login names with all lowercase letters. Using the client machine name with a capital S added to the front as the login name for that machine&#146;s SLIP account makes tracking it easier and avoids login name collisions with normal user accounts.<HR></FONT>

</BLOCKQUOTE>

<P>The script in Listing 29.1 initializes the modem and sets the local and remote IP addresses for the SLIP link. If you use host names here, <TT>dip</TT> resolves them to their IP address equivalents. The script then dials the modem and works its way through the login sequence. When logged in and sure that the SLIP link is up on the remote host, the script has <TT>dip</TT> configure the routing table and then switch the serial line into SLIP mode.</P>

<P>If an error occurs, the error routine at the end of the script prints a warning message and aborts the script. <TT>dip</TT> is excellent about leaving the serial line in a reasonable state when it&#146;s done with it.</P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Using <I>dip</I> with Dynamic IP Addresses

</FONT></H4>

<P>As SLIP became more popular, the task of managing IP addressees for SLIP clients got more and more difficult. This problem got worse when terminal servers supporting SLIP came into use. Now, you might be assigned any one of a range of IP addresses, depending on which port the terminal server received your call. This led to changes in <TT>dip</TT> that captured IP address information from the incoming data on the serial line. Listing 29.2 is a <TT>dip</TT> script that captures the local and remote IP addresses from the serial line.</P>

<P><B>Listing 29.2 A Sample <TT>dip</TT> Script for Dynamic IP Addresses</B></P>

<!-- CODE //-->

<PRE>

# Connection script for SLIP to server with dynamic IP address

# assignment. The terminal server prints out:

#

# remote address is XXX.XXX.XXX.XXX the local address is YYY.YYY.YYY.YYY



# Set the desired serial port and speed.

port /dev/cua1

speed 38400



# Reset the modem and terminal line.

Reset

flush



# Prepare for dialing.

dial 555-1234

if $errlvl != 0 goto error

wait CONNECT 60

if $errlvl != 0 goto error



# We are connected. Login to the system.

login:

wait name: 10                         # Log in to system

if $errlvl != 0 goto error

send Slinux2\n                        # Send user ID

wait ord: 10

if $errlvl != 0 goto error

send be4me\n                          # Send password

if $errlvl != 0 goto error

get $remote remote 10                 # Get remote IP address

if $errlvl != 0 goto error

get $local remote 10                  # Get local IP address

if $errlvl != 0 goto error

done:

print CONNECTED to $remote with address $rmtip we are $local

default                               # Set routing

mode SLIP                             # Go to SLIP mode

goto exit

error:

print SLIP to $host failed.

exit

</PRE>

<!-- END CODE //-->

<P>The script in Listing 29.2 uses <TT>get $remote remote 10</TT> to watch the serial line and to capture the first thing that looks like an IP address in the <TT>$remote</TT> variable. The command times out in 10 seconds with an error if it doesn&#146;t see an IP address.</P>

<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Using <I>diplogin</I> to Provide SLIP Service

</FONT></H3>

<P>The <TT>dip</TT> program automates starting SLIP links from the client machine. Linux also supports incoming dial-up SLIP links. A few packages are available for doing this as well. You use the <TT>diplogin</TT> program here, which is really just another name for <TT>dip</TT>.</P>

<P>Providing SLIP service to others requires that you create a specific account for each person on your Linux box and configure that account correctly. You also need to write an /etc/diphosts file with appropriate information for each host that you&#146;re providing SLIP service for.</P>

<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Creating SLIP Accounts</FONT></H4>

<P>You can manually create the SLIP account or use the <TT>adduser</TT> script with appropriate responses to each question. Here&#146;s an example /etc/passwd entry for linux2.burwell.com in the passwd file on linux1.burwell.com:</P>

<!-- CODE SNIP //-->

<PRE>

Slinux2:IdR4gDZ7K7D82:505:100:linux2 SLIP Account:/tmp:/sbin/diplogin

</PRE>

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

<P>It&#146;s recommended that /tmp be used as the home directory for SLIP accounts to minimize security risks by preventing SLIP users from writing files into sensitive areas of your file system by default. Make sure that you use the correct path to the <TT>diplogin</TT> program.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="563-565.html">Previous</A></TD>

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

<TD><A HREF="568-570.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 + -