Ephemeral port selection

The sequence that the stack uses to determine the ephemeral port for an outbound connection or packet depends on the protocol that is being used. For an outbound UDP packet, the following hierarchy is used:

  1. The port number is specified on an explicit bind.
  2. The port number is assigned from the pool of ports that the EPHEMERALPORTS parameter on the UDPCONFIG statement defines.

    The default ephemeral port numbers are in the range 1024 – 65535.

For an outbound TCP connection, ephemeral port selection can be affected by source IP address selection during bind processing. For more information about source IP address selection, see Source IP address selection.

After a source IP address is selected, the ephemeral port is selected by using the following hierarchy:

  1. The port number is specified on an explicit bind.
  2. The port number is assigned from the pool of ports that the EXPLICITBINDPORTRANGE parameter on the GLOBALCONFIG statement defines.
    Rule: EXPLICITBINDPORTRANGE ports are used when an application issues an explicit bind() to port 0 and either the IPv4 address INADDR_ANY or the IPv6 unspecified address (in6addr_any), before the application issues a connect() request. EXPLICITBINDPORTRANGE ports are unique throughout the sysplex.
  3. The port number is assigned from the PASSIVEDATAPORTS range. The PASSIVEDATAPORTS range must also be reserved on a PORTRANGE statement with the AUTHPORT parameter.
    Rule: The PASSIVEDATAPORTS range is used by the FTP server only, and specifies the range of ports that are used as listening data socket ports.
  4. The port number is assigned by SYSPLEXPORTS processing when a client application binds to a distributed DVIPA with SYSPLEXPORTS specified and port 0.
  5. The port number is assigned from the pool of ports that the EPHEMERALPORTS parameter on the TCPCONFIG statement defines.

    The default ephemeral port numbers are in the range 1024 – 65535.

For more information about ephemeral port selection and the interaction between the different methods of assigning ports, see Port selection interactions.