DistributedNetworks DistributedNetworks


Network Daemons  «Prev  Next»
Lesson 5 Well-known port numbers and /etc/services
Objective Describe the conventions for establishing an association between certain port numbers and services.

Well-known Port Numbers and /etc/services

When a user opens a telnet connection from his or her machine to another machine, the client telnet process on the originating machine must find the server process on the remote machine. Thus, the client telnet process must know the port number of a telnet server process on the remote machine. Fortunately, the client process does not need to guess this port number. A set of conventions administered by the Internet Assigned Numbers Authority (IANA) establishes an association between certain port numbers and services. These assigned port numbers are called "well-known" port numbers. For example, the “well-known” port number for telnet is 23, so a telnet client can expect to find a telnet server at port 23 on the remote machine.
The notion of well-known port numbers has nothing to do with UNIX; it is part of TCP/IP. A telnet client on a UNIX machine expects to find a telnet server at port 23 on the destination machine, regardless of what operating system is running on that machine.
The file /etc/services is a list of conventional names for TCP/IP services and associated well-known port numbers:

etc services file
View the image below to examine some well-known port numbers and /etc/services.

Unix /etc/services file

  1. Port number/protocol
  2. This line indicates that the telnet service uses TCP port 23.
  3. The domain service uses both TCP port 53 and UDP port 53. These are different ports.
Comment lines, Service name, Port number/protocol

It is important to realize that the services file merely associates names (telnet, domain[1], FTP) with port numbers. (Just because a line appears in /etc/services does not mean that the corresponding service is available on the machine.) Nor is the
 /etc/services file 
 

particularly informative about what the various services are, what is chargen, for example? (see below)
The services file is a bit like the hosts file. Without it, you would have to refer to port numbers, but with it, you can refer to the telnet port.
The system can look up telnet in the services file to find out it means port 23/tcp.

The Character Generator Protocol (CHARGEN) is a service of the Internet Protocol Suite defined in RFC 864 in 1983 by Jon Postel. It is intended for testing, debugging, and measurement purposes and the protocol is rarely used, as its design flaws allow ready misuse.

[1]Domain: On the Internet, "domain" is most commonly used to refer to a group of computers whose hostnames share a common suffix, the domain name. The last component of this is the top-level domain.