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

📄 tyt09fi.htm

📁 tcpip14study_14天学会TCPIP编程裁减移植_好书啊!
💻 HTM
📖 第 1 页 / 共 5 页
字号:

64 bytes from 127.0.0.1: icmp_seq=0.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=1.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=2.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=3.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=4.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=5.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=6.  ttl=255 time=1 ms

64 bytes from 127.0.0.1: icmp_seq=7.  ttl=255 time=1 ms

^C

--- localhost PING Statistics ---

7 packets transmitted, 7 packets received, 0% packet loss

round-trip (ms) min/avg/max = 1/1/1</FONT></PRE>

<P>The ping command's progress was interrupted by the user by issuing a Ctrl+C after seven transmissions. You can let as many transmissions as you want go by. If you get no replies from the ping command, then the address 127.0.0.1 or the name localhost wasn't recognized and you should check the configuration files and route entry again.

<BR>

<P>If the configuration files look correct and the route command was accepted properly, but the ping command still doesn't produce the proper results, you have a more serious problem. In some cases, the network kernel is not properly configured and the entire process must be conducted again. Sometimes a mismatch in versions of kernel drivers and network utilities can cause hang-ups with the ping routine, as well.

<BR>

<P>Next, you need to add the Ethernet drivers to the kernel. You can perform the same configuration process with the Ethernet driver. To begin, you set up the Ethernet interface using ifconfig. To make the interface active, use the ifconfig command with the Ethernet device name and your local IP address. For example, use the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ifconfig eth0 147.120.0.2</FONT></PRE>

<P>to set up the local machine with the IP address 147.120.0.2. The interface is to the Ethernet device /dev/eth0. You don't have to specify the network mask with the ifconfig command because it deduces the proper value from the IP address entered. If you want to provide the network mask value explicitly, append it to the command line with the keyword netmask:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">ifconfig eth0 147.120.0.2 netmask 255.255.255.0</FONT></PRE>

<P>You can then check the interface with the ifconfig command using the interface name:

<BR>

<PRE>

<FONT COLOR="#000080">$ ifconfig eth0

eth0         Link encap 10Mps: Ethernet Hwaddr

          inet addr 147.123.20.1 Bcast 147.123.1.255 Mask 255.255.255.0

          UP BROADCAST RUNNING  MTU 1500 Metric 1

          X packets:0 errors:0 dropped:0 overruns:0

          TX packets:0 errors:0 dropped:0 overruns:0</FONT></PRE>

<P>You might have noticed in the output from the command that the broadcast address was set based on the local machine's IP address. This is used by TCP/IP to access all machines on the local area network at once. The Message Transfer Unit (MTU) size is usually set to the maximum value of 1500 supported by Ethernet networks.

<BR>

<P>Next, you need to add an entry to the kernel routing tables that lets the kernel know about the local machine's network address. That lets it send data to other machines on the same network. The IP address that is used with the route command to do this is not your local machine's IP address, but that of the network as a whole without the local identifier. To set the entire local area network at once, the -net option of the route command is used. In the case of the IP addresses shown previously, the command would be as follows:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">route add -net 147.120.0</FONT></PRE>

<P>This adds all the machines on the network identified by the network address 147.120.0 to the kernel's list of accessible machines. If you didn't do it this way, you would have to manually enter the IP address of each machine on the network. An alternative method is to use the /etc/networks file, which can contain a list of network names and their IP addresses. If you have an entry in the /etc/networks file for a network called maclean_net, you could add the entire network to the routing table with this command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">route add maclean_net</FONT></PRE>

<P>Once the route has been added to the kernel routing tables, you can try the Ethernet interface out by pinging another machine, such as the SCO server you configured earlier.

<BR>

<P>Now you can configure the files used by TCP/IP, as you did for the SCO UNIX system configured earlier. Because many of the details of these files are identical to those shown in the SCO UNIX section, I skip a lot of the details here.

<BR>

<P>The /etc/hosts file is used to hold the network addresses and symbolic names, as well as the loopback driver. The loopback connection address is usually listed as the machine name loopback or localhost. The /etc/hosts file consists of the network address in one column and the symbolic name in another. Although the network addresses can be specified in decimal, octal, or hexadecimal format, decimal is the most commonly used form (and use of the others can be downright confusing). You can specify more than one symbolic name on a line by separating the names with white space characters (spaces or tabs). The Linux server /etc/hosts file on the sample network looks like this (remember that the Linux server is called freya and has an IP address of 147.120.0.2):

