Can some local port in "ip_local_port_range" be used for each local ip address?

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5

Issue

  • Can some local port in "ip_local_port_range" be used for each local ip address?

Resolution

  • In the case of tcp, yes. A local port can be used for each local address, each destination address and each destination port.
# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
...skip

tcp        0      0 192.168.122.5:32768         192.168.122.1:22            ESTABLISHED 3548/ssh           
tcp        0      0 172.16.1.5:32768            172.16.1.1:22               ESTABLISHED 3539/ssh            
tcp        0      0 192.168.122.5:32768         192.168.122.1:23            ESTABLISHED 3579/telnet         
tcp        0      0 172.16.1.5:32768            172.16.1.1:23               ESTABLISHED 3638/telnet  

The notion of "socket pairs" is valid for this. Each socket pair is described by a unique 4-tuple consisting of source and destination IP addresses and port numbers.

  • In the case of udp, no, it cannot be. There is a difference between udp and tcp for the local port auto-selection.

Description of ip_local_port_range:

linux-2.6.32-358.el6.x86_64/Documentation/networking/ip-sysctl.txt

ip_local_port_range - 2 INTEGERS
        Defines the local port range that is used by TCP and UDP to
        choose the local port. The first number is the first, the
        second the last local port number. Default value depends on
        amount of memory available on the system:
        > 128Mb 32768-61000
        < 128Mb 1024-4999 or even less.
        This number defines number of active connections, which this
        system can issue simultaneously to systems not supporting
        TCP extensions (timestamps). With tcp_tw_recycle enabled
        (i.e. by default) range 1024-4999 is enough to issue up to
        2000 connections per second to systems supporting timestamps.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.