Once you have decided to create a name for a port, you need to edit the
/etc/services
file. To edit this file:
- Open
/etc/services
in an editor, such as vi
or pico
.
- Find where the entry should go in the file. Notice that as you scroll down through the file, the port numbers increase.
You should put your new entry so that port numbers remain sorted.
- Insert the port name, number and protocol, any aliases, and a comment.
View the SlideShow below to see the process of inserting a new entry into the
/etc/services
file.
Question: What line would you put in /etc/services for the foobar service running on UDP port 8888?
Correct answer:
foobar 8888/udp # the foobar service
Explanation:
The first field in /etc/services is the official service name. Next, you list the port and protocol using the "port/protocol" format. Finally, you list any aliases and a descriptive comment. Since you don't have any aliases, only a descriptive comment is required.
The next lesson describes the function of the Domain Name System.