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

📄 656-658.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=656-658//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

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

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

<TD><A HREF="659-661.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>One other daemon you might want running is <TT>syslogd</TT>. It usually is set to execute automatically. This is the system logging daemon, which collects log messages from other applications and stores them in log files. The log file locations, which you can change as you desire, are given in the file <TT>/etc/syslog.conf</TT>.</P>

<P>That&#146;s enough changes to the <TT>rc</TT> files for now. After TCP/IP is installed and tested, the rest of the daemons (<TT>routed</TT>, <TT>named</TT>, and so on) can be started one at a time to ensure they work. The first task is to get TCP/IP communicating with other machines properly. Then you tweak it!</P>

<P><FONT SIZE="+1"><B>/etc/hosts</B></FONT></P>

<P>The <TT>/etc/hosts</TT> file is a simple list of IP addresses and the hostnames to which they correspond. This is a good location to list all your favorite machines so that you can use the name and have the system look up the IP address. On very small networks, you can add all the machines in the network here and avoid the need to run the <TT>named</TT> daemon.</P>

<P>Every <TT>/etc/hosts</TT> file will have an entry for <TT>localhost</TT> (also called <TT>loopback</TT>, IP address <TT>127.0.0.1</TT>) and probably one for your machine if you named it when you installed the software. If you didn&#146;t supply a name and there is no line other than <TT>localhost</TT>, you can add it now. Use an editor and set your IP address and machine name. Don&#146;t bother adding too many other machines until you&#146;re sure the network works properly! Here&#146;s a sample <TT>/etc/hosts</TT> file:</P>

<!-- CODE SNIP //-->

<PRE>

127.0.0.1     localhost

147.12.2.42    merlin.tpci merlin

</PRE>

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

<P>You will notice that the format is quite simple: an IP address in one column and the name in another column, separated by tabs. If the machine may have more than one name, supply them all. In the example, which uses random numbers for the IP address, the machine <TT>147.12.2.42</TT> has the name <TT>merlin</TT>. Because it is also part of a larger network called <TT>tpci</TT>, the machine can be addressed as <TT>merlin.tpci</TT>. Both names on the line ensure that the system can resolve either name to the same address.</P>

<P>You can expand the file a little if you want by adding other machines on your local network, or those you will communicate with regularly:</P>

<!-- CODE SNIP //-->

<PRE>

127.0.0.1       localhost

147.12.2.42     merlin.tpci merlin

147.12.2.43     wizard.tpci wizard

147.12.2.44     arthur.tpci arthur bobs_machine

147.12.2.46     lancelot.tpci lancelot

</PRE>

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

<P>In this example, there are several machines from the same network (the same network address). One has three different names.

</P>

<P>If you are using only the loopback driver, the only line that should be in the file is for the IP address <TT>127.0.0.1</TT> with the name <TT>localhost</TT> and your machine&#146;s name after it.</P>

<P><FONT SIZE="+1"><B>/etc/networks</B></FONT></P>

<P>The <TT>/etc/networks</TT> file lists names and IP address of your own network and other networks you connect to frequently. This file is used by the <TT>route</TT> command, started through the <TT>rc.inet1</TT> file. One advantage of this file is that it lets you call remote networks by name, so instead of typing <TT>149.23.24</TT>, you can type <TT>eds_net</TT>.</P>

<P>The <TT>/etc/networks</TT> file should have an entry for every network that will be used with the <TT>route</TT> command. If there is no entry, errors will be generated, and the network won&#146;t work properly.</P>

<P>A sample <TT>/etc/networks</TT> file using random IP addresses is shown next. Remember that you need only the network address and not the device portion of a remote machine&#146;s IP address, although you must fill in the rest with zeros.</P>

<!-- CODE SNIP //-->

<PRE>

loopback         127.0.0.0

localnet         147.13.2.0

eds_net          197.32.1.0

big_net          12.0.0.0

</PRE>

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

<P>At a minimum, you must have a loopback and <TT>localnet</TT> address in the file.</P>

<P><FONT SIZE="+1"><B>/etc/host.conf</B></FONT></P>

<P>The system uses the <TT>host.conf</TT> file to resolve hostnames. It usually contains two lines that look like this:</P>

<!-- CODE SNIP //-->

<PRE>

order hosts, bind

multi on

</PRE>

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

<P>These tell the system to first check the <TT>/etc/hosts</TT> file, and then the nameserver (if one exists) when trying to resolve a name. The <TT>multi</TT> entry lets you have multiple IP addresses for a machine in the <TT>/etc/hosts</TT> file (which happens with gateways and machines on more than one network).</P>

<P>If your <TT>/etc/host.conf</TT> file looks like these two lines, you don&#146;t need to make any changes at all.</P>

<P><FONT SIZE="+1"><B>resolv.conf</B></FONT></P>

<P>The <TT>resolv.conf</TT> file is used by the name resolver program. It gives the address of your name server (if you have one) and your domain name (if you have one). You have a domain name if you are on the Internet.</P>

<P>A sample <TT>resolv.conf</TT> file for the system <TT>merlin.tpci.com</TT> has an entry for the domain name, which is <TT>tpci.com</TT> (<TT>merlin</TT> is the name of an individual machine):</P>

<!-- CODE SNIP //-->

<PRE>

domain tpci.com

</PRE>

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

<P>If a name server is used on your network, you should add a line that gives its IP address:

</P>

<!-- CODE SNIP //-->

<PRE>

domain tpci.com

nameserver 182.23.12.4

</PRE>

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

<P>If there are multiple name servers, which is not unusual on a larger network, each name server should be specified on its own line.

</P>

<P>If you don&#146;t have a domain name for your system, you can safely ignore this file for the moment.</P>

<P><FONT SIZE="+1"><B>/etc/protocols</B></FONT></P>

<P>UNIX systems use the <TT>/etc/protocols</TT> file to identify all the transport protocols available on the system and their respective protocol numbers. (Each protocol supported by TCP/IP has a special number, but that&#146;s not really important at this point.) Usually, this file is not modified but is maintained by the system and updated automatically as part of the installation procedure when new software is added.</P>

<P>The <TT>/etc/protocols</TT> file contains the protocol name, its number, and any alias that may be used for that protocol. A sample <TT>/etc/protocols</TT> file looks like this:</P>

<!-- CODE //-->

<PRE>

# Internet protocols (IP)

ip     0   IP

icmp   1   ICMP

ggp    3   GGP

tcp    6   TCP

egp    8   EGP

pup    12  PUP

udp    17  UDP

hello  63  HELLO

</PRE>

<!-- END CODE //-->

<P>If your entries don&#146;t match this, don&#146;t worry. You shouldn&#146;t have to make any changes to this file at all, but you should know what it does.

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

<CENTER>

<TABLE BORDER>

<TR>

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

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

<TD><A HREF="659-661.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 + -