0257-0259.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 407 行

HTML
407
字号


<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="0254-0256.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0260-0262.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-257"><P>Page 257</P></A>





<TABLE WIDTH="360">



<TR><TD>

dev ethn

</TD><TD>

Specifies the device onto which a routed packet should go. This

is useful only if you have a multihomed system (a machine

with multiple network cards). The ethn parameter specifies the

interface's name. This option should always be at the end of the command line.

</TD></TR>

</TABLE>









<H4><A NAME="ch13_ 14">

Examples of Using route

</A></H4>









<P>In this example, the default route is set up to go to

192.168.42.1, your router:

</P>





<!-- CODE SNIP //-->

<PRE>

route add -net default gw 192.168.42.1

</PRE>

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











<P>(You'll find that many routers are set up such that their IP addresses end in

.1. This isn't a rule, but a common practice.) Because this is a

-net, the netmask is automatically computed.

</P>









<P>Assuming your machine is set up as

192.168.42.12 with a netmask of 255.255.255.0, this

route points to your own local area network:

</P>





<!-- CODE SNIP //-->

<PRE>

route add -net 192.168.42.0 dev eth0

</PRE>

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











<P>This keeps the router from having to send packets back to your network after they've sent to

it as the default route. The last parameter, dev

eth0, specifies that the 192.168.42.0 network is connected to the first Ethernet device in the system.

</P>









<H4><A NAME="ch13_ 15">

Understanding the route Table

</A></H4>









<P>When route is invoked without a parameter, it displays your current routing table. The

output should look something like this:

</P>





<!-- CODE //-->

<PRE>

[root@denon /root]# route

Kernel IP routing table

Destination       Gateway       Genmask        Flags   Metric   Ref   Use   Iface

192.168.42.0      *             255.255.255.0  U       0        0     2     eth0

loopback          *             255.0.0.0      U       0        0     3     lo

default           192.168.42.1  0.0.0.0        UG      0        0     0     eth0

</PRE>

<!-- END CODE //-->











<P>Destination is the destination network or host address for packets, and

Gateway is the gateway host (typically a router) used to get to the destination. An

* character is displayed if no gateway is set. Flags describe the characteristic of the route. It is possible to have more than one

characteristic, as in the default route. The possible flags are

</P>



<TABLE WIDTH="360">



<TR><TD>

U

</TD><TD>

The route is up.

</TD></TR>

<TR><TD>

H

</TD><TD>

The route is a host.

</TD></TR>

<TR><TD>

G

</TD><TD>

The route is through a gateway.

</TD></TR>

</TABLE>





<P>Metric gives the route a weight, a lower weight being a faster route. This is useful only for

dynamic routing, so you will almost always see this as

0. The Ref column states the number of references to the route. Because this information is not used in the Linux kernel, it is always

0. Use tells you how many times this route has been looked up by your system.

Iface is the network interface the route uses.

</P>



<A NAME="PAGENUM-258"><P>Page 258</P></A>













<H3><A NAME="ch13_ 16">

The Domain Name Service

</A></H3>









<P>Up until now, I've been referring to hosts by their IP addresses. Although this might be

terribly convenient for the computers to use, we humans work much better with names.

Obviously, some sort of translation table is needed to convert IP addresses to hostnames. But

with millions of machines on the Internet and new ones popping up every day, it would be

impossible for everyone to keep this sort of table up-to-date. This is where DNS comes in.

</P>









<P>The Domain Name Service (DNS) is the protocol by which each site maintains only its

own mapping of IP addresses to machine names. Each site makes this mapping a publicly

queriable database so that when people from around the world want to find the corresponding IP

address, they simply query the correct database and get their answer.

</P>









<P>In order to access this database, you need to

run a DNS server for your site. (A DNS server is also known as a nameserver

or NS for short.) These servers come in three varieties:

primary, secondary, and caching. If you are connecting to an existing network (through your

campus network, for example), you will need to run only

a caching server. If, on the other hand, you are setting up a new site to be accessed through the Internet, you will need to set up a

primary server. Secondary servers become important as your site grows to the point that the

primary server can no longer handle the load and queries to it need to be broken up across

different machines.

</P>









<H4><A NAME="ch13_ 17">

Before DNS&#151;The /etc/hosts File

</A></H4>









<P>As your machine gets started, it will need to know the mapping of some hostnames to IP

addresses (for example, your NIS servers) before DNS can be referenced. This mapping is kept

in the /etc/hosts file.

</P>









<P>Following is a sample /etc/hosts file:</P>



<TABLE WIDTH="360">



<TR><TD>

<B>IP Address</B>

</TD><TD>

<B>Hostname</B>

</TD><TD>

<B>Alias</B>

</TD></TR>

<TR><TD>

127.0.0.1

</TD><TD>

localhost

</TD><TD>

</TD></TR>

<TR><TD>

192.168.42.7

</TD><TD>

vestax

</TD><TD>

www

</TD></TR>

<TR><TD>

192.168.42.8

</TD><TD>

mailhub

</TD><TD>

mailhub.domain.com

</TD></TR>

<TR><TD>

192.168.42.6

</TD><TD>

technics

</TD><TD>

</TD></TR>

</TABLE>













<P>The leftmost column is the IP address to be resolved. The next column is that host's

name. Any subsequent columns are aliases for that host. In the second line, for example, the

address 192.168.42.7 is for the host vestax. Another name for

vestax is www. The domain name is automatically appended to the hostname by the system; however, many people append it

themselves for clarity (for example,

www.domain.com).

</P>



<A NAME="PAGENUM-259"><P>Page 259</P></A>





<P>At the very least, you need to have the entries for</P>









<UL>

<LI>     Localhost



<LI>     Your NIS server



<LI>     Any systems from which you NFS mount disks



<LI>     The host itself

</UL>









<P>In this example, localhost is the first line, followed by

vestax, your WWW server. mailhub is the machine with which

sendmail communicates for mail, and finally there is

technics, the name of the machine from which the

/etc/hosts file came.

</P>









<H4><A NAME="ch13_ 18">

Configuring the DNS Client: /etc/resolv.conf

</A></H4>









<P>Every machine in your network is a DNS client. In order to know which DNS server to

use, you need to configure the /etc/resolv.conf file. This file should look something like

</P>





<!-- CODE SNIP //-->

<PRE>

search domain.com

nameserver 192.168.42.1

</PRE>

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











<P>where domain.com is the domain name of your site and the IP address listed after

nameserver is the address of the DNS server with which you will be communicating. You can have up

to three nameserver entries, each of which will be tried sequentially until one of them returns

an answer.

</P>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

NOTE

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

You must supply the nameserver's IP address, not its hostname. After all, how is the

resolver going to know what the nameserver's IP address is until it finds

the nameserver?

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

<BR>





<H4>The Software of DNS

</H4>









<P>While configuring DNS for your site, you will need to be familiar with the following tools:

</P>









<UL>



<LI>     named



<LI>     The resolver library



<LI>     nslookup



<LI>     traceroute

</UL>









<P>named is the daemon that needs to run on DNS servers to handle queries. If it cannot answer

a query, it is its responsibility to forward the request on to a server that can. Along with

queries, named is responsible for performing zone transfers. Zone transferring is the method by

which changed DNS information is propagated across the Internet. You will need to install the

named daemon from the BIND distribution, available from

<a href="http://www.redhat.com">http://www.redhat.com</A> or on the CD-ROM that comes with this book (filename

bind-4.9.5p1-2.i386.rpm).

</P>



<P><CENTER>

<a href="0254-0256.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0260-0262.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?