Introduction to Linux ports and introduction to linux
1. view the port range
[root@lry proc]# cat /proc/sys/net/ipv4/ip_local_port_range 3276860999
32768 when used by the system, if the port above 6099 is set, it indicates that the system failed.
2. sysctl. conf configuration file
Most kernel parameters are stored in the/proc/sys directory and can be modified during system running. However, restarting the machine fails. /Etc/sysctl. conf is an interface that allows you to change the running Linux system. It contains some advanced options for the TCP/IP stack and virtual memory system, and the modification of Kernel Parameters takes effect permanently. That is to say, the kernel file in/proc/sys corresponds to the variable in the configuration file sysctl. conf.
Modify the Linux kernel parameters directly by modifying the sysctl. conf file. The following is my Configuration:
# System default settings live in /usr/lib/sysctl.d/00-system.conf.# To override those settings, enter new settings here, or in an /etc/sysctl.d/
.conf file## For more information, see sysctl.conf(5) and sysctl.d(5).net.ipv6.conf.all.disable_ipv6 = 1net.ipv6.conf.default.disable_ipv6 = 1net.ipv6.conf.lo.disable_ipv6 = 1vm.swappiness = 0net.ipv4.neigh.default.gc_stale_time=120net.ipv4.conf.all.rp_filter=0net.ipv4.conf.default.rp_filter=0net.ipv4.conf.default.arp_announce = 2net.ipv4.conf.lo.arp_announce=2net.ipv4.conf.all.arp_announce=2net.ipv4.tcp_max_tw_buckets = 5000net.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_syn_backlog = 1024net.ipv4.tcp_synack_retries = 2
Explain the meaning of parameters in the sysctl. conf file:
- File-max: this parameter indicates the maximum number of handles that a process can open at the same time. This parameter directly limits the maximum number of concurrent connections.
- Tcp_tw_reuse: this parameter is set to 1, indicating that the socket in the TIME-WAIT status can be re-used for the new TCP link. This makes sense for the server, because there will always be a lot of TIME-WAIT connections on the server.
- Tcp_keepalive_time: indicates the frequency of keepalive messages sent by TCP when keepalive is enabled. The default value is 7200 seconds, which means that if a TCP connection is established after idle 2 hours, the kernel initiates probe. If you set it to a smaller value, you can clear invalid connections faster.
- Tcp_fin_timeout: the maximum time for the socket to remain in the FIN-WAIT-2 state when the server closes the connection.
- Tcp_max_tw_buckets: this parameter indicates the maximum number of TIME_WAIT sockets allowed by the operating system. If this number is exceeded, TIME_WAIT socket is immediately cleared and warning information is printed. The default value is i180000. Too many TIME_WAIT sockets will slow down the Web server.
- Tcp_max_syn_backlog: this parameter indicates the maximum length of the WYN Request queue accepted during TCP three-way handshake establishment. The default value is 1024. setting this parameter to a greater value may cause Nginx to be too busy to access the new connection, linux does not lose connection requests initiated by clients.
- Ip_local_port_range: this parameter defines the value range of the local port in UDP and TCP connections.
- Net. ipv4.tcp _ rmem: this parameter defines the minimum value of TCP accept cache (used for TCP receive Sliding Window), default value, maximum value.
- Net. ipv4.tcp _ wmem: this parameter defines the minimum value of TCP sending cache (for TCP sending Sliding Window), default value, maximum value.
- Netdev_max_backlog: when the speed at which the network adapter receives data packets is greater than that processed by the kernel, a queue stores these data packets. This parameter indicates the maximum value of the queue.
- Rmem_default: this parameter indicates the default size of the kernel socket receiving cache.
- Wmem_default: the default size of the kernel socket sending cache.
- Rmem_max: the default maximum size of the kernel socket receiving cache.
- Wmem_max: the default maximum size of the kernel socket sending cache.