Monday, 13 April 2015

Concept of Ephemeral Port in Linux OS

Ephemeral Port is a common term for all system administrators. In this post, I will explain about its concept and the procedure to change its range.

TCP is the heartbeat of web services. Every TCP connection has source IP, source port, destination IP, destination port. For a given machine communicating with a single host, three of the elements (source IP, destination IP, and destination port) are fixed.

This means the number of connections a single machine can make to a single web service is limited to the number of source ports available. On Linux, the source port for an outgoing connection is selected by the kernel from the ephemeral range.

The ephemeral range, that is currently configured in a linux machine can be viewed by using the following method

This gives a range of about 28,000 connections.

Proxies servers are susceptible to ephemeral port exhaustion because all requests (from many clients) pass through them.

echo "15000 61000" > /proc/sys/net/ipv4/ip_local_port_range

To make this change persistent after reboots, we can use sysctl.

Edit /etc/sysctl.conf and append the entry:

net.ipv4.ip_local_port_range = 15000 61000

then, for the change to take effect force sysctl to reread the settings in /etc/sysctl.conf, run as root:

sysctl -p

Kool :)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.