Current location - Quotes Website - Team slogan - Linuxtcp connection
Linuxtcp connection
How does linux log into the background and the port number and protocol used?

Open cmd

1.netstat

View all ports used by this machine.

(1).Proto indicates that there are two protocols: tcp and udp.

②.LocalAddress indicates the IP of this machine, followed by the port number we use.

③.③。 The ForeignAddress connects to the IP address and server port of the external server.

④.State: indicates some specific states, such as LAST_ACK waiting for the used package to die.

2. Confirm the port number to query.

Command netstat-aon|findstr 1044 (specified port number)

The last digit of the query result is the pid of the current program or service.

3. Enter the command: tasklist|findstr26 12 (enter the pid queried above).

So you can see the programs running on this port.

Then query from the task manager, you can see this program.

4. If we use the specified port number in two schemes.

(1). End the running program of this port in the task manager, and then you can use this port number.

② Enter the command: taskkill/f/pid26 12 (enter the pid of the query) in the cmd interface, or you can kill this program.

Linux operating system

Netstat-tln# looks for all occupied ports.

Netstat-tln|grep80# Find the specified occupied port.

Install lsof

yuminstalllsof

Lsof can tell us which program the port belongs to.

Lsof-I: port of 80 # query

Kill-9# Kill process id Multiple process ids are separated by spaces.

The correct way for linux clients to close tcp?

Client calls write ()-> Client calls shutdown (write)->; Server receives FIN (manifested as blocking reading and reading 0 bytes) (->; The server calls write ()-> Server close () (because readbuffer is empty, you can close () directly without sending RST and discarding writebuffer)->; Client receives FIN (reading blocked, reading 0 bytes)-> client closes ().

What if there are too many tcp connections on the linux server?

No matter what system's server is, the most obvious thing for customers to connect to the server is the display of TCP. Generally divided into two situations:

1 CC attacks will increase traffic, and the typical TCP traffic (red) on the bandwidth graph will suddenly increase abnormally. The CPU usage increases, which then leads to slow opening or jamming. So if TCP suddenly increases, it proves that your server has been attacked by CC. You can contact the server manufacturer and let the computer room make a defense strategy.

2. If the number of TCP connections in an area is already very large, the resources of the inspection server may not be able to support the number of visits, and more resources and higher configuration support are needed.

How to modify linuxtcp?

The TCP port range of Linux system can be modified. Adjust the TCP port range appropriately to meet personal needs, so how to modify the TCP port range specifically? Let's take a look at it through examples. When starting a custom service, I want to use port 8370, but I find that the port is already occupied by nginx or node, so I can't start it. However, lvs has applied again, and it is more troublesome to change the port. Therefore, the parameter/proc/sys/net/IPv4/IP _ local _ port _ range can be modified, so that the ports allocated by the tcp protocol can be enabled from a wider range, so that node or nginx will not occupy smaller ports. The code is as follows: echo' 3276861000'/proc/sys/net/IPv4/IP _ local _ port _ range Supplement: Temporary port range adjustment You can use the netstat command to show how many connections have entered this state: [In a production environment, it is best to test first. Then consider the appropriate range of a port] The code is as follows: shell "netstat-n | greptime _ waitshell" cat/proc/sys/net/ipv4/IP _ local _ port _ range3276861 000 If echo "start-number end-number "needs to be modified, start-number and end-number are numbers in the range of 0-65536 port number, and 0- 1024 is best not to be used. Usually, it is a famous port. If it is a dedicated proxy server, many well-known ports are not used, of course, you can consider it! Don't forget to add the echo command to the system startup script, so that the machine will take effect after each restart.

Why does Linux check the tcp connection to shut down actively?

When you check TCP, if its connection is actively closed, it may be because there is a word combination in the system.