Ephemeral Ports in Network Security
What you'll learn: How temporary client ports affect return traffic rules in Network ACLs.
What Are Ephemeral Ports?
When your application makes an outbound connection (like fetching data from an API), your computer doesn't just use any random port—it picks a temporary port from a specific range called ephemeral ports. These are short-lived ports used only for the duration of that connection.
Think of it like making a phone call: you dial out from your phone (source port), and when the other person responds, they call back to your number—not some fixed business line. That "callback number" is your ephemeral port.
Why This Matters for NACLs
Remember that Network ACLs are stateless—they evaluate inbound and outbound rules independently. If your instance in a private subnet initiates an HTTPS request (outbound on port 443), the response comes back on a different, unpredictable ephemeral port.
The problem: Your NACL must explicitly allow inbound traffic on the entire ephemeral port range, or the response gets blocked—even though your instance initiated the connection.
Common ephemeral ranges:
- Linux:
32768-60999 - Windows:
49152-65535
The NACL Rule You Need
To allow return traffic for outbound connections, your inbound NACL rules must permit traffic from ephemeral ports. For example, if instances make web requests, you need an inbound rule allowing source ports 1024-65535 (safe broad range) from the internet.
Key Takeaway: Network ACLs must explicitly allow inbound traffic on ephemeral port ranges to permit return traffic for connections initiated by your instances, because NACLs don't track connection state like Security Groups do.