Back to Articles

Utilizing netstat command to check your Linux server network performance

2 min read
asrar
Utilizing netstat command to check your Linux server network performance

Here’s some of the netstat command to check your network performance or behavior in your Linux server.

- Identified FIN_WAIT1, FOREIGN, SYNC_RECV, LAST_ACK, TIME_WAIT, LISTEN and ESTABLISHED  Connections

#netstat -nat | awk ‘{print $6}’ | sort | uniq -c | sort -n  

Xshell_Hg3IkFVgc2.png

- Identified established and time_wait connections state

#netstat -etna|grep -i establi|wc -l

Xshell_EKy31eCYld.png Or

#netstat -tupen |wc -l 

Xshell_Jd2v5blU7u.png See the difference?

- Identified unique connection type

-  Tracking connection type  
    ```
    #netstat -n -p | grep SYN\_REC | sort -u
    ```
*   Get all ip address involved in the connection above  
    #netstat -n -p | grep SYN\_REC | awk ‘{print $5}’ | awk -F: ‘{print $1}’
*   Get all ip address that SYN\_REC connection  
    #netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
*   Calculate the number of connection from each unique ip address  
    \# netstat -anp |grep ‘tcp|udp’ | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
*   Counting connection for TCP or UDP to the server  
    \# netstat -ntu | grep ESTAB | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr  
    ![](/uploads/Xshell_5x_FX_805_Sdu_7780168be8.png)
*   Get only ESTABLISHED connection of all connection with each ip count  
    \# netstat -plan|grep :80|awk {‘print $5’}|cut -d: -f 1|sort|uniq -c|sort -nk 1  
    ![](/uploads/Xshell_RUP_Ygjjt_Ec_81b680d138.png)

Hope this helpfull.

Share this article

Discussion

Join the discussion

Loading comments...