Once an IP packet reaches its destination address, the operating system must deliver the packet's information to a specific running application.
Some protocols that use IP, such as TCP or UDP, include an extra bit of addressing information known as the "port."
These protocols allocate 16 bits of storage for the port, meaning the maximum representable port number is 216-1, or 65,535. The image below illustrates the port number concept.
The Internet Assigned Numbers Authority (IANA)
reserves ports 1 through 1023 for well-known services
These services use the same ports on all machines universally. For example, all Web traffic uses the well-known service on port 80. Knowing this, a Web browser can connect to port 80 and be sure a Web server is listening on that port.
For comparison, imagine the problems if every city used a different number for 911. With 911 as a standard, people know where to call in case of an emergency.
IANA also registers ports 1024 through 49151 as a "service to the community." This prevents collisions caused by different services trying to use the same port number. Unlike reserved ports, users may run servers on registered ports.
The remaining ports, numbered 49152 through 65535, are dynamic and private ports available to all users.
- Internet Assigned Numbers Authority (IANA): The IANA is responsible for assigned standard port numbers to well-known Internet services, such as HTTP, FTP, and DNS.
- Well-known services (WKS): WKSs are services that are prevalent across the Internet. Examples include HTTP for World Wide Web traffic, FTP for File Transfer Protocol, and DNS for the Domain Name System.
To prevent user programs from running potentially insecure servers on well-known service ports, Linux only allows the root user to start
servers on these ports.
The next lesson describes the relationship between port names and numbers.