DistributedNetworks DistributedNetworks


Internet Services  «Prev  Next»
Lesson 6Port names
ObjectiveExplain the relationship between port names and numbers.

Relationship Between Port Names and Numbers

Computers are very good with numbers, and, not surprisingly, they handle port numbers without a problem.
Humans, on the other hand, are better with names than numbers.

Assigning names to numbers

Linux allows administrators to assign a name to an actual port number. This way, the administrator or users may refer to the port by name or number. For example, it's easier to remember the name "ftp" than it is to remember the FTP service port of 21, so the administrator can map the name "ftp" to port 21.

Mapping port names

Linux ships with port names mapped to numbers for many IANA-standard services. However, if you wish to run services on non-standard ports or if you install a new network service, you might want to update your system's mapping.
The /etc/services text file maps port names to port numbers. In this file, Linux ignores blank lines and all commentary text after a hash ("#") Otherwise, Linux expects the first field to be the primary service name (e.g., ftp), the second field to be the port number and protocol separated by a slash (e.g., 21/tcp), and all remaining fields to be aliases to the primary name.
Whitespace: As the name implies, any space between text that is empty. Whitespace includes spaces, tabs, new lines, and form feeds, though programs may restrict what they consider to be whitespace to just a subset of these.

Red Hat Reference
  1. This is a comment line in /etc/services, because it starts with a hash (#) sign. All text after the hash, to the end of the line, is ignored.
  2. Blank lines are ignored in /etc/services. 1) ftp protocol, 2) instant messenger protocol
  3. The first field in /etc/services is the official service name.
  4. The second field in /etc/services is the port and protocol, separated by a forward slash (/)
  5. his is an alias. The words in the third field and beyond are aliases to the official service name in field one.

Port Names To Numbers - Mapping
The next lesson demonstrates configuring port names.

Port Numbers Names - Quiz

Before moving on to the next lesson, click the Quiz link below to check your understanding of port numbers and names.
Port Numbers Names - Quiz