| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ |
| 3 |
]> |
| 4 |
|
| 5 |
|
| 6 |
<section id="tcpconnectionssect"> |
| 7 |
<title>Monitoring Incoming TCP Connections</title> |
| 8 |
<indexterm> |
| 9 |
<primary>script examples</primary> |
| 10 |
<secondary>monitoring incoming TCP connections</secondary> |
| 11 |
</indexterm> |
| 12 |
|
| 13 |
<indexterm> |
| 14 |
<primary>examples of SystemTap scripts</primary> |
| 15 |
<secondary>monitoring incoming TCP connections</secondary> |
| 16 |
</indexterm> |
| 17 |
|
| 18 |
<indexterm> |
| 19 |
<primary>monitoring incoming TCP connections</primary> |
| 20 |
<secondary>examples of SystemTap scripts</secondary> |
| 21 |
</indexterm> |
| 22 |
<indexterm> |
| 23 |
<primary>TCP connections (incoming), monitoring</primary> |
| 24 |
<secondary>examples of SystemTap scripts</secondary> |
| 25 |
</indexterm> |
| 26 |
<indexterm> |
| 27 |
<primary>incoming TCP connections, monitoring</primary> |
| 28 |
<secondary>examples of SystemTap scripts</secondary> |
| 29 |
</indexterm> |
| 30 |
<!-- |
| 31 |
<indexterm> |
| 32 |
<primary>script examples</primary> |
| 33 |
<secondary>net/socket.c, tracing functions from</secondary> |
| 34 |
</indexterm> |
| 35 |
|
| 36 |
<indexterm> |
| 37 |
<primary>examples of SystemTap scripts</primary> |
| 38 |
<secondary>net/socket.c, tracing functions from</secondary> |
| 39 |
</indexterm> |
| 40 |
|
| 41 |
<indexterm> |
| 42 |
<primary>net/socket.c, tracing functions from</primary> |
| 43 |
<secondary>examples of SystemTap scripts</secondary> |
| 44 |
</indexterm> |
| 45 |
--> |
| 46 |
|
| 47 |
<para> |
| 48 |
This section illustrates how to monitor incoming TCP connections. This task is useful in |
| 49 |
identifying any unauthorized, suspicious, or otherwise unwanted network access requests |
| 50 |
in real time. |
| 51 |
</para> |
| 52 |
|
| 53 |
<formalpara id="tcpconnections"> |
| 54 |
<title>tcp_connections.stp</title> |
| 55 |
<para> |
| 56 |
<programlisting><xi:include parse="text" href="../testsuite/systemtap.examples/network/tcp_connections.stp" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting> |
| 57 |
</para> |
| 58 |
</formalpara> |
| 59 |
|
| 60 |
<para> |
| 61 |
While <xref linkend="tcpconnections"/> is running, it will print out the following information |
| 62 |
about any incoming TCP connections accepted by the system in real time: |
| 63 |
</para> |
| 64 |
|
| 65 |
<itemizedlist> |
| 66 |
<listitem><para>Current <command>UID</command></para></listitem> |
| 67 |
<listitem><para><command>CMD</command> - the command accepting the connection</para></listitem> |
| 68 |
<listitem><para><command>PID</command> of the command</para></listitem> |
| 69 |
<listitem><para>Port used by the connection</para></listitem> |
| 70 |
<listitem><para>IP address from which the TCP connection originated</para></listitem> |
| 71 |
</itemizedlist> |
| 72 |
|
| 73 |
|
| 74 |
<example id="tcpconnectionsoutput"> |
| 75 |
<title><xref linkend="tcpconnections"/> Sample Output</title> |
| 76 |
<screen>UID CMD PID PORT IP_SOURCE |
| 77 |
0 sshd 3165 22 10.64.0.227 |
| 78 |
0 sshd 3165 22 10.64.0.227</screen> |
| 79 |
</example> |
| 80 |
|
| 81 |
</section> |
| 82 |
|