Always use the ifconfig command to view network connections in CentOS, including IP address, MAC address, network connection status, and so on. Upgrade to CentOS 7 after the ifconfig can not find, the original instructions have been discarded, using IP instructions instead. The same thing happened in the minimal version of RHEL 7, Oracle Linux 7, Scientific Linux 7.
In the CentOS 7 minimal system, you can use "IP addr", "IP link" to view network connections and their status, and you can also view statistics using "ip–s link."
If you still want to use ifconfig, you need to install it yourself. First we need to know which package is provided by the IFCONFIG Directive,
Yum provides ifconfig
Or
Yum Whatprovides ifconfig
can query to the corresponding package for Net-tools, install it,
Yum Install Net-tools
Once installed, you can use Ifconfig–a to view the network status.
Of course, this approach also applies to querying for other installation packages that you want to use but cannot find the corresponding instructions.
Will Linode VPS also deployed into the CentOS 7, only to find that Linode on the CentOS 7 has been customized, including the common but in the 7 version of the abandoned instructions, such as ifconfig, Netstat, iptables and so on.
If it is CentOS 7 The following version can be used netstat
Netstat-n | awk '/^tcp/{++s[$NF]} end {for (a in S) print A, s[a]} '
Explain:
NF current total number of row fields processed
The value of the last field $NF (corresponding to)
Introduction to awk Special fields
NR currently processes the total number of rows. Because awk is a flow-processing tool, one row at a time, NR is continuously increasing by 1, indicating the number of rows of data that awk reads after it starts executing the program
FNR the current processing row is the first row of the current file and its variable value is less than or equal to NR (for example, when the second file is read, the FNR is counted from 0 and nr is not).
NR==FNR: Used to determine whether to read the first file when reading two or more files.
The basic syntax for awk to handle multiple files is:
Awk-f delimiter ' BEGIN {initialize} {circular execution part} ' end {finish processing} ' File_list1 File_list2
Where begin and end can be omitted, and-F can also use the default, loop execution section, which is processed by rows.
The result of running this command:
Close_wait 1
Established 23
Fin_wait2 12
Time_wait 30
Network State explanation
CLOSED: Indicates the initial state. The same for both the server side and the C client.
LISTEN: Indicates a listening state. The Listen function is invoked on the server side, and the accept connection can begin.
Syn_sent: Indicates that the client has sent a SYN message. When the client calls the Connect function to initiate the connection, it first sends SYN to the server, then enters the syn_sent state itself and waits for the server to send the Ack+syn.
SYN_RCVD: Indicates that the server receives the client to send a SYN message. When the server receives this message, it enters the SYN_RCVD state and sends Ack+syn to the client.
Established: Indicates that the connection has been established successfully. After the service end sends the Ack+syn to enter this state, the client receives the ACK also to enter this state.
Fin_wait_1: Indicates active shutdown of the connection. Whichever side calls the close function to send a FIN message will enter this state.
Fin_wait_2: Indicates that the passive closed side agrees to close the connection. The active shutdown of the connection will enter the state after it receives an ACK returned by the passive closing party.
Time_wait: means to receive each other's fin message and send an ACK message, and then 2MSL can return to closed state. If the fin_wait_1 state, when receiving the other side with the FIN flag and ACK sign message, you can directly into the time_wait state, without having to go through the fin_wait_2 state.
CLOSING: means both sides close the connection at the same time. If both sides call the close function at the same time, there will be cases where both sides send the fin message at the same time, and the closing state will appear, indicating that both sides are closing the connection.
Close_wait: Indicates that the passive shutdown is waiting to be closed. When receiving a fin message sent by the close function, the caller responds to the ACK message and enters the close_wait state at this time.
Last_ack: Indicates that the passive closed side sends the fin message, waits for the other side ACK message status, when receives the ACK to enter the closed state.
Specifically, why does the TIME_WAIT state still need to wait for 2MSL to return to closed state? or why does TCP introduce TIME_WAIT state?