logs information about selected incoming and outgoing TCP/IP connections to
syslog. The following information is logged: username, local address and port,
remote address, port, and optionally the filename of the executable. At
present, only the IPv4 protocol is supported.
Log only connections matching the specified rule. Rule syntax is outlined
below. If this option is specified more than once, connections matching any
of the specified rules are logged. You should quote the rule, as shown above.
Read rules from
Each rule is on a new line. The `#' character may be used to add comments;
everything from this character to the end of the line is ignored.
options may be used together.
Log to syslog facility
instead of the compile-time default setting. See the
manual page for a list of facilities.
Update the internal state every
milliseconds, instead of the default of 1000 ms. Connections that last less
milliseconds may be missed, so you should experiment to find a value small
enough that it catches most connections, but not so small that it causes
tcpspy to use too much CPU time.
Switch to the specified user after startup.
may be a numeric user id or a user name from the system password file.
Switch to the specified group after startup.
may be a numeric group id or a group name from the system group file.
If a username to switch to with the
option is specified but
is omitted, tcpspy will switch to that specified user's primary group.
Debugging mode; if this option is specified, tcpspy will not detach from the
console after initialisation, and will log connections to standard output
instead of syslog.
Log the filename of the executable that created/accepted the connection.
You may require superuser privileges to obtain this information for processes
you do not own (this is a kernel limitation).
This option can greatly increase the amount of CPU time required to
process each connection/disconnection.
A rule may be specified with the
option to log information about connections matching this rule, overriding
the default of logging all connections.
The following comparison operations are defined:
True if the local user initiating or accepting the connection has the
Same as above, but using a username instead of a user id.
True if the local end of the connection has port number
lport [low] - [high]
True if the local end of the connection has a port number
greater than or equal to
and less than or equal to
If the form
is used, high is assumed to be 65535.
If the form
is used, low is assumed to be 0. It is an error to omit both
low and high.
Same as above, but using a service name from
instead of a port number.
but compares the port number of the remote end of the connection.
Interpreted as a "net/mask" expression; true if "net" is equal to the bitwise
AND of the local address of the connection and "mask". If no mask is specified,
a default mask with all bits set (255.255.255.255) is used.
but compares the remote address.
True if the full filename (including directory) of the executable that
created/accepted the connection matches
The pattern "" (an empty string) matches connections created/accepted by
processes whose executable filename is unknown.
option is not specified, a warning message will be printed, and the result of
this comparison will always be true.
Expressions (including the comparisons listed above) may be joined together
with the following logical operations:
expr1 or expr2
True if either of
are true (logical OR).
expr1 and expr2
True if both
are true (logical AND).
is false (logical NOT).
Rules are evaluated from left to right. Whitespace (space, tab and newline)
characters are ignored between "words". Rules consisting of only whitespace
match no connections, but do not cause an error.
Parentheses, '(' and ')' may be placed around expressions to affect the order
The Examples section contains some sample rules which further demonstrate how
they are constructed.
The daemon was successfully started
An error occurred
Shut down at most
milliseconds from now.
(Debugging mode only) Handled identically to
All other signals retain their default behaviour, which is documented in
tcpspy -e 'user "joe" and rport "ssh"'
Log connections made by user "joe" for the service "ssh".
tcpspy -e 'not raddr 10.0.0.0/255.0.0.0 and rport 25 and (user "bob" or user "joe")'
Log connections made by users "bob" and "joe" to remote port 25 on machines
not on a fictional "intranet".
tcpspy -e 'exe "/usr/bin/irc"'
Log connections made by /usr/bin/irc (probably ircII).
Empty rule files cause
to log no connections instead of all connections.