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

📄 651-653.html

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

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Networking</TITLE>

<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

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

<!--IMPRINT=Sams//-->

<!--CHAPTER=37//-->

<!--PAGES=651-653//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="648-650.html">Previous</A></TD>

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

<TD><A HREF="653-656.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>Messages sent using TCP/IP use the IP address to identify sending and receiving devices, as well as any routing information put within the message headers. If you are going to connect to an existing network, you should find out what their IP addresses are and what numbers you can use. If you are setting up a network for your own use but plan to connect to the Internet at some point, you should contact the Network Information Center for an IP Address. On the other hand, if you are setting up a network for your own use and don&#146;t plan to have more than a telephone connection to other networks (including the Internet), you can make up your own IP addresses.

</P>

<P>If you are only setting up a loopback driver, you don&#146;t even need an IP address. The default value for a loopback driver is <TT>127.0.0.1</TT>.</P>

<P><FONT SIZE="+1"><B>Network Mask</B></FONT></P>

<P>Next, you need a network mask. This is pretty easy if you have picked out an IP address. The network mask is the network portion of the IP address set to the value 255, and it&#146;s used to blank out the network portion to determine routing.

</P>

<P>If you have a Class C IP address (three bytes for network and one for devices), your network mask is <TT>255.255.255.0</TT>. A Class B network has a network mask of <TT>255.255.0.0</TT>, and a Class A network mask is <TT>255.0.0.0</TT>.</P>

<P>If you are configuring only a loopback driver, your network mask is <TT>255.0.0.0</TT> (Class A).</P>

<P><FONT SIZE="+1"><B>Network Address</B></FONT></P>

<P>The network address is, strictly speaking, the IP address bitwise-<TT>AND</TT>ed to the netmask. In English, what this means is that it&#146;s the network portion of your IP address, so if your IP address is <TT>147.120.46.7</TT> and it&#146;s a Class B network, the network address is <TT>147.120.0.0</TT>.</P>

<P>To get your own network address, just drop the device-specific part of the IP address and set it to zero. A Class C network with an IP address of <TT>201.12.5.23</TT> has a network address of <TT>201.12.5.0</TT>.</P>

<P>If you&#146;re working with only a loopback address, you don&#146;t need a network mask.</P>

<P><FONT SIZE="+1"><B>Broadcast Address</B></FONT></P>

<P>The broadcast address is used when a machine wants to send the same packet to all devices on the network. To get your broadcast address, you set the device portion of the IP address to 255. Therefore, if you have the IP address <TT>129.23.123.2</TT>, your broadcast address will be <TT>129.23.123.255</TT>. Your network address will be <TT>129.23.123.0</TT>.</P>

<P>If you are configuring only a loopback driver, you needn&#146;t worry about the broadcast address.</P>

<P><FONT SIZE="+1"><B>Gateway Address</B></FONT></P>

<P>The gateway address is the IP address of the machine that is the network&#146;s gateway out to other networks (such as the Internet). You need a gateway address only if you have a network that has a dedicated gateway out. If you are configuring a small network for your own use and don&#146;t have a dedicated Internet connection, you don&#146;t need a gateway address.

</P>

<P>Normally, gateways have the same IP address as your machines, but they have the digit 1 as the device number. For example, if your IP address is <TT>129.23.123.36</TT>, chances are that the gateway address is <TT>129.23.123.1</TT>. This convention has been used since the early days of TCP/IP.</P>

<P>Loopback drivers do not require a gateway address, so if you are configuring your system only for loopback, ignore this address.</P>

<P><FONT SIZE="+1"><B>Nameserver Address</B></FONT></P>

<P>Many larger networks have a machine whose purpose is to translate IP addresses into English-like names and vice versa. It is a lot easier to call a machine <TT>bobs_pc</TT> instead of <TT>123.23.124.23</TT>. This translation is done with a system called the Domain Name System (DNS). If your network has a name server, that&#146;s the address you need. If you want to have your own machine act as a name server (which requires some extra configuration not mentioned here), use the loopback address <TT>127.0.0.1</TT>.</P>

<P>Loopback drivers don&#146;t need a name server because the machine talks only to itself. Therefore, you can ignore the nameserver address if you are configuring only a loopback driver.</P>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Setting Up the Dummy Interface</FONT></H4>

<P>What&#146;s a <I>dummy interface</I>? It&#146;s a bit of a trick to give your machine an IP address to work with when it uses only SLIP and PPP interfaces. A dummy interface solves the problem of a standalone machine (no network cards connecting it to other machines) whose only valid IP address to send data to is the loopback driver (<TT>127.0.0.1</TT>). While SLIP and PPP may be used for connecting your machine to the outside world, when the interface is not active, you have no internal IP address that applications can use.</P>

<P>The problem arises with some applications that require a valid IP address to work. Some word processors and desktop layout tools, for example, require the TCP/IP system to be operational with an IP address for the target machine. The dummy interface essentially sets an IP address for your local machine that is valid as far as TCP/IP is concerned, but doesn&#146;t really get used except to fool applications.</P>

<P>Creating a dummy interface is very simple. If your machine has an IP address already assigned for it in the <TT>/etc/hosts</TT> file, all you need to do is set up the interface and create a route. The following two commands are required:</P>

<!-- CODE SNIP //-->

<PRE>

ifconfig dummy machine_name

route add <I>machine_name</I>

</PRE>

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

<P>Where <I>machine_name</I> is your local machine&#146;s name (such as <TT>darkstar</TT>). This creates a link to your own IP address. If you do not have an IP address for your machine in the <TT>/etc/hosts</TT> file, you should add one before you create the dummy interface.</P>

<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">Configuration Files</FONT></H4>

<P>Configuring Linux for TCP/IP is not difficult because only a few configuration files need to have the information about IP address and such added to them. You can do this with any editor, as long as it saves the files in ASCII format. It is advisable to make copies of the configuration files before you modify them, just in case you damage the format in some way.

</P>

<P>Many of these files are similar in every version of UNIX, including most versions of Linux, except for one or two slight naming variations. If you&#146;ve ever set up a UNIX system (or snooped around one in detail), these files and steps might seem familiar. If you haven&#146;t done anything with Linux or UNIX before, just take it one step at a time and follow the instructions.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="648-650.html">Previous</A></TD>

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

<TD><A HREF="653-656.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 + -