Increase IP_local_port_range TCP port range
On Linux, there is a sysctl parameter called ip_local_port_range that defines the minimum and maximum port a networking connection can use as its source (local) port.
To find out the current IP range, use the following commands: (CentOS5/6)
$cat /proc/sys/net/ipv4/ip_local_port_range 32768 61000
The value is shown as “minimum maximum” value, so the local port for new connections will be between 32.768 and 61.000, by default that’s a 28.232 range of ports. Sounds plenty, but heavy traffic servers may reach this limit.
To increase port range, add following parameter to configuration file /etc/sysctl.conf
net.ipv4.ip_local_port_range = 30000 65535
And restart OS.
Generally, in many types of OSs, ephemeral ports are defined as under 65535, so we recommend to set the range under 65535.