Ephemeral ports are temporary ports that are assigned by a machine's IP stack from a designated range of ports that are specifically for temporary use. When you terminate a connection to an ephemeral port, that port is available for reuse. However, most IP stacks do not reuse that port number until the entire pool of ephemeral ports have been used. So, if the client program reconnects, it is assigned a different ephemeral port number for its side of the new connection.
The following sections provide system-specific information about ephemeral ports.
AIX uses the no command to set network options. AIX uses two separate ephemeral port ranges, one for transmission control protocol (TCP) and one for user datagram protocol (UDP). Both of these ports default to values that range from 32768 through 65535.
Under AIX, you query the ephemeral port range as follows:
# /usr/sbin/no -a | fgrep ephemeral
To change these range values, use the -o option, as follows:
# /usr/sbin/no -o tcp_ephemeral_low=49152 -o tcp_ephemeral_high=65535
If you want to make this change permanent, insert your no commands in /etc/rc.tcpip. Add the commands at a location before the script starts the server daemons.
The Linux port range is in the ip_local_port_range file that is found in /proc/sys/net/ipv4/. To change the range, simply edit the file. Be aware that a range change that is made in this file is not permanent; the change reverts the next time you start the system. To make the change permanent, add the following line to /etc/rc.local:
# echo "49152 65535" >/proc/sys/net/ipv4/ip_local_port_range
Solaris uses the ndd utility program to configure the IP stack. Solaris uses two separate ephemeral port ranges, one for TCP and UDP. Both ports default to values from 32768 through 65535.
The following examples illustrate how you can query and change the settings:
# /usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port 32768 65535
# # /usr/sbin/ndd -set /dev/tcp tcp_smallest_anon_port 49152 # /usr/sbin/ndd -set /dev/tcp tcp_largest_anon_port 61000 # /usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port 49152 61000 #
These changes last until the next time you start your system.
HP-UX also uses ndd to configure the IP stack, but it is found in the /usr/bin directory (/usr/bin/ndd). HP-UX uses two separate ephemeral port ranges, one for TCP and UDP. Both of these ports default to values from 49152 through 65535. You query and change the setting under HP-UX the same as is shown for Solaris in the previous section.
As is the case with Solaris, any changes under HP-UX last only until the next time you start your system.
Windows Server 2008 and later use a default range of values from 49152 through 65535. For details about how to change a range under Windows, see the Microsoft knowledge base article 929851, "The default dynamic port range for TCP/IP has changed in Windows Vista and Windows Server 2008."
Earlier releases of Windows use a default range of values from 1024 through 4999. For details about these earlier releases, see the Microsoft knowledge base article 196271, "When you try to connect from TCP ports greater than 5000, you receive the error 'WSAENOBUFS (10055).'