Ports
The
port numbers are divided into three ranges: the Well Known Ports, the Registered
Ports, and the dynamic and/or Private Ports
·
The Well Known Ports are those from 0
through 1023.
·
The Registered Ports are those from
1024 through 49151 – in the list of port numbers (see the link below), you
will see that most of these are registered to a person or company, and an email
address is given. They are reserved
for that person’s particular application
· The Dynamic and/or Private Ports are those from 49152 through 65535. They are not shown on the port list generated by IANA (see link below)
Another
type of port, called “Ephemeral” ports – is a concatenation of the all the
ports above the well-known ports. Therefore,
Ephemeral ports include both the Registered and Dynamic/Private ports.
Well-Known
Ports
Well-Known ports belong to the standard servers, for example Telnet uses port 23. Well-known port numbers range between 1 and 1023. Well-known port numbers are typically odd, because early systems using the port concept required an odd/even pair of ports for duplex (two-way) operation. Most servers require only a single port. Exceptions are BBOTP server which uses port 67 & 68 and the FTP server, which uses 20 & 21. The well-known ports are controlled and assigned by the Internet central authority (IANA) and on most systems can only be used by system processes or by programs executed by privileged users. The reason for well-known ports is to allow clients to be able to find servers without configuration information.
The assigned well-known ports go all the way up to 48556, with higher number reserved for future assignments . For an automatically generated file which lists all the Well-Known Ports :
http://www.iana.org/assignments/port-numbers
(a long download)
Ephemeral
Ports
(all ports above 1023)
These are temporary, non-established ports. It would seem that in general, they are meant to be the unassigned ports above 1023. However, even if you use a reserved port that was registered to a certain individual (see the link to the list of ports), it should be fine, since you will not be using that port for anything else. In addition, clients rarely actually use any of the higher numbered ports for specific purposes, and they are usually free to grab any of the ephemeral ports at any time. Lastly, to be safe, a client can simply request an “available” port from the server, which insures that the port given will be free for use.
NOTE: there are specific ranges to avoid using. For example, the X Window System uses TCP ports 6000-6063, which makes this an excellent port range to avoid. Unfortunately, the list of ports is long and tedious to read, which makes it difficult to locate ranges to avoid. However, all of these ranges fall between 1024 and 10,000. Therefore, to be completely safe, choose ephemeral port numbers above 10,000
Webster’s dictionary defines the word ephemeral as: “Lasting for a markedly brief time”. Clients do not need well-known port numbers because they initiate communication with servers and the port number they are using is contained in the UDP data grams sent to the server. Each client process is also allocated a port number as long as it needs it, by the host it is running on. Ephemeral port numbers have values greater than 1023, normally in the range 1024 to 65535. A client can use any number allocated to it, as long as the combination of <transport protocol, IP address, port number>is unique. Ephemeral ports are not controlled by IANA and on most systems can be used by ordinary user developed programs. Confusion due to two different applications trying to use the same port numbers on one host is avoided by writing those applications to request an available port from TCP/IP. Because this port number is dynamically assigned, it may differ from one invocation of an application to the next. UDP, TCP and ISO TP-4 all use the same port principle. To the extent possible, the same port numbers are used for the same services on top of UDP, TCP and ISO TP-4. Normally, servers will use either TCP or UDP, but there are exceptions. For example, domain name server use both UDP port 53 and TCP port 53.
Every process communicating over the Internet via these
protocols must have at least one port number assigned to it. A process which is
communicating simultaneously with many other processes may have dozens or even
hundreds of port numbers assigned to it.
Ephemeral port numbers typically have only temporary significance, being assigned for the duration of a program run. Port numbers assigned to a telnet or rlogin session are in this category. Conversely, the Well-Known port numbers (1 to 1023) have specific, widely understood meanings, which processes on other machines use to locate specific services. For example, 'sendmail' always runs on TCP port 25, and other systems count on this when sending mail. Ports 1-1023 (in both the TCP and UDP address spaces) are reserved for processes running with unix root privilege. This provides a certain (weak) amount of authentication: If you connect to a port in this range, you can have some confidence that the process you contact was set up by the authority controlling that machine, rather that by some arbitrary user.
Unix typically (but not always) allocates ephemeral TCP ports from the range 1024-5000, and ephemeral UDP ports from the range 1024-32767.