In
computer networking, a port
number
is part of the addressing information used to identify the senders
and receivers of messages. Port numbers are most commonly used with
TCP/IP
connections. Home network routers and computer software work with
ports and sometimes allow you to configure port number settings.
These port numbers allow different applications on the same computer
to share network resources simultaneously.
How Port Numbers
Work
Port
numbers are associated with network addresses. For example, in TCP/IP
networking, both TCP
and UDP
utilize their own set of ports that work together with IP
addresses.
Port numbers work
like telephone extensions. Just as a business telephone switchboard
can use a main phone number and assign each employee an extension
number (like x100, x101, etc.), so a computer has a main address and
a set of port numbers to handle incoming and outgoing connections.
In both TCP and UDP,
port numbers start at 0 and go up to 65535. Numbers in the lower
ranges are dedicated to common Internet protocols (like 21 for FTP,
80 for HTTP,
etc.).
When You May Need
to Take Action with Port Numbers
Port
numbers are typically processed by network hardware and software
automatically. Normally you will not see them while casually using a
network nor need to take any action involving them. However, in these
special cases you can work with network port numbers:
- network administrators may need to set up port forwarding to allow the port numbers of specific applications to pass through a firewall. On home networks, broadband routers support port forwarding on their configuration screens.
- network programmers sometimes need to specify port numbers in their code, such as in socket programming.
- sometimes, a Web site URL will require a specific TCP port number be included. For example, http://localhost:8080/ uses TCP port 8080. Again, this is more usually seen in software development environments than on the Internet.
Port (computer networking)
In
computer
networking a port
is an application-specific or process-specific software construct
serving as a communications endpoint in a computer's host operating
system. A port is associated with an IP
address of the host, as well as the type of protocol used for
communication. The protocols that primarily use the ports are the
Transport
Layer protocols, such as the Transmission
Control Protocol (TCP) and the User
Datagram Protocol (UDP) of the Internet
Protocol Suite. A port is identified for each address and
protocol by a 16-bit number, commonly known as the port
number.
The port number completes the destination address for a
communications session. Thus, different IP addresses or protocols may
use the same port number for communication, e.g. on a given host or
interface UDP and TCP may use the same port number, or on a host with
two interfaces, both addresses are associated with a port having the
same number.
A
range of well-known
ports is reserved by convention to identify specific service
types on a host. In the client-server
model of application architecture ports are used to provide a
multiplexing
service on each port number that network clients connect to for
service initiation, after which communication is reestablished on
other connection-specific port number.
|
Technical details
Transport
Layer protocols, such as the Transmission
Control Protocol (TCP), the User
Datagram Protocol (UDP), specify a source and destination port
number in their packet headers. A port number is a 16-bit unsigned
integer, thus ranging from 0 to 65535. A process associates its input
or output channels via Internet
sockets, a type of file
descriptor, with a transport protocol, a port number and an IP
address. This process is known as binding,
and enables sending and receiving data via the network. The operating
system's networking software has the task of transmitting
outgoing data from all application ports onto the network, and
forwarding arriving network packets to a process by matching the
packet's IP address and port number. Only one process may bind to a
specific IP address and port combination using the same transport
protocol. Common application failures, sometimes called port
conflicts,
occur when multiple programs attempt to bind to the same port numbers
on the same IP address using the same protocol.
Applications
implementing common services often use specifically reserved,
well-known port numbers for receiving service requests from client
hosts. This process is known as listening
and involves the receipt of a request on the well-known port and
reestablishing one-to-one server-client communications on another
private
port, so that other clients may also contact the well-known service
port. The well-known ports are defined by convention overseen by the
Internet
Assigned Numbers Authority (IANA).
The
core network services, such as the World-Wide Web, typically use
small port numbers less than 1024. In many operating systems special
privileges are required for applications to bind to these ports,
because these are often deemed critical to the operation of IP
networks. Conversely, the client end of a connection typically uses a
high port number allocated for short term use, therefore called an
ephemeral
port.
The
port numbers are encoded in the transport protocol packet header, and
they can be readily interpreted not only by the sending and receiving
computers, but also by other components of the networking
infrastructure. In particular, firewalls
are commonly configured to differentiate between packets based on
their source or destination port numbers. Port
forwarding is an example application of this.
The
practice of attempting to connect to a range of ports in sequence on
a single computer is commonly known as port
scanning. This is usually associated either with malicious
cracking
attempts or with network administrators looking for possible
vulnerabilities to help prevent such attacks.
Port
connection attempts are frequently monitored and logged by computers.
The technique of port
knocking uses a series of port connections (knocks) from a client
computer to enable a server connection.
Examples
An
example for the use of ports is the Internet
mail system. A server used for sending and receiving email
generally needs two services. The first service is used to transport
email to and from other servers. This is accomplished with the Simple
Mail Transfer Protocol (SMTP). The SMTP service application
usually listens on TCP port 25 for incoming requests. The second
service is the Post
Office Protocol (POP) which is used by e-mail
client applications on user's personal computers to fetch email
messages from the server. The POP service listens on TCP port number
110. Both services may be running on the same host computer, in which
case the port number distinguishes the service that was requested by
a remote computer, be it a user's computer or another mail server.
While
the listening port number of a server is well defined (IANA
calls these the well
known ports), the client's port number is often chosen from the
dynamic port range (see below). In some applications, the client and
the server each use specific port numbers assigned by the IANA. A
good example of this is DHCP
in which the client always uses UDP port 68 and the server always
uses UDP port 67
Use in URLs
Port
numbers can occasionally be seen in the Uniform
Resource Locator (URL) of a website or other services. By
default, HTTP uses port 80 and HTTPS uses port 443, but a URL like
http://www.example.com:8000/path/
specifies that the web site is served by the HTTP server on port
8000. The active transport layer protocol ports may be discovered on
many operating systems (Windows, Unix-like, z/OS) with the command
line netstat
-a.
Common port numbers
The
Internet
Assigned Numbers Authority (IANA) is responsible for the global
coordination of the DNS Root, IP addressing, and other Internet
protocol resources. This includes the registration of commonly used
port numbers for well-known Internet services.
The
port numbers are divided into three ranges: the well-known
ports,
the registered
ports,
and the dynamic
or private
ports.
The well-known ports are those from 0 through 1023. Examples include:
- 20 & 21: File Transfer Protocol (FTP)
- 22: Secure Shell (SSH)
- 23: Telnet remote login service
- 25: Simple Mail Transfer Protocol (SMTP)
- 53: Domain Name System (DNS) service
- 80: Hypertext Transfer Protocol (HTTP) used in the World Wide Web
- 110: Post Office Protocol (POP3)
- 119: Network News Transfer Protocol (NNTP)
- 143: Internet Message Access Protocol (IMAP)
- 161: Simple Network Management Protocol (SNMP)
- 443: HTTP Secure (HTTPS)
The
registered ports are those from 1024 through 49151. IANA maintains
the official list. The dynamic or private ports are those from 49152
through 65535. One common use is for ephemeral
ports.
History
The
concept of port numbers was established by the early developers of
the ARPANET
in informal cooperation of software authors and system
administrators.
The
term port
number
was not yet used at this time. It was preceded by the use of the term
socket
number
in the early development stages of the network. A socket number for a
remote host was a 40-bit quantity. The first 32 bits were similar to
today's IPv4 address, but at the time the most-significant 8 bits
were the host number. The least-significant portion of the socket
number (bits 33 through 40) was an entity called Another
Eightbit Number,
abbreviated AEN, today's port number.
On
March 26, 1972, Vint
Cerf and Jon
Postel called for documenting the then current usages and
establishing a socket number catalog in RFC
322. Network administrators were asked to submit a note or place
a phone call, "describing
the function and socket numbers of network service programs at each
HOST".This
catalog was subsequently published as RFC
433 in December 1972 and included a list of hosts and their port
numbers and the corresponding function used at each host in the
network. This first registry function served primarily as
documentation of usage and indicated that port number usage was
conflicting between some hosts for "useful
public services".
The
document promised a resolution of the conflicts based on a standard
that Postel had published in May 1972 in RFC
349, in which he first proposed official assignments of port
numbers to network services and suggested a dedicated administrative
function, which he call a czar,
to maintain a registry. The 256 values of the AEN were divided into
the following ranges:
- 0 through 63: network-wide standard functions
- 64 through 127: host-specific functions
- 128 through 239: reserved for future use
- 240 through 255: any experimental function
Be a learner not a
collector