| Lesson 6 | Ephemeral and reserved port numbers |
| Objective | Describe the significance of ephemeral and reserved port numbers in Linux |
In TCP/IP networking, a port number identifies a process endpoint on a host. Servers typically listen on a known destination port, but clients also need a port for the source side of the conversation. Client-side ports are commonly assigned automatically by the operating system and are usually drawn from the ephemeral port range.
Ephemeral ports (also called dynamic or private ports) are temporary ports used to create short-lived endpoints for outbound connections. They exist for the life of a connection (TCP) or for the life of an application’s socket usage (UDP/SCTP), and they are later returned to the pool for reuse.
On modern Linux systems, the ephemeral range is configurable. A common default range is 32768–60999 (varies by distribution and kernel defaults). You can check your system’s active range with:
cat /proc/sys/net/ipv4/ip_local_port_range
Example output:
32768 60999
You can adjust the range temporarily using sysctl. This can be useful in high-connection
environments (proxies, load balancers, busy application servers) where port exhaustion becomes a risk.
sudo sysctl -w net.ipv4.ip_local_port_range="40000 65000"
To make changes persistent, place the setting in a sysctl configuration file (for example,
/etc/sysctl.conf or a drop-in under /etc/sysctl.d/) and reload sysctl settings.
Reserved (or privileged) ports are the low-numbered ports historically associated with core system services. On UNIX-like systems, binding to ports 0–1023 traditionally required elevated privileges (root or a process with the appropriate capabilities).
This convention exists so that a non-privileged user cannot easily impersonate a system service
(for example, by binding to port 22 to mimic SSH). In modern Linux, “privileged port” behavior is
still relevant, but it is often managed through Linux capabilities rather than requiring full root.
For example, a service may be granted CAP_NET_BIND_SERVICE so it can bind to low ports
without running as root.
The practical point for administrators is simple: well-known services tend to live on privileged ports, while client connections tend to originate from ephemeral ports.
Ephemeral ports are not just a theory detail — they affect troubleshooting, performance, and security:
TIME_WAIT. The symptom
looks like intermittent connection failures despite healthy DNS and routing.
The operating system’s ephemeral port pool is used across multiple transport protocols, but the behavior differs slightly by protocol:
Across all three, the principle is the same: ephemeral ports provide temporary client endpoints while servers use stable listening ports that clients can predict.
Click the Quiz link below to take a short multiple-choice quiz on client/server processes, TCP, UDP, and port numbers.
TCP UDP Port Numbers - Quiz