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

📄 455-460.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Using Linux:Managing Network Connections</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=0789716232//-->

<!--TITLE=Using Linux//-->

<!--AUTHOR=William Ball//-->

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

<!--IMPRINT=Que//-->

<!--CHAPTER=27//-->

<!--PAGES=455-460//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="451-455.html">Previous</A></TD>

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

<TD><A HREF="460-463.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P><FONT SIZE="+1"><B><I>Configuring an Ethernet interface</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Launch <TT>netcfg</TT>.

<DD><B>2.</B>&nbsp;&nbsp;Click the <B>Interfaces</B> button in the Network Configurator main window (refer to Figure 27.1).

<DD><B>3.</B>&nbsp;&nbsp;Click the <B>Add</B> button.

<DD><B>4.</B>&nbsp;&nbsp;In the Choose Interface window, click <B>Ethernet</B> to open the Edit Ethernet dialog box (see Figure 27.14).

<P><A NAME="Fig14"></A><A HREF="javascript:displayWindow('images/27-14.jpg',271,234 )"><IMG SRC="images/27-14t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/27-14.jpg',271,234)"><FONT COLOR="#000077"><B>Figure 27.14</B></FONT></A>&nbsp;&nbsp;Configure a new ethernet interface using the Edit Ethernet Interface window.</P>

<DD><B>5.</B>&nbsp;&nbsp;Click the IP field and type the IP address of the interface. If ethernet is your machine&#146;s primary interface, type the machine&#146;s IP address.

<DD><B>6.</B>&nbsp;&nbsp;Click the Netmask field and enter the network mask for the IP address entered in step 5.

<DD><B>8.</B>&nbsp;&nbsp;Click the <B>Activate interface at boot time</B> option.

<DD><B>9.</B>&nbsp;&nbsp;Unless you need the capability of booting remote machines using this interface as the address of the boot server, leave the Configure interface with BOOTP option unselected.

</DL>

<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Setting Up a Router</FONT></H4>

<P>The previous steps configure your ethernet interface, but for your machine to be able to talk to other machines, the routing must be set up. The following example covers setting up a machine to be a <I>router</I>. Client setups for Linux, Windows, and MacOS are covered in separate subsections.</P>

<P>For the purposes of the following examples, assume that the local network is the one shown in Figure 27.15 and that the <TT>eth0</TT> interface for <TT>kanchi</TT> has been configured with the parameters shown in Figure 27.14.</P>

<P><A NAME="Fig15"></A><A HREF="javascript:displayWindow('images/27-15.jpg',223,262 )"><IMG SRC="images/27-15t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/27-15.jpg',223,262)"><FONT COLOR="#000077"><B>Figure 27.15</B></FONT></A>&nbsp;&nbsp;This is a sample network, used to illustrate connecting hosts to a Linux machine.</P>

<P>The network illustrated in Figure 25.15 boasts four hosts, which will be used to demonstrate the process of configuring different types of machines to talk to a Linux machine acting as a router.

</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;<TT><I>doc</I></TT>. This is a Macintosh running system 8.1 with open transport. Its local IP address is 10.8.11.3.

<DD><B>&#149;</B>&nbsp;&nbsp;<TT><I>win</I></TT>. This is an x86 machine running Windows NT Workstation 4.0. Its local IP address is 10.8.11.7.

<DD><B>&#149;</B>&nbsp;&nbsp;<TT><I>kanchi</I></TT>. This main Linux machine is the router for all the other machines in the network. Its IP address is 10.8.11.2.

<DD><B>&#149;</B>&nbsp;&nbsp;<TT><I>melkote</I></TT>. This is a client Linux machine. Its local IP address is 10.8.11.4.

</DL>

<P>To configure <TT>kanchi</TT> to route packets for all machines, several routes must be added to the routing table, which helps the kernel keep track of where packets should be sent. The routing table is used to track three main types of routes:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;Host routes

<DD><B>&#149;</B>&nbsp;&nbsp;Network routes

<DD><B>&#149;</B>&nbsp;&nbsp;Default routes

</DL>

<P><FONT SIZE="+1"><B><I>Setting up routes</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;The first type of route you must set up is a host route to yourself. To do this, use the route command (while acting as root), as follows:

<!-- CODE SNIP //-->

<PRE>

   # route add -host 10.8.11.2 netmask 255.255.255.255 dev

   lo

</PRE>

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

<BR>This creates a route to the host 10.8.11.2 through the interface <TT>lo</TT> (loopback).

<DD><B>2.</B>&nbsp;&nbsp;Add a route to all hosts with IP addresses starting with <TT>10.</TT>:

<!-- CODE SNIP //-->

<PRE>

   # route add -net 10.0.0.0 netmask 255.0.0.0 dev eth0

</PRE>

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

