659 661




Linux Unleashed, Third Edition:Networking





-->















Previous
Table of Contents
Next




/etc/services
The /etc/services file identifies the existing network services. This file is maintained by software as it is installed or configured.
This file consists of the service name, a port number, and the protocol type. The port number and protocol type are separated by a slash, following the conventions mentioned in previous chapters. Any optional service alias names follow. Here’s a short extract from a sample /etc/services file:


# 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


You shouldn’t change this file at all, but you do need to know what it is and why it is there to help you understand TCP/IP a little better.

/etc/hostname or /etc/HOSTNAME
The file /etc/hostname or /etc/HOSTNAME is used to store the name of the system you are on. (Slackware Linux uses the uppercase version of the name.) This file should have your local machine’s name in it:


merlin.tpci


That’s all it needs. The hostname is used by most protocols on the system and many applications, so it is important for proper system operation. The hostname can be changed by editing the system file and rebooting the machine, although many distributions provide a utility program to ensure that this process is performed correctly.

Linux systems have a utility called hostname, which displays the current setting of the system name, as well as the uname program, which can give the node name with the command uname -n. When issued, the hostname and uname commands echo the local machine name, as the following sample session shows:


$ hostname
merlin.tpci.com
$ uname -n
merlin


Some Linux versions of hostname show only the name without the domain name attached. All the configuration files necessary for TCP/IP to function have now been set properly, so you should be able to reboot the machine and see what happens.
Testing and Troubleshooting
To try out TCP/IP, reboot your machine and carefully watch the messages displayed on-screen. If you see any error messages, they may help guide you to the faulty file or process. Otherwise, you will see the TCP/IP daemons load one after another.

The netstat Command
Probably the best approach to checking on TCP/IP is to use the netstat command, which gives you many different summaries of all network connections and their status. The netstat program provides comprehensive information. It’s the program most commonly used by administrators to quickly diagnose a problem with TCP/IP.
There are many more netstat options than the ones mentioned in the next sections. For more information on netstat, start with the man page on the Linux system and then check a good UNIX networking book.
Communications End Points
The netstat command with no options shows information on all active communications end points (where data is actually being transferred or communications are established). To display all end points (active and passive), netstat uses the -a option.
The netstat output is formatted in columns that show the protocol (Proto), the amount of data in the receive and send queues (Recv-Q and Send-Q), the local and remote addresses, and the current state of the connection. Here’s a truncated sample output:


merlin> netstat -a
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address Foreign Address (state)
ip 0 0 *.* *.*
tcp 0 2124 tpci.login oscar.1034 ESTABL.
tcp 0 0 tpci.1034 prudie.login ESTABL.
tcp 11212 0 tpci.1035 treijs.1036 ESTABL.
tcp 0 0 tpci.1021 reboc.1024
;TIME_WAIT
tcp 0 0 *.1028 *.* LISTEN
tcp 0 0 *.* *.* CLOSED
udp 0 0 localhost.1036 localhost.syslog
udp 0 0 *.1034 *.*
udp 0 0 *.* *.*
udp 0 0 *.* *.*


This excerpt has three active TCP connections, as identified by the state ESTABL., with one that has data being sent (as shown in the Send-Q column). An asterisk means that no end point is yet associated with that address.
Network Interface Statistics
The behavior of the network interface (such as the network interface card) can be shown with the netstat -i option. This quickly shows administrators whether there are major problems with the network connection.
The netstat -i command displays the name of the interface, the maximum number of characters a packet can contain (MTU), the number of input packets received error free (RX-OK), number of received packets with errors (RX-ERR), number of received packets dropped (RX-DRP), and the number of packets that could not be received (RX-OVR). This is followed by the same statistics for sent packets. The following is a sample output from a netstat -i command:


merlin> netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR
Flags
lo 2000 0 0 0 0 0 12 0 0 0
BLRU
eth0 1500 0 218 0 0 0 144 0 0 0
BRU


Routing Table Information
Routing tables are continually updated to reflect connections to other machines. To obtain information about the routing tables (if there are any on your system), the netstat -r option is used.
Columns show the destination machine, the address of the gateway to be used, a flag to show whether the route is active (U) and whether it leads to a gateway (G) or a machine (H for host), a reference counter (Refs) that specifies how many active connections may use that route simultaneously, the number of packets that have been sent over the route (Use), and the interface name.


merlin> netstat -r
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
localnet * 255.255.0.0 U 0 0 262 eth0
loopback * 255.0.0.0 U 0 0 12 lo
default * 0.0.0.0 U 0 0 0 eth0






Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
I CSK 661 10 1
661 663
SHS 661 741
661 Jak biuro rachunkowe ma przeciwdziałaś praniu pieniędzy i finasowaniu terroryzmu
574 659
655 661
MaxCom KXT 661
659 Analiza ekonomiczno finansowa
Vzduchovka APP 661

więcej podobnych podstron