<BR>

<PRE>

<FONT COLOR="#000080"># network host addresses

127.0.0.1           localhost tpci

147.120.0.2         freya freya.tpci.com

147.120.0.1         merlin merlin.tpci.com

147.120.0.3         brutus brutus.tpci.com

147.120.0.4         megan megan.tpci.com_

147.120.0.10        whitney whitney.tpci.com

147.120.0.11        sinbad sinbad.tpci.com

147.120.0.12        pepper pepper.tpci.com</FONT></PRE>

<P>This file is essentially identical to that of the SCO UNIX server, because all the machines on the network have the same names and addresses. Because the localhost name is set to freya, the Linux server knows which entry in the file refers to itself.

<BR>

<P>The file /etc/protocols identifies all the transport protocols available on the Linux server and gives their respective protocol numbers. All systems have this file, although some entries might be commented out to prevent unwanted intrusion or abuse. With Linux the /etc/protocols file is not usually modified by the administrator. Instead, the file is maintained by the networking software and updated automatically as part of installation procedures. The file contains the protocol name, its number, and any alias that can be used for that protocol. The /etc/protocols file from the Linux server is shown here:

<BR>

<PRE>

<FONT COLOR="#000080"># protocols

ip       0    IP   # internet protocol, pseudo protocol number

icmp     1    ICMP # internet control message protocol

igmp     2    IGMP # internet group multicast protocol

ggp      3    GGP  # gateway-gateway protocol

tcp      6    TCP  # transmission control protocol

pup     12    PUP  # PARC universal packet protocol

udp     17    UDP  # user datagram protocol

idp     22    IDP  # WhatsThis?

raw    255    RAW  # RAW IP interface</FONT></PRE>

<P>The exact contents of the /etc/protocols file on your system might differ a little from the file shown here, but the protocol numbers and names are probably the same. There might be additional protocols listed, depending on your version of Linux and networking software.

<BR>

<P>The last TCP/IP configuration file used on most Linux systems identifies existing network services. This is /etc/services. As with the /etc/protocols file, this file is not usually modified by an administrator but is maintained by software when installed or configured. The /etc/services file is in ASCII format and consists of the service name, a port number, and the protocol type. The port number and protocol type are separated by a slash. Any optional service alias names follow. A short extract from a sample /etc/services file (the file is usually quite lengthy) is shown next:

<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>

<P>Most /etc/services files have many more lines, because a wide number of TCP/IP services are supported by most versions of Linux. Because you never have to worry about the contents of this file, you don't need to check each entry.

<BR>

<BR>

<A ID="E69E130" NAME="E69E130"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Configuring Solaris</B></FONT></CENTER></H4>

<BR>

<P>SunSoft Solaris 2.4 is a System V Release 4 version of UNIX, so it is configured very much like the SCO UNIX system configured earlier. The Ethernet interface and drivers are linked into the kernel when the operating system is loaded, so none of the device configuration should have to be modified. When the Solaris operating system is loaded, part of the configuration procedure asks for the name of the server and its IP address (in the sample network the name is brutus and the IP address is 147.120.0.3). 

<BR>

<P>These settings are then placed in the /etc/hosts file. You can use any ASCII editor to enter the rest of the machines on the sample network to complete the /etc/hosts file, as shown here:

<BR>

<PRE>

<FONT COLOR="#000080">#

# Internet Host Table

#

127.0.0.1           localhost

147.120.0.3         brutus brutus.tpci.com loghost

147.120.0.1         merlin merlin.tpci.com

147.120.0.2         freya freya.tpci.com

147.120.0.4         megan megan.tpci.com_

147.120.0.10        whitney whitney.tpci.com

147.120.0.11        sinbad sinbad.tpci.com

147.120.0.12        pepper pepper.tpci.com</FONT></PRE>

<P>The /etc/networks file on the SPARCstation server is similar to that on the SCO UNIX machine:

<BR>

<PRE>

<FONT COLOR="#000080">loopback       127

sco            132.147

sco-hq         132.147.128

sco-mfg        132.147.64

sco-engr       132.147.192

sco-slip       132.147.32

sco-tcplab     132.147.160

sco-odtlab     132.147.1

maclean_net    147.50.1

bnr.ca         47</FONT></PRE>

<P>In some cases, additional entries might exist for backward-compatibility reasons. You can add as many entries as you want to the /etc/networks file.