<BR>The route that is created enables the computer to use the ethernet interface eth0 to communicate with all hosts that have an IP address of the form 10.<I>x.x.x</I>, where x is a number between 1 and 254. Some examples of valid IP address starting with 10. are 10.0.0.1 and 10.8.11.2.

<DD><B>3.</B>&nbsp;&nbsp;For all packets going to hosts without 10.<I>x.x.x</I> addresses, you must add the default route. In the case of this machine, the default route runs through itself, so you add it as follows:

<!-- CODE SNIP //-->

<PRE>

   <B># route add default gw 10.8.11.2 dev eth0</B>

</PRE>

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

</DL>

<P>Now that the main Linux machine, <TT>kanchi</TT>, is configured, you can configure the other machines.</P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">Connecting Two Linux Systems</FONT></H4>

<P>Connecting two Linux machines is easy. This is usually referred to as configuring one Linux machine to be the client of another. In this case, <TT>melkote</TT> as is configured to be a client of <TT>kanchi</TT>.</P>

<P><FONT SIZE="+1"><B><I>Configuring <I>melkote</I>

</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Make sure that <TT>melkote</TT>&#146;s <TT>lo</TT> and <TT>eth0</TT> interfaces have been configured properly.

<DD><B>2.</B>&nbsp;&nbsp;Add a route to the <TT>kanchi</TT> (10.8.11.2). This route will be used by the local machine for sending and receiving packets from <TT>kanchi</TT>. Entering the following at the command line adds a route to <TT>kanchi</TT> via the <TT>eth0</TT> interface:

<!-- CODE SNIP //-->

<PRE>

   <B># route add -host 10.8.11.2 netmask 255.255.255.255 dev

   eth0</B>

</PRE>

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

<DD><B>3.</B>&nbsp;&nbsp;For the local machine (<TT>melkote</TT>) to communicate with the other computers on the network, you must add the default route. The default route is used to communicate with hosts that do not have explicit entries in the routing table. To add the default route for <TT>melkote</TT> via <TT>kanchi</TT>, enter the following: 

<!-- CODE SNIP //-->

<PRE>

   <B>route add default gw 10.8.11.2 dev eth0</B>

</PRE>

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

<BR>This adds a default route for all packets to be sent to the router at 10.8.11.2 on your <TT>eth0</TT> interface. A program such as Telnet or PING will confirm if the routing is working properly.

</DL>

<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Connecting a MacOS Machine to a Linux System</FONT></H4>

<P>Connecting the machine <TT>doc</TT>, which runs MacOS as a <TT>kanchi</TT>, is straightforward under Open Transport.</P>

<P><FONT SIZE="+1"><B><I>Configuring <I>doc</I>

</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Click the <B>Apple</B> menu and select <B>Control Panels</B>.

<DD><B>2.</B>&nbsp;&nbsp;In the Control Panels window, select the TCP/IP icon. The TCP/IP screen shown in Figure 27.16 appears.

<P><A NAME="Fig16"></A><A HREF="javascript:displayWindow('images/27-16.jpg',468,334 )"><IMG SRC="images/27-16t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/27-16.jpg',468,334)"><FONT COLOR="#000077"><B>Figure 27.16</B></FONT></A>&nbsp;&nbsp;Configure TCP/IP on a computer running MacOS using the TCP/IP control panel.</P>

<DD><B>4.</B>&nbsp;&nbsp;Click <B>Connect via drop-down list</B> and select the <B>Ethernet built-in</B> option.

<DD><B>5.</B>&nbsp;&nbsp;Click <B>Configure drop-down list</B> and select the <B>Manually</B> option.

<DD><B>6.</B>&nbsp;&nbsp;In the IP Address field, enter <TT>doc</TT>&#146;s IP address (in this example, the IP address is 10.8.11.3).

<DD><B>7.</B>&nbsp;&nbsp;In the Subnet mask field, enter the network mask for the IP address entered in step 6.

<DD><B>8.</B>&nbsp;&nbsp;In the Router Address field, enter <TT>kanchi</TT>&#146;s address (10.8.11.2).

<DD><B>9.</B>&nbsp;&nbsp;Close the window to initialize the network by clicking the Close box in the upper-left side of the window.

</DL>



<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">

<TR><TD><FONT SIZE="+1"><B>Testing the connection</B></FONT>

<BR>To test the connection between <TT>doc</TT> and <TT>kanchi</TT>, try using the NCSA Telnet program.</TABLE>



<H4 ALIGN="LEFT"><A NAME="Heading13"></A><FONT COLOR="#000077">Connecting a Windows Machine to a Linux System</FONT></H4>

<P>Configuring a Windows machine is similar to configuring a Macintosh. This example demonstrates how to configure Windows NT; configuring Windows 95 (and, presumably, Windows 98) works in exactly the same way.

</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="451-455.html">Previous</A></TD>

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

<TD><A HREF="460-463.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 + -