📄 0167-0169.html
字号:
<HTML>
<HEAD>
<TITLE>Sams Teach Yourself Linux in 24 Hours:Connecting to the Internet:EarthWeb Inc.-</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=0672311623 //-->
<!-- TITLE=Sams Teach Yourself Linux in 24 Hours//-->
<!-- AUTHOR=Bill Ball//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=10 //-->
<!-- PAGES=0161-0172 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0164-0166.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0170-0172.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-167"><P>Page 167</P></A>
<TABLE BGCOLOR=#FFFF99><TR><TD></TD></TR><TR><TD>
<BLOCKQUOTE>
must connect to a specific (static, or fixed) IP address, you'll need to remove
the noipdefault option from the pppd command line, and change the
$REMOTE_IP string to the IP address provided by your ISP (you can do this in the
pppd command line or further up in the script in the
$REMOTE_IP variable).
</BLOCKQUOTE>
</TD></TR></TABLE>
<P>Finally, make sure that the ppp-on and
ppp-on-dialer scripts are executable by checking with
ls -l, or modifying with the chmod program:
</P>
<!-- CODE SNIP //-->
<PRE>
# chmod +x /etc/ppp/ppp-on*
</PRE>
<!-- END CODE SNIP //-->
<P>You're now ready, assuming that your modem is connected to your computer, and
your phone line is connected to your modem, to try a connection.
</P>
<H3><A NAME="ch10_ 10">
Starting and Stopping PPP Connections
</A></H3>
<P>This section shows you how to connect to your ISP and start your Internet session.
There are several ways to do this. The first way you'll see is the most basic, simplest way to
connect with the minicom program without using the scripts you just created. Then you'll learn
how to use your PPP connection script, ppp-on.
</P>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
The minicom program, discussed in Hour 9, is a communications program
you can use to dial out and connect to other computers or information services,
such as bulletin board systems, or BBSs. See the
minicom manual page for more information.
</BLOCKQUOTE>
</TD></TR></TABLE>
<H4><A NAME="ch10_ 11">
Using minicom to Connect
</A></H4>
<P>Using minicom to connect with your ISP has an advantage because your account infor-<BR>
mation and password aren't recorded in the system logs under the
/var/log directory. You can use minicom each time you want to use the Internet, but you may find the process
tedious. I'm showing you this approach first, because you may find it useful in verifying that
the login and password entries you've specified in your
ppp-on-dialer script will work.
</P>
<P>Here is the step-by-step method. You can do this because
minicom can quit without resetting your modem. This means you can use
minicom to dial out, connect, and then quit,
allowing you to start your PPP session with the
pppd daemon. Here's how:
</P>
<OL>
<LI> Run minicom.
<LI> Type ATDT, followed by your ISP's modem number.
<LI> Wait for the connection, your ISP's prompt, then log in with your username
and password. Note whether the login and password prompts are different. If so,
</OL>
<A NAME="PAGENUM-168"><P>Page 168</P></A>
<OL START="4">
<DL>write them down so you'll have the information you need to edit the
chat program options in your ppp-on-dialer script.</DL>
<LI> Press Ctrl+Q to exit minicom without a modem reset.
<LI> From the command line, type the following:
</OL>
<!-- CODE SNIP //-->
<PRE>
# pppd -d detach /dev/modem &
</PRE>
<!-- END CODE SNIP //-->
<P>After a second or so, you're connected! (Well, you should check first—try some of
the programs discussed later.)
</P>
<H4><A NAME="ch10_ 12">
Using Your ppp-on Script to Connect
</A></H4>
<P>Using the ppp-on script to establish your PPP connection is easy. Make sure that
you're logged in as root, and type the following to start the connection:
</P>
<!-- CODE SNIP //-->
<PRE>
# /etc/ppp/ppp-on
</PRE>
<!-- END CODE SNIP //-->
<P>You'll notice that you have to type the entire pathname to the script. If you find
your connection works, you can move the script to the
/usr/local/bin directory, or make a symbolic link to the script with (you can call it whatever you want; just don't use
pppd)
</P>
<!-- CODE SNIP //-->
<PRE>
# ln -s /etc/ppp/ppp-on /usr/local/bin/start-ppp
</PRE>
<!-- END CODE SNIP //-->
<P>After you start the script, you should hear your modem connect to your phone line,
dial out, then connect with your ISP's modem. After several seconds, you should be connected!
</P>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
If you don't like the sound of your modem or find it disruptive (especially
if you have to work in a quiet environment), use your modem's AT command
set to turn off the modem's speaker. Run minicom, type
ATM0, press Enter, type AT&W, and then press Enter again to save the settings. Now you can
start stealth PPP connections!
</BLOCKQUOTE>
</TD></TR></TABLE>
<P><B>
Stopping the PPP Connection
</B></P>
<P>To stop your PPP session, use the ppp-off script, found in the
/etc/ppp directory. To use it, type
</P>
<!-- CODE SNIP //-->
<PRE>
# /etc/ppp/ppp-off
</PRE>
<!-- END CODE SNIP //-->
<P>This script works by finding your network interface,
ppp0, which you can test by using some of the programs in the next section and then using the
kill command to kill the process ID of ppp0 (the
kill command is discussed in the next hour).
</P>
<A NAME="PAGENUM-169"><P>Page 169</P></A>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
If you're interested in the details on setting up other serial-line connections,
such as Serial-Line IP, or SLIP, look under the
/usr/doc/slip-login-2.1.0.6 directory.
</BLOCKQUOTE>
</TD></TR></TABLE>
<H4><A NAME="ch10_ 13">
Checking the Connection
</A></H4>
<P>You can diagnose, troubleshoot, or get more information about your PPP connection
in a number of ways. You can use networking utility programs during your connection to
test, time, and diagnose the ppp0 interface. You can also examine system logs to look for
any problems occurring during startup, connecting, and disconnecting.
</P>
<P>This section introduces you to a few of these networking programs, and shows you
where to look in your system logs for more information.
</P>
<P><B>
Using the ifconfig Command
</B></P>
<P>Although the ifconfig command, found under the
/sbin directory, is generally used in network administration by the root operator to configure network interfaces (a skill not covered
in this book; see the Linux Network Administrators
Guide), you can use ifconfig to see the status of your PPP connection.
</P>
<P>This command can also be helpful when you're running programs, such as
newsreaders, which may appear "frozen," but are actually sending and receiving data, but not
displaying updates on your screen. To use ifconfig, just enter
</P>
<!-- CODE //-->
<PRE>
# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0
UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1
RX packets:17257 errors:0 dropped:0 overruns:0
TX packets:17257 errors:0 dropped:0 overruns:0
ppp0 Link encap:Point-Point Protocol
inet addr:207.226.80.52 P-t-P:207.226.80.4
Mask:255.255.255.0
UP POINTOPOINT RUNNING MTU:1500 Metric:1
RX packets:676 errors:0 dropped:0 overruns:0
TX packets:545 errors:0 dropped:0 overruns:0
</PRE>
<!-- END CODE //-->
<P>The command will list the current, active network interfaces. Look at the
ppp0 listing and you can see the number of bytes received and transmitted (in the form of packets) over
your PPP interface. Calling the program intermittently from another console or
terminal window under X will show you the progress of data being sent and received.
</P>
<P><B>
Using the netstat Command
</B></P>
<P><CENTER>
<a href="0164-0166.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0170-0172.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -