?? tyt07fi.htm
字號:
<HTML>
<HEAD>
<TITLE>tyt07fi.htm</TITLE>
<LINK REL="ToC" HREF="index.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/index.htm">
<LINK REL="Index" HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/htindex.htm">
<LINK REL="Next" HREF="tyt08fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt08fi.htm">
<LINK REL="Previous" HREF="tyt06fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt06fi.htm"></HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"><A ID="I0" NAME="I0"></A>
<P><P ALIGN=CENTER>
<A HREF="tyt06fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt06fi.htm" TARGET="_self"><IMG SRC="blanprev.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blanprev.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Previous Page"></A>
<A HREF="index.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/index.htm" TARGET="_self"><IMG SRC="blantoc.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blantoc.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="TOC"></A>
<A HREF="tyt08fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt08fi.htm" TARGET="_self"><IMG SRC="blannext.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blannext.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Next Page"></A>
<HR ALIGN=CENTER>
<P>
<UL>
<UL>
<UL>
<LI>
<A HREF="#E68E68" >Configuration Files</A></LI>
<UL>
<LI>
<A HREF="#E69E100" >Symbolic Machine Names: /etc/hosts</A></LI>
<LI>
<A HREF="#E69E101" >Network Names: /etc/networks</A></LI>
<LI>
<A HREF="#E69E102" >Network Protocols: /etc/protocols</A></LI>
<LI>
<A HREF="#E69E103" >Network Services: /etc/services</A></LI></UL>
<LI>
<A HREF="#E68E69" >Setting the Host Name</A></LI>
<LI>
<A HREF="#E68E70" >The Loopback Driver</A></LI>
<LI>
<A HREF="#E68E71" >Managing ARP</A></LI>
<LI>
<A HREF="#E68E72" >Using ifconfig</A></LI>
<LI>
<A HREF="#E68E73" >The inetd Daemon</A></LI>
<LI>
<A HREF="#E68E74" >The netstat Command</A></LI>
<UL>
<LI>
<A HREF="#E69E104" >Communications End Points</A></LI>
<LI>
<A HREF="#E69E105" >Network Interface Statistics</A></LI>
<LI>
<A HREF="#E69E106" >Data Buffers</A></LI>
<LI>
<A HREF="#E69E107" >Routing Table Information</A></LI>
<LI>
<A HREF="#E69E108" >Protocol Statistics</A></LI></UL>
<LI>
<A HREF="#E68E75" >The ping Utility</A></LI>
<LI>
<A HREF="#E68E76" >Tracing a Connection</A></LI>
<LI>
<A HREF="#E68E77" >Summary</A></LI>
<LI>
<A HREF="#E68E78" >Q&A</A></LI></UL></UL></UL>
<HR ALIGN=CENTER>
<A ID="E66E7" NAME="E66E7"></A>
<H1 ALIGN=CENTER>
<CENTER>
<FONT SIZE=6 COLOR="#FF0000"><B>— 7 —</B>
<BR><B>TCP/IP Configuration and Administration Basics</B></FONT></CENTER></H1>
<BR>
<P>Although TCP/IP works transparently for the user, occasionally communications seem to be slow and TCP/IP is suspected as the cause. Most users are impatient and expect things to happen right away, so delays for any reason lead to frustration. Rather than sit and wait, most users like to be able to verify that a connection to a remote machine is active and a delay is caused by network traffic instead of a system failure. At the least, most users would like to understand why a session is progressing slowly.
<BR>
<P>TCP/IP has several utility programs that provide status information and performance statistics. Also available are several debugging programs and options to enable a developer or knowledgeable user to trace a problem. This chapter examines the basic set of these tools. Although TCP/IP is a standard, there are many different implementations of the protocol family. Most versions have the basic toolset discussed today, although some might alter names and output to their own liking.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>
<IMG SRC="caution.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/caution.gif" WIDTH = 37 HEIGHT = 35>All network addresses and machine names in this chapter are chosen at random and do not represent any particular network. Because the network addresses used might correspond to a real network, you should not use them in any experimentation, or you might incur the wrath of a system administrator!</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Not all the commands shown in this chapter are available to regular users (as opposed to system administrators) on all systems, although some system administrators do enable some access to the utilities for checking connection and TCP/IP status. The commands are presented here to show the debugging and diagnostic capabilities available to the TCP/IP user and administrator. The commands are not covered in exhaustive detail but are intended to complete the TCP/IP picture for you. Many of these programs and utilities are seen again later in this book when I set up a sample TCP/IP network.
<BR>
<BR>
<A ID="E68E68" NAME="E68E68"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Configuration Files</B></FONT></CENTER></H3>
<BR>
<P>Several files are involved in the complete specification of network addresses and configuration for TCP/IP. For illustrative purposes, a UNIX system is used as the standard here, although a few other operating systems are mentioned as appropriate. Other operating systems use different filenames, but the purpose of the files is usually the same. You might have to check with your operating system documentation to identify the files used for each purpose.
<BR>
<P>UNIX allows comments on every line of these configuration files, as long as they are prefaced by a pound sign (#). If you see this character in your own system's configuration files, you should note that it is not part of an entry. With many operating systems, the default configuration files have many entries, most of which are commented out until the system administrator removes the comments.
<BR>
<P>You might not be able to examine the files or run the utilities mentioned in this chapter because of security restrictions. If you edit the configuration files, make sure you do not make any unintentional changes! Make backups of all the files before you make any changes to your systems.
<BR>
<A ID="E69E100" NAME="E69E100"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Symbolic Machine Names: </B><B><I>/etc/hosts</I></B></FONT></CENTER></H4>
<BR>
<P>Whenever a symbolic name is used as a target address by an application, there must be some method to resolve that name into a network address. An ASCII file is commonly used with the symbolic names matched to network addresses. This does not apply when the Yellow Pages (YP), Network Information Services (NIS), or the Domain Name Server (DNS) is used; they use their own configuration files.
<BR>
<P>On UNIX systems, the file /etc/hosts is used to hold the network addresses, as well as one special connection called the <I>loopback</I> (which is examined later in this chapter in the section titled "The Loopback Driver"). The loopback connection address is usually listed as the machine name loopback or localhost.
<BR>
<P>The file /etc/hosts consists of the network address in one column separated from the symbolic name in another. The network addresses can be specified in decimal, octal, or hexadecimal format (although decimal is the most common). More than one symbolic name can be specified on a line by separating the names with either space characters or tabs. The /etc/hosts file can be as long as necessary to contain all the symbolic names used on the local machine; they do not need to be presented in any order. A sample UNIX /etc/hosts file is as follows:
<BR>
<PRE>
<FONT COLOR="#000080"># network host addresses
127.0.0.1 localhost local tpci_server
157.40.40.1 tpci_sco1
157.40.40.2 tpci_sco2
157.40.40.3 tpci_hpws1
157.40.40.0 tpci_server tpci_main tpci
47.80.157.36 bnr.ca BNR bnr
191.13.123.4 kitty_cat
205.150.89.1 roy_maclean big_roy
210.24.47.128 bobs_machine</FONT></PRE>
<P>As you can see, the file is made up of two columns. The first column gives the IP address of a machine, and the second (separated by one or more whitespace characters) gives the machine's name. If several names can be used to identify the remote machine, they are listed on the same line, separated by whitespace. For example, the remote machine with IP address 205.150.89.1 can be addressed as either roy_maclean or big_roy. Whenever either of those names is used in a command (such as an FTP or Telnet application), this file is used to match to the proper IP address.
<BR>
<P>A system or network administrator can update the /etc/hosts file at any time, and changes are effective immediately (so the machine doesn't have to be rebooted to effect the changes). Whenever a symbolic name is specified by a user or an application, the /etc/hosts file is always searched first for a matching name, and the proper address is read from the same line.
<BR>
<P>Most TCP/IP implementations on other platforms have a similar type of file to resolve IP addresses from symbolic names. NetManage ChameleonNFS running on a Windows 3.<I>x</I> machine, for example, uses a Host Table to match names and IP addresses. The Host Table, shown in Figure 7.1, is a graphical front-end to a file equivalent to /etc/hosts on a UNIX machine.
<BR>
<P><B><A HREF="07tyt01.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/07tyt01.gif">Figure 7.1. ChameleonNFS uses a Host Table to match </B><B>symbolic names and IP addresses.</A></B>
<BR>
<BR>
<A ID="E69E101" NAME="E69E101"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Network Names: </B><B><I>/etc/networks</I></B></FONT></CENTER></H4>
<BR>
<P>Networks can be addressed by a symbolic name, just as machines are. To resolve the network names, another file is used that contains the corresponding network address. Typically, this file isn't accessed often, because few users want to address an entire network within their application. The network name resolution file's most common use is to specify the local network's name.
<BR>
<P>UNIX systems usually use the file /etc/networks to specify symbolic network names. The format of the file provides a network symbolic name, its network address, and any alias that might be used, in much the same format as the /etc/hosts table is used for specific machines. A sample /etc/networks file is shown here:
<BR>
<PRE>
<FONT COLOR="#000080"># local network names
tpci 146.1 tpci_network tpci_local
bnr 47.80 BNR bnr.ca
tmn 123.2.21
unique 89.123.23 UNIQUE
sco 132.147 SCO
loopback 127 localhost</FONT></PRE>
<P>The /etc/networks file layout is a little different from /etc/hosts in that the usual network name is given in the first column, followed by the IP network address, then any aliases.
<BR>
<P>The last entry in this example file gives the loopback name. The first entry specifies the local machine name, its network address, and any name variants. Using this file, an application that wanted to reach the network called UNIQUE could use that name and let the operating system resolve it to the IP network address 89.123.23.
<BR>
<P>Many implementations of TCP/IP on other platforms don't bother with a network name resolution file like this. Part of the reason is that the /etc/networks file has little use on a UNIX platform, and many single-user operating systems don't require the type of versatility a multiuser operating system like UNIX must supply to an entire network.
<BR>
<BR>
<A ID="E69E102" NAME="E69E102"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Network Protocols: </B><B><I>/etc/protocols</I></B></FONT></CENTER></H4>
<BR>
<P>Protocol numbers are used to identify the transport protocol to the receiving machine to enable proper decoding of the information within the datagram. With TCP/IP, the protocol number is embedded in the Internet Protocol header. A configuration file is usually used to identify all the transport protocols available on the system and their respective protocol numbers.
<BR>
<P>UNIX systems use the /etc/protocols file for this purpose. Usually, this file is not modified by the administrator but is maintained by the system and updated automatically as part of the installation procedure when new TCP/IP software or services are added. The /etc/protocols file contains the protocol name, its number, and any alias that might be used for that protocol. A sample /etc/protocols file is shown here:
<BR>
<PRE>
<FONT COLOR="#000080">#
# Internet (IP) protocols
#
ip 0 IP # internet protocol, pseudo protocol number
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # internet group management protocol
ggp 3 GGP # gateway-gateway protocol
tcp 6 TCP # transmission control protocol
egp 8 EGP # Exterior-Gateway Protocol
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hello 63 HELLO # HELLO Routing Protocol
ospf 89 OSPF # Open Shortest Path First Routing Protocol</FONT></PRE>
<P>In this /etc/protocols file, the IP protocol is assigned protocol 0, and TCP is protocol 6. The values in this table should not be changed from their default values except when special network conditions mandate a change. If new TCP/IP services are added to the UNIX system this file resides on, new entries are made to this file by the application installation routine.
<BR>
<P>There are usually no equivalents of the /etc/protocols file on other operating systems because they assume that the standard transport number is used for each protocol.
<BR>
<BR>
<A ID="E69E103" NAME="E69E103"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Network Services: </B><B><I>/etc/services</I></B></FONT></CENTER></H4>
<BR>
<P>The final common configuration file used on most UNIX systems identifies the existing network services. As with the /etc/protocols file, this file is not usually modified by an administrator but is maintained by software as it is installed or configured.
<BR>
<P>The UNIX network services file is /etc/services. The file is in ASCII format consisting of the service name, a port number, and the protocol type. The port number and protocol type are separated by a slash. The port numbers for TCP/IP usually follow the conventions mentioned in the previous chapters. Any optional service alias names follow after the port numbers. A short extract from a sample /etc/services file (the file is usually quite lengthy) is shown here:
<BR>
<PRE>
<FONT COLOR="#000080"># network services
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp mail mailx
tftp 69/udp
# specific services
login 513/tcp
who 513/udp whod</FONT></PRE>
<BR>
<A ID="E68E69" NAME="E68E69"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Setting the Host Name</B></FONT></CENTER></H3>
<BR>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -