📄 0291-0294.html
字号:
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:TCP/IP Network Management</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=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=13 //-->
<!-- PAGES=0243-0298 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0287-0290.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0295-0298.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-291"><P>Page 291</P></A>
<OL START=7>
<LI> After you have the PPP information typed in, click the Customize button at
the bottom of the Create PPP Interface window. The Create PPP Interface
window closes, and the Edit PPP Interface window appears (see Figure 13.8).
</OL>
<BR>
Figure 13.8.<BR>
The Network<BR>
Configurator Edit PPP<BR>
Interface Hardware menu.<BR>
<a href="11rhu08.html"><img src="images/tn_11rhu08_jpg.jpg"></a><BR>
<OL START=8>
<LI> Make sure that the Use hardware flow control and modem lines entry and the
Abort connection on well-known errors entry are set and that Escape control characters
and Allow any user to (de)activate interface are not set.
<LI> In the Line speed: box, select the highest speed your computer can communicate
with the modem, not the highest speed the modem can communicate with
another modem. For most modems, this should be
115200.
<LI> For the Modem Port: box, use
/dev/modem. If you have not configured your modem with the
modemtool program yet, this is the time to do it.
</OL>
<P>At this point, your hardware is configured. Now to tackle the network aspects of the
configuration. Click the Networking button in the Edit PPP Interface window. The window will
change to look something like Figure 13.9.
</P>
<BR>
Figure 13.9.<BR>
The Network<BR>
Configurator Edit PPP<BR>
Interface Networking menu.<BR>
<a href="11rhu09.html"><img src="images/tn_11rhu09_jpg.jpg"></a><BR>
<P>You now have to make some important decisions:
</P>
<UL>
<LI> Do you want the PPP connection to automatically restart if it drops?
<LI> Do you want the PPP connection to automatically start at boot time?
</UL>
<P>If you answer yes to the first question, you will be unable to drop the PPP connection until
the system shuts down or you kill the pppd daemon with the
kill command. For a flaky
</P>
<A NAME="PAGENUM-292"><P>Page 292</P></A>
<P>connection, this is a very useful option because it will keep you from having to constantly
restart your connection.
</P>
<P>Answering yes to the second question is useful only if your account with your ISP is a
24-hours-a-day connection.
</P>
<P>To set your desired parameters, do the following:
</P>
<OL>
<LI> In the current Edit PPP Interface window, set the Activate interface at boot
time option and Restart PPP when connection fails option to your preferences. Keep
the second option, Set default route when making connection (defaultroute), set.
<LI> The MRU box stands for Maximum Receive Unit, which is
similar to the MTU of a network card. This option sets how much data is contained in a packet between
you and your ISP within the range of 296 bytes and 1500 bytes. If your telephone lines
are clear, set this number higher. Conversely, if your telephone line often has a lot
of static, you will want to set it to a lower number.
<LI> The last two options in the current Edit PPP Interface
window let you specify your IP address and your server's IP address. In most instances, your IP address is
dynamically assigned by your ISP; however, some ISPs offer a plan that gives you a static
IP address for a higher monthly cost. (This is useful if you need to keep a
continuous network connection going.) If you do have a static IP plan, your ISP will provide
these two numbers for you. Otherwise, leave them blank.
</OL>
<P>To complete the PPP setup, click Done. Another window will come up asking if
you want to save the current configuration. Click the Save button. The Edit PPP Interface window
will disappear and your original Network Configurator window will show the PPP interface,
as shown in Figure 13.10.
<P>
You are now ready to test your PPP connection. Click the Activate button at the bottom of
the Network Configurator window to start your PPP connection. You should hear your
modem dialing and connecting within a few moments. After it is connected, test the connection
by pinging your ISP's nameserver. A valid connection should look something like this:
</P>
<!-- CODE //-->
<PRE>
[root@technics /root]# ping -c 5 207.155.59.1
PING 207.155.59.1 (207.155.59.1): 56 data bytes
64 bytes from 207.155.59.1: icmp_seq=0 ttl=254 time=141.8 ms
64 bytes from 207.155.59.1: icmp_seq=1 ttl=254 time=140.4 ms
64 bytes from 207.155.59.1: icmp_seq=2 ttl=254 time=150.4 ms
64 bytes from 207.155.59.1: icmp_seq=3 ttl=254 time=140.3 ms
64 bytes from 207.155.59.1: icmp_seq=4 ttl=254 time=140.4 ms
--- 207.155.59.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 140.3/142.6/150.4 ms
</PRE>
<!-- END CODE //-->
<P>When you are done with your connection, click the Deactivate button in the
Network Configurator window. Be sure to click Save one last time before you click Quit.
</P>
<A NAME="PAGENUM-293"><P>Page 293</P></A>
<BR>
Figure 13.10.<BR>
The Network<BR>
Configurator Interfaces<BR>
menu with PPP<BR>
information.<BR>
<a href="11rhu10.html"><img src="images/tn_11rhu10_jpg.jpg"></a><BR>
<P>To bring your connection back up, simply run
netcfg, select Interfaces from the top menu, highlight the
ppp interface, and click Activate.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD>
<B>TIP</B>
</TD></TR>
<TR><TD>
<BLOCKQUOTE>
Instead of having to start the netcfg program every time you want to activate your
PPP connection, you can use command-line scripts in the
/etc/sysconfig/network-scripts directory. The command for starting PPP is
<BR>
<BR>
<!-- CODE SNIP //-->
<PRE>
./ifup-ppp ifcfg-ppp0 &
</PRE>
<!-- END CODE SNIP //-->
<BR>
<BR>
The command to shut down your PPP connection is
<BR><BR>
<!-- CODE SNIP //-->
<PRE>
./ifdown-ppp ifcfg-ppp0 &
</PRE>
<!-- END CODE SNIP //-->
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
<BR>
<H4>
On-Demand Dialing
</H4>
<P>As you become more Net savvy, you might find it useful to have your machine
automatically dial out to your ISP and log in whenever it detects a packet destined to a particular IP
address, for example, your ISP's nameserver.
</P>
<P>When the kernel tries to connect to an IP that it doesn't have a route for, it invokes the
script /sbin/request-route with the destination IP address.
request-route checks to see if it has a script corresponding to that address. If it does, the script is invoked, which presumably
starts the necessary connection to establish the desired route. In most instances, this would be
the PPP connection.
</P>
<A NAME="PAGENUM-294"><P>Page 294</P></A>
<P>There is, however, a slight limitation in the current setup. If you attempt to connect to an
IP that requires the PPP connection be up, but was not specifically set with
request-route so that the connection is started, the kernel will return an error to the calling program. To
circumvent this, you can use a slightly modified script that establishes a default script to
invoke for all IPs that cannot be reached. This feature is especially useful if you run your own nameserver.
</P>
<P>Before using a new request-route script, make a backup copy of the
original with the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
cp /sbin/request-route /sbin/request-route-orig
</PRE>
<!-- END CODE SNIP //-->
<P>Should you decide to return back to the original script, you can simply copy the
/sbin/request-route-orig script back to/sbin/request-route.
</P>
<P>Next, add the following line
</P>
<!-- CODE SNIP //-->
<PRE>
if [ ! -f $chatfile ] ; then chatfile=/etc/ppp/chat-default; fi
</PRE>
<!-- END CODE SNIP //-->
<P>to request-route after the line that reads
</P>
<!-- CODE SNIP //-->
<PRE>
chatfile=/etc/ppp/chat.$1
</PRE>
<!-- END CODE SNIP //-->
<P>With request-route ready, you need to provide it the script files necessary to invoke the
PPP connection. You've already configured PPP with the
netcfg tool, so the script is already done and just needs to be copied to
/etc/ppp like so:
</P>
<!-- CODE SNIP //-->
<PRE>
cp /etc/sysconfig/network-scripts/chat-ppp0 /etc/ppp/chat-default
</PRE>
<!-- END CODE SNIP //-->
<P>Doing this will set up your default PPP service. If for some reason you need to set up a
different network connection for a particular IP address, you can create a specific chat script for
that address and name it
/etc/ppp/chat.xxx.xxx.xxx.xxx, where
xxx.xxx.xxx.xxx is the IP address. The
request-route script will automatically pick the IP-specific script over the default script.
</P>
<P>By default, the PPP connection will automatically shut itself down after five minutes of
inactivity. You can change this by editing the
request-route script and changing the number after the string
idle-disconnect to however many seconds you want it to wait for before
automatically disconnecting.
</P>
<P>If you want to force a disconnection before the idle out period, you can simply kill the
pppd daemon. Do not use the -9 option on kill when doing so, however, because
pppd intercepts the standard termination signal and does cleanup work
before exiting.
</P>
<H3><A NAME="ch13_ 44">
Summary
</A></H3>
<P>As you've seen in this chapter, adding network access and networking tools to your system is
a fantastic asset. And with Red Hat Linux, sharing data through these networking tools is
relatively straightforward, which is impressive considering the power they add to your system.
</P>
<P><CENTER>
<a href="0287-0290.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0295-0298.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -