TCP Default assignment port range settings under Linux

Source: Internet
Author: User
Tags echo command

When you start a custom service, you want to use port 8370, but you find that the port is already occupied by nginx or node and cannot be started. But LVs has also applied, change port is more troublesome. So you can modify the next/proc/sys/net/ipv4/ip_local_port_range parameter to enable the TCP protocol to allocate ports from a larger range, so that node or nginx will not occupy the smaller port.

The code is as follows Copy Code


Echo ' 32768 61000 ' >/proc/sys/net/ipv4/ip_local_port_range

Supplemental: Temporary port range Adjustment

You can use the netstat command to show how many connections are in this state: [In a production environment, it is best to test first, and then consider the appropriate range of a port]

The code is as follows Copy Code
Shell>netstat-n | grep time_wait
......
Shell>cat/proc/sys/net/ipv4/ip_local_port_range
32768 61000

If you need to modify the echo "Start-number End-number", Start-number and End-number are the number within the range of the 0-65536 port number, and 0-1024 is best not to use, usually known as the port, if it is a dedicated proxy server, Many well-known ports are not used, of course you can consider!

Don't forget to add the echo command to the system startup script to take effect every time the machine restarts

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.