In computer networking, a port is a communications socket/endpoint in a computer's operating system. A port is associated with an IP address of the host, as well as the type of protocol used for communication.
A port in conjunction with the IP address is known as a socket or endpoint. The Transport Layer protocols, such as the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP), are the primary users of TCP/IP ports.
The sockets created by each host that is used in the communication session is known as socket pairs or endpoint pairs. These sockets or endpoints allow hosts to create more than one session to allow for multiple
communication channels to be active at any given time between various hosts.
There are clearly defined port numbers for every popular or well-known TCP/IP application. A port number is a 16-bit value between 0 and 65,535. Within this range of ports, some port numbers are established for specific
services, some are reserved for certain applications, and others are available for temporary use by applications. Web servers, for example, use port number 80 because client browsers are developed to connect to web servers
using the HTTP protocol on port 80. Port numbers from 0 to 1023 are called well-known ports and are reserved for specific TCP/IP application services. The range of port numbers from 1024 to 49151 are the Registered, also
known as User ports.
These ports are assigned by IANA for specific service upon application by a requesting entity. The range 49152–65535 are above the registered ports. This range is reserved for the Dynamic and/or Private ports that cannot
be registered with IANA. This range is used for custom or temporary purposes and for automatic allocation of ephemeral ports.
The port numbers in the range from 0 to 1023 are the well-known, also known as System ports. They are used by system processes that provide widely-used types of network services. Examples of some of the most common
well-known ports are:
|20||ftp||tcp/udp/sctp||File Transfer Data|
|21||ftp||tcp/udp/sctp||File Transfer Control|
|25||smtp||tcp/udp||Simple Mail Transfer|
|42||name||tcp/udp||Name Server (WINS)|
|67||bootps||udp||Bootstrap (BOOTP/DHCP) Server |
|68||bootpc||udp||Bootstrap (BOOTP/DHCP) Client|
|69||tftp||udp||Trivial File Transfer|
|80||http||tcp||Hypertext Transfer Protocol|
|110||pop3||tcp||Post Office Protocol v3|
|119||nntp||tcp||Network News Transfer Protocol |
|123||ntp||udp||Network Time Protocol|
|135||epmap||tcp/udp||DCE Endpoint Mapper/RPC|
|137||netbios-ns||tcp/udp||NETBIOS Name Service|
|138||netbios-dgm||tcp/udp||NETBIOS Datagram Service|
|139||netbios-ssn||tcp/udp||NETBIOS Session Service|
|143||imap||tcp/udp||Internet Message Access Protocol|
|161||snmp||udp||Simple Network Management Protocol|
|162||snmptrap||tcp/udp||Simple Network Management Protocol Trap|
|443||https||tcp||Internet Message Access Protocol|
|445||microsoft-ds||tcp||SMB File Sharing|
If we take the example of a host system trying to access a web server, the source system will craft a packet to send to the destination IP address on port 80. Since port 80 is a well-known port for HTTP, in most cases, if
you wanted to host a web server, you would not change the web server's default port. If you did configure the web server to run on a different port, you would have to communicate this information to your users since
the client applications that they are using (web browsers) are expecting to connect to the web server on port 80. In this scenario, the client that established this connection with the web server will use a port in the
Private/Dynamic range. For example, the source IP:source port may be 192.168.1.1:50125 for the client. When the web server sends back a packet to the client it will send it back to this IP and port (socket/endpoint).
For more information about port numbers or to get a complete listing of reserved and registered ports, please visit the Service Name and Transport Protocol Port Number Registry
Recommended Books & Training Resources