Linux settings reserved port number to prevent the listening port from being occupied ip_local_reserved_ports

Source: Internet
Author: User

1. Background

When the Linux server starts, the specified port is monitored for bind, and if the port on the same machine is already in use, the listener fails and the program fails to start.

When the Linux client connects to the server accept, the system allocates a local temporary port for the network connection.

Now is the "big mix" of the era, a physical machine may deploy multiple services, if the port number is not set, it is likely that the port is occupied by other programs.

2. Workaround

Look at my Linux machine.

local ephemeral port configuration (2 numbers: Start, end)

cat/proc/sys/net/ipv4/ip_local_port_range3276861000

Reserved Port configuration (Can support multiple comma-separated numbers, such as 10000, 10005-10010)

Cat/proc/sys/net/ipv4/ip_local_reserved_ports

As the following link says, there are 2 ways:

(1) Modify the ephemeral port range Ip_local_port_range, because a program port problem modifies the temporary port range of a machine, significantly reducing the amount of temporary port usage. The price is great.

(2) Modify the reserved port Ip_local_reserved_ports, even if there is no conflict can be pre-set to prevent the subsequent port is occupied.

Paste the reference link inside the English

Ip_local_reserved_ports explained as follows: Ip_local_reserved_ports-list of comma separated rangesspecify the ports which is reserved f or known third-partyapplications. These ports is not being used by automatic portassignments (e.g. when calling connect () or bind () with portnumber 0). Explicit port allocation behavior is unchanged. The format used for both input and output are a comma separatedlist of ranges (e.g. "1,2-4,10-10" for Ports 1, 2, 3, 4 and1 0). Writing to the file would clear all previously reservedports and update the current list with the one given in Theinput .

Reference:

(1) http://www.ttlsa.com/linux/reserved-port-to-avoid-occupying-ip_local_reserved_ports/

(2) 78546551?locationnum=10&fps=1

Linux settings reserved port number to prevent the listening port from being occupied ip_local_reserved_ports

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.