Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ipfilter(4) [netbsd man page]

IPL(4)							     Kernel Interfaces Manual							    IPL(4)

ipl - IP packet log device DESCRIPTION
The ipl pseudo device's purpose is to provide an easy way to gather packet headers of packets you wish to log. If a packet header is to be logged, the entire header is logged (including any IP options - TCP/UDP options are not included when it calculates header size) or not at all. The packet contents are also logged after the header. If the log reader is busy or otherwise unable to read log records, up to IPLLOGSIZE (8192 is the default) bytes of data are stored. Prepending every packet header logged is a structure containing information relevant to the packet following and why it was logged. The structure's format is as follows: /* * Log structure. Each packet header logged is prepended by one of these. * Following this in the log records read from the device will be an ipflog * structure which is then followed by any packet data. */ typedef struct iplog { u_long ipl_sec; u_long ipl_usec; u_int ipl_len; u_int ipl_count; size_t ipl_dsize; struct iplog *ipl_next; } iplog_t; typedef struct ipflog { #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) u_char fl_ifname[IFNAMSIZ]; #else u_int fl_unit; u_char fl_ifname[4]; #endif u_char fl_plen; /* extra data after hlen */ u_char fl_hlen; /* length of IP headers saved */ u_short fl_rule; /* assume never more than 64k rules, total */ u_32_t fl_flags; } ipflog_t; When reading from the ipl device, it is necessary to call read(2) with a buffer big enough to hold at least 1 complete log record - reading of partial log records is not supported. If the packet contents are more than 128 bytes when log body is used, then only 128 bytes of the packet contents are logged. Although it is only possible to read from the ipl device, opening it for writing is required when using an ioctl which changes any kernel data. The ioctls which are loaded with this device can be found under ipf(4). The ioctls which are for use with logging and don't affect the filter are: ioctl(fd, SIOCIPFFB, int *) ioctl(fd, FIONREAD, int *) The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes flushed. FIONREAD returns the number of bytes currently used for storing log data. If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not available and FIONREAD will return but not do any- thing. There is currently no support for non-blocking IO with this device, meaning all read operations should be considered blocking in nature (if there is no data to read, it will sleep until some is made available). SEE ALSO
ipf(4) BUGS
Packet headers are dropped when the internal buffer (static size) fills. FILES
/dev/ipl IPL(4)

Check Out this Related Man Page

ipmon(8)						      System Manager's Manual							  ipmon(8)

ipmon - monitors /dev/ipl for logged packets SYNOPSIS
ipmon [ -abBDFhnpstvxX ] [ -N <device> ] [ -L <facility> ] [ -o [NSI] ] [ -O [NSI] ] [ -P <pidfile> ] [ -S <device> ] [ -f <device> ] [ <filename> ] DESCRIPTION
ipmon opens /dev/ipl for reading and awaits data to be saved from the packet filter. The binary data read from the device is reprinted in human readable for, however, IP#'s are not mapped back to hostnames, nor are ports mapped back to service names. The output goes to stan- dard output by default or a filename, if given on the command line. Should the -s option be used, output is instead sent to syslogd(8). Messages sent via syslog have the day, month and year removed from the message, but the time (including microseconds), as recorded in the log, is still included. Messages generated by ipmon consist of whitespace separated fields. Fields common to all messages are: 1. The date of packet receipt. This is suppressed when the message is sent to syslog. 2. The time of packet receipt. This is in the form HH:MM:SS.F, for hours, minutes seconds, and fractions of a second (which can be several digits long). 3. The name of the interface the packet was processed on, e.g., we1. 4. The group and rule number of the rule, e.g., @0:17. These can be viewed with ipfstat -n. 5. The action: p for passed, b for blocked, for a short packet, n did not match any rules or L for a log rule. 6. The addresses. This is actually three fields: the source address and port (separated by a comma), the -> symbol, and the destination address and port. E.g.:,80 ->,1722. 7. PR followed by the protocol name or number, e.g., PR tcp. 8. len followed by the header length and total length of the packet, e.g., len 20 40. If the packet is a TCP packet, there will be an additional field starting with a hyphen followed by letters corresponding to any flags that were set. See the ipf.conf manual page for a list of letters and their flags. If the packet is an ICMP packet, there will be two fields at the end, the first always being `icmp', and the next being the ICMP message and submessage type, separated by a slash, e.g., icmp 3/3 for a port unreachable message. In order for ipmon to properly work, the kernel option IPFILTER_LOG must be turned on in your kernel. Please see options(4) for more details. ipmon reopens its log file(s) and rereads its configuration file when it receives a SIGHUP signal. OPTIONS
-a Open all of the device logfiles for reading log entries from. All entries are displayed to the same output 'device' (stderr or sys- log). -b For rules which log the body of a packet, generate hex output representing the packet contents after the headers. -B <binarylogfilename> Enable logging of the raw, unformatted binary data to the specified <binarylogfilename> file. This can be read, later, using ipmon with the -f option. -D Cause ipmon to turn itself into a daemon. Using subshells or backgrounding of ipmon is not required to turn it into an orphan so it can run indefinitely. -f <device> specify an alternative device/file from which to read the log information for normal IP Filter log records. -F Flush the current packet log buffer. The number of bytes flushed is displayed, even should the result be zero. -L <facility> Using this option allows you to change the default syslog facility that ipmon uses for syslog messages. The default is local0. -n IP addresses and port numbers will be mapped, where possible, back into hostnames and service names. -N <device> Set the logfile to be opened for reading NAT log records from to <device>. -o Specify which log files to actually read data from. N - NAT logfile, S - State logfile, I - normal IP Filter logfile. The -a option is equivalent to using -o NSI. -O Specify which log files you do not wish to read from. This is most sensibly used with the -a. Letters available as parameters to this are the same as for -o. -p Cause the port number in log messages to always be printed as a number and never attempt to look it up as from /etc/services, etc. -P <pidfile> Write the pid of the ipmon process to a file. By default this is //etc/opt/ipf/ (Solaris), /var/run/ (44BSD or later) or /etc/ for all others. -s Packet information read in will be sent through syslogd rather than saved to a file. The default facility when compiled and installed is security. The following levels are used: LOG_INFO - packets logged using the "log" keyword as the action rather than pass or block. LOG_NOTICE - packets logged which are also passed LOG_WARNING - packets logged which are also blocked LOG_ERR - packets which have been logged and which can be considered "short". -S <device> Set the logfile to be opened for reading state log records from to <device>. -t read the input file/device in a manner akin to tail(1). -v show tcp window, ack and sequence fields. -x show the packet data in hex. -X show the log header record data in hex. DIAGNOSTICS
ipmon expects data that it reads to be consistent with how it should be saved and will abort if it fails an assertion which detects an anomaly in the recorded data. FILES
/dev/ipl /dev/ipnat /dev/ipstate /etc/services SEE ALSO
ipl(4), ipf(8), ipfstat(8), ipnat(8) BUGS
If you find any, please send email to me at ipmon(8)
Man Page