What is the range of TCP/UDP ports?
TCP and UDP use the same port range: from 0 to 65535. The difference between TCP and UDP is that they have different port spaces.
In short: TCP port 80 and UDP port 80 are different ports.
Overall port range
- Minimum: 0
- Maximum: 65535
- Total: 65,536 ports for TCP and the same number for UDP
Main port ranges
1. Well-known ports (0-1023)
Standard, "well-known" ports.
Used by basic network services:
- 80 - HTTP
- 443 - HTTPS
- 22 - SSH
- 25 - SMTP
- 53 - DNS
Usually:
- require administrator privileges
- used by servers
2. Registered ports (1024-49151)
Ports assigned to specific applications.
- used by servers and services
- not considered system ports
Examples:
- 3306 - MySQL
- 5432 - PostgreSQL
- 8080 - alternative HTTP
3. Dynamic / Ephemeral ports (49152-65535)
Temporary (dynamic) ports.
Used by:
- client applications
- assigned automatically by the OS
- exist only for the duration of the connection
Important points for the interview
-
the ranges are the same for TCP and UDP
-
the port spaces are separate
-
a port is part of an end-to-end connection
-
a connection is uniquely identified by the set:
source IP + source port + destination IP + destination port + protocol (TCP/UDP)
In short, for the interview
The range of TCP and UDP ports is 0 to 65535. It is divided into well-known (0-1023), registered (1024-49151), and dynamic/ephemeral (49152-65535); TCP and UDP have independent port spaces.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.