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

📄 488-491.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:Configuring a TCP/IP Network</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=24//-->

<!--PAGES=488-491//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="486-488.html">Previous</A></TD>

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

<TD><A HREF="491-493.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>This causes <TT>ifconfig</TT> to activate Ethernet interface 0, look up the IP address for linux1 in the /etc/hosts file, and assign it to this interface. Examining the <TT>eth0</TT> interface at this point reveals the following code:</P>

<!-- CODE SNIP //-->

<PRE>

$ <B>ifconfig eth0</B>

eth0      Link encap 10Mbps Ethernet HWaddr 00:00:E1:54:3B:82

          inet addr 166.82.1.21Bcast166.82.1.255 Mask 255.255.255.0

          UP BROADCAST RUNNING MTU 1500 Metric 0

          RX packets 3136 errors 217 dropped 7 overrun 26

          TX packets 1752 errors 25 dropped 0 overrun 0

          Interrupt:10 Base address:0x300

</PRE>

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

<P>Note that the broadcast address and netmask were set automatically by <TT>ifconfig</TT> based on the IP address it found in /etc/hosts. If you&#146;re using subnetworks, you need to specify the broadcast address and netmask explicitly. For example, if you have a class C network and are using the first bit in the host portion of the address to make two subnetworks, you must specify the broadcast address and netmask when running <TT>ifconfig</TT> :</P>

<!-- CODE SNIP //-->

<PRE>

ifconfig eth0 linux1 broadcast 166.82.1.127 netmask 255.255.255.128

</PRE>

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

<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Configuring Parallel IP Interfaces</FONT></H4>

<P>The Parallel IP (PLIP), Serial Line IP (SLIP), and Point-to-Point Protocol (PPP) interfaces are managed by <TT>ifconfig</TT> somewhat differently. To bring up a PLIP interface, you add the <TT>pointopoint</TT> option to the <TT>ifconfig</TT> command line. Assume that the Burwell laptop linux2 is attached to the first parallel port on linux1. You call <TT>ifconfig</TT> as follows to activate the PLIP link:</P>

<!-- CODE SNIP //-->

<PRE>

ifconfig plip0 linux1 pointopoint linux2

</PRE>

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

<P>This activates the <TT>plip0</TT> interface with the IP address for linux1, sets the <TT>pointopoint</TT> flag, and tells the interface that the IP address for the other end of the link is linux2. <TT>ifconfig</TT> looks up the IP addresses for linux1 and linux2 in /etc/hosts and assigns the addresses appropriately. On a laptop, you use the analogous call</P>

<!-- CODE SNIP //-->

<PRE>

ifconfig plip0 linux2 pointopoint linux1

</PRE>

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

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR>&#149; <B>See</B> See &#147;Understanding the Requirements for SLIP and PPP,&#148;<B>p. 562</B><HR></FONT>

</BLOCKQUOTE>

<H3><A NAME="Heading10"></A><FONT COLOR="#000077">Understanding TCP/IP Routing</FONT></H3>

<P>Routing determines the path a packet takes from its source through the network to its destination. This path is determined by matching the destination IP address against the kernel routing tables and transmitting the packet to the indicated machine, which may or may not be the destination of the packet. The kernel routing table contains information in the form &#147;To get to network X from machine Y, send the packet to machine Z with a cost of 1,&#148; along with time-to-live and reliability values for that route.

</P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Deciding On a Routing Policy</FONT></H4>

<P>The first step in setting up routing on your network is deciding on a routing policy. For small, unconnected networks, using the <TT>route</TT> command to set up static routes on each machine at boot time is sufficient. Large networks with many subnets or networks connected to the Internet need to use dynamic routing. The routing program provides dynamic routing by communicating with routing programs on other machines and installing routes based on what it learns about the topology of the network.</P>

<P>A very common strategy combines static and dynamic routing. Machines on each subnet use static routing to reach their immediate neighbors. The default route&#151;the route used for packets that match no other route in the routing table&#151;is set to a gateway machine that&#146;s doing dynamic routing and knows about the rest of the world. Large networks can be constructed this way, minimizing the hassle of configuration files and the amount of bandwidth used by the dynamic routing programs.</P>

<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Using the /sbin/route Program</FONT></H4>

<P>The /sbin/route program manipulates the kernel routing table and is used to set static routes to other computers or networks via interfaces that have been configured and activated by <TT>ifconfig.</TT> This is normally done at boot time by the /etc/rc.d/rc3.d/S10network script. Table 24.3 describes the command-line arguments for /sbin/route.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.3</B> Command-Line Arguments for /sbin/route

<TR>

<TH COLSPAN="2"><HR>

<TR>

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

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

<TR>

<TD COLSPAN="2"><HR>

<TR>

<TD VALIGN="TOP">(None)

<TD>Giving no option to /sbin/route causes it to output the current routing table.

<TR>

<TD VALIGN="TOP"><TT>-n</TT>

<TD>This argument causes the same output as giving no option, but replaces host names with their numerical IP addresses.

<TR>

<TD VALIGN="TOP"><TT>del</TT>

<TD>This argument deletes the route for the specified destination address from the routing table.

<TR>

<TD VALIGN="TOP"><TT>add</TT>

<TD>This argument adds to the routing table a route to the specified address or network.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P><FONT SIZE="+1"><B>Examining the Kernel Routing Table</B></FONT></P>

<P>Running /sbin/route without any command-line arguments or just <TT>-n</TT> outputs the routing table:</P>

<!-- CODE SNIP //-->

<PRE>

/sbin/route

Kernel routing table

Destination Gateway Genmask   Flags Metric Ref UseIface

127.0.0.0   *       255.0.0.0 U     0      0   100 lo

</PRE>

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

<P>This is from a machine with just the loopback interface activated. Table 24.4 describes the fields in the routing table report.

</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.4</B> The Fields in the Routing Table Report</B>

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="25%" ALIGN="LEFT">Field

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

<TR>

<TD COLSPAN="2"><HR>

<TR>

<TD><TT>Destination</TT>

<TD>The destination IP address of the route.

<TR>

<TD VALIGN="TOP"><TT>Gateway</TT>

<TD>The host name or IP address of the gateway the route uses. If there&#146;s no gateway, an asterisk is output.

<TR>

<TD VALIGN="TOP"><TT>Genmask</TT>

<TD>The netmask for the route. The kernel uses this to set the generality of a route by bitwise ANDing the <TT>Genmask</TT> against a packet&#146;s IP address before comparing it to the destination IP address of the route.

<TR>

<TD VALIGN="TOP"><TT>Flags</TT>

<TD>The flags for the route (<TT>U</TT> means up, <TT>H</TT> means host, <TT>G</TT> means gateway, <TT>D</TT> means dynamic route, and <TT>M</TT> means modified).

<TR>

<TD VALIGN="TOP"><TT>Metric</TT>

<TD>The metric cost for the route. This isn&#146;t currently supported in the kernel networking layer.

<TR>

<TD VALIGN="TOP"><TT>Ref</TT>

<TD>The number of other routes that rely on the presence of this route.

<TR>

<TD><TT>Use</TT>

<TD>The number of times the routing table entry has been used.

<TR>

<TD><TT>Iface</TT>

<TD>The network interface to which this route delivers packets.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="486-488.html">Previous</A></TD>

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

<TD><A HREF="491-493.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 + -