<BR>

<P>As with Linux, the /etc/services and /etc/protocols files are left alone, because they are supplied with all the configuration details already entered. These files can be modified if you need to disable a particular service (for security reasons, for example), but in most cases they are best left unmodified.

<BR>

<P>The SPARCstation was supplied with an RJ45 connector to the Ethernet network, so I used a transceiver to convert from RJ45 to a BNC connector. Passing through the transceiver converts the Ethernet connection to the mode you need. I could have wired the entire network with RJ45 connectors, but I would then need a hub to connect all the RJ45 connectors to (as I discussed on Day 1, &quot;Open Systems, Standards, and Protocols&quot;).

<BR>

<P>After the SPARCstation is connected to the network, you can try pinging a remote machine. If you get a proper response, all is well and you can move on to configuring other machines. If there is a problem with ping, you have to verify that all the files are correct, that the IP address is valid, and that the network transceiver is functioning properly.

<BR>

<BR>

<A ID="E69E131" NAME="E69E131"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Configuring Windows NT Server</B></FONT></CENTER></H4>

<BR>

<P>Windows NT is available in both server and workstation versions. Today I configure the server version for the sample network. I use Windows NT Server 3.51 on the sample system although Windows NT 4.0 performs in almost exactly the same way. (Windows NT 4.0 was still in beta as this book was being written; the only changes noticeable were because of the GUI modifications to resemble the Windows 95 GUI.) Although TCP/IP is provided with Windows NT, it is not installed as the default network protocol. Instead, IPX/SPX and NetBEUI are installed as default protocols. To configure TCP/IP, you need to extract the TCP/IP software from the distribution media if it hasn't already been installed. 

<BR>

<P>You can check for the presence of the TCP/IP software by opening the Network Settings window inside the Control Panel. This window is shown in Figure 9.2. The scroll list in the bottom left corner has a list of all installed components. If it does not include an entry such as TCP/IP Protocol, the TCP/IP software is not installed. To install the TCP/IP software, click the Add Software button on the Network Settings window.

<BR>

<P><B><A HREF="09tyt02.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/09tyt02.gif">Figure 9.2. The Windows NT Network Settings screen </B><B>shows all the components that are installed.</A></B>

<BR>

<P>When you select Add Software, the system checks for all the installed and available components (which can take some time), then displays the windows shown in Figure 9.3. After selecting TCP/IP to be installed, you can select the specific TCP/IP components and any other TCP/IP services you want to install from the window shown in Figure 9.4.

<BR>

<P><B><A HREF="09tyt03.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/09tyt03.gif">Figure 9.3. You can add the TCP/IP software to your </B><B>Windows NT system through this window.</A></B>

<BR>

<P><B><A HREF="09tyt04.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/09tyt04.gif">Figure 9.4. Select the components of the Windows NT </B><B>TCP/IP software that you want to install from this window.</A></B>

<BR>

<P>The server version of Windows NT offers several TCP/IP configuration options and extra services. Those shown in Figure 9.4 include the following:

<BR>

<UL>

<LI><B>TCP/IP Internetworking:</B> These must be installed for TCP/IP to function. It includes the drivers for TCP, IP, UDP, and ARP, as well as several other protocols like ICMP. PPP and SLIP are also provided through this option.

<BR></LI>

<BR>

<LI><B>Connectivity Utilities:</B> Utilities like finger, ping, telnet, and many others. These should be installed with all TCP/IP configurations.

<BR></LI>

<BR>

<LI><B>SNMP Service:</B> The SNMP drivers used to enable the server or workstation to be administered remotely. This option should be used if your Windows NT machine is to be managed by a remote UNIX workstation. The SNMP Service is also required if you want to run the Performance Monitor and obtain TCP/IP behavior statistics.

<BR></LI>

<BR>

<LI><B>TCP/IP Network Printing:</B> Enables network printers (those attached directly to the network cables instead of a PC) to be used. This option can also be used if you want to send all print requests on this machine to another machine for handling, such as a UNIX print server.

<BR></LI>

<BR>

<LI><B>FTP Server Service:</B> If you want to use FTP to transfer files from Windows NT, this service must be loaded.

<BR></LI>

<BR>

<LI><B>Simple TCP/IP Services:</B> Offers specialty services like Daytime, Echo, and Quote that are used by some applicatio

⌨️ 快捷键说明

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