Count the number of Linux server connections

Source: Internet
Author: User

Security code: There is no degree of loneliness is impossible to have inner peace.

we learn by TCP individual states , you can exclude and the It is helpful to locate network or system failures. View the number of connections to the server through the netstat command.

Netstat-an|awk '/tcp/{print $6} ' |sort|uniq-c 2 close_wait CLOSING established fin_wait1 Fin_wait2 4 last_ack 5 LISTEN syn_recv 295 time_wait


State Describe
CLOSED Without any connection
LISTENING Listening for connection requests from a remote TCP port
Syn-sent Application has started, open a connection
Syn-received A connection request has arrived, waiting for confirmation
Established Represents an open connection
Fin-wait-1 Waiting for a remote TCP connection to interrupt the request, or the acknowledgement of a previous connection interrupt request
Fin-wait-2 Waiting for connection interrupt request from remote TCP
Close-wait Waiting for a connection interrupt request from a local user
CLOSING Wait for the remote TCP acknowledgement of the connection interruption
Last-ack Acknowledgement of the connection interrupt request waiting for the original send to remote TCP
Time-wait Wait enough time to ensure that the remote TCP receives a connection interrupt request acknowledgement


1, the state of the client can be represented by the following process:

Closed->syn_sent->established->fin_wait_1->fin_wait_2->time_wait->closed


2, the status of the server can be represented by the following process:

Closed->listen->syn_received->established->close_wait->last_ack->closed


This article is from the "Concise Linux" blog, so be sure to keep this source http://easylinux.blog.51cto.com/9732761/1945539

Count the number of Linux server connections

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.