Difference between revisions of "Network Statistics"

From 6bit.ch wiki
Jump to navigation Jump to search
 
Line 31: Line 31:


== Useful Flags ==
== Useful Flags ==
<code>-t</code> show tcp connections only</br>
<code>-t</code> tcp connections only</br>
<code>-u</code> show udp connections only</br>
<code>-u</code> udp connections only</br>
<code>-x</code> show unix sockets only</br>
<code>-x</code> unix sockets only</br>
<code>-n</code> show numerical addresses and ports</br>
<code>-n</code> numerical addresses and ports</br>
<code>-p</code> show associated pid/program</br>
<code>-p</code> display associated pid/program</br>
<code>-c</code> continuous output</br>
<code>-c</code> continuous output</br>
<code>-r</code> show routing table</br>
<code>-r</code> show routing table</br>

Latest revision as of 10:38, 2 December 2022

netstat

Gives an overview of network activities and displays which ports are open or have established connections. The netstat tool is essential for discovering network problems.

Use

netstat show lists of active connections

The first list shows internet connections:
Proto – Protocol of the connection (TCP, UDP)
Recv-Q – Receive queue of bytes received or ready to be received
Send-Q – Send queue of bytes ready to be sent
Local Address – Address details and port of the local connection, an asterisk (*) in the host indicates that the server is listening and if a port is not yet established
Foreign Address– Address details and port of the remote end of the connection, an asterisk (*) appears if a port is not yet established
State – State of the local socket, most commonly ESTABLISHED, LISTENING, CLOSED or blank

The second list shows "Unix Domain" open sockets:
Proto – Protocol used by the socket (always unix)
RefCnt – Reference count of the number of attached processes to this socket
Flags – Usually ACC or blank
Type – The socket type
State – State of the socket, most often CONNECTED, LISTENING or blank
I-Node – File system inode (index node) associated with this socket
Path – System path to the socket

netstat -l list open ports
netstat -a list open ports and active connections
netstat -s show statistics for all protocols
netstat -i show interface statistics
netstat -ie show extended interface statistics

Useful Flags

-t tcp connections only
-u udp connections only
-x unix sockets only
-n numerical addresses and ports
-p display associated pid/program
-c continuous output
-r show routing table