diff options
author | darrenr <darrenr@FreeBSD.org> | 1997-02-09 22:50:16 +0000 |
---|---|---|
committer | darrenr <darrenr@FreeBSD.org> | 1997-02-09 22:50:16 +0000 |
commit | cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717 (patch) | |
tree | 93c7db298b1fd70f9e27663b3fd527da063d0008 /contrib/ipfilter/man | |
download | FreeBSD-src-cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717.zip FreeBSD-src-cb8d46a179f2d30ac1cd0a01eb156e1a4c08d717.tar.gz |
Import IP Filter v3.1.7 into FreeBSD tree
Diffstat (limited to 'contrib/ipfilter/man')
-rw-r--r-- | contrib/ipfilter/man/Makefile | 21 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipf.1 | 109 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipf.4 | 184 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipf.5 | 433 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipfstat.8 | 73 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipftest.1 | 127 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipl.4 | 62 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipmon.8 | 56 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipnat.1 | 45 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipnat.4 | 88 | ||||
-rw-r--r-- | contrib/ipfilter/man/ipnat.5 | 70 |
11 files changed, 1268 insertions, 0 deletions
diff --git a/contrib/ipfilter/man/Makefile b/contrib/ipfilter/man/Makefile new file mode 100644 index 0000000..c62e54c --- /dev/null +++ b/contrib/ipfilter/man/Makefile @@ -0,0 +1,21 @@ +# +# (C)opyright 1993, 1994, 1995 by Darren Reed. +# +# This code may be freely distributed as long as it retains this notice +# and is not changed in any way. The author accepts no responsibility +# for the use of this software. I hate legaleese, don't you ? + +all: + +install: + $(INSTALL) -m 0644 -c -o root -g bin ipf.1 $(MANDIR)/man1 + $(INSTALL) -m 0644 -c -o root -g bin ipftest.1 $(MANDIR)/man1 + $(INSTALL) -m 0644 -c -o root -g bin ipnat.1 $(MANDIR)/man1 + $(INSTALL) -m 0644 -c -o root -g bin ipf.4 $(MANDIR)/man4 + $(INSTALL) -m 0644 -c -o root -g bin ipl.4 $(MANDIR)/man4 + $(INSTALL) -m 0644 -c -o root -g bin ipnat.4 $(MANDIR)/man4 + $(INSTALL) -m 0644 -c -o root -g bin ipf.5 $(MANDIR)/man5 + $(INSTALL) -m 0644 -c -o root -g bin ipnat.5 $(MANDIR)/man5 + $(INSTALL) -m 0644 -c -o root -g bin ipmon.8 $(MANDIR)/man8 + $(INSTALL) -m 0644 -c -o root -g bin ipfstat.8 $(MANDIR)/man8 + @echo "Remember to rebuild the whatis database." diff --git a/contrib/ipfilter/man/ipf.1 b/contrib/ipfilter/man/ipf.1 new file mode 100644 index 0000000..912d7ef --- /dev/null +++ b/contrib/ipfilter/man/ipf.1 @@ -0,0 +1,109 @@ +.TH IPF 1 +.SH NAME +ipf \- alters packet filtering lists for IP packet input and ouput +.SH SYNOPSIS +.B ipf +[ +.B \-AdDEInorsUvyzZ +] [ +.B \-l +<block|pass|nomatch> +] [ +.B \-F +<i|o|a> +] +.B \-f +<\fIfilename\fP> +[ +.B \-f +<\fIfilename\fP> +[...]] +.SH DESCRIPTION +.PP +\fBipf\fP opens the filenames listed (treating "\-" as stdin) and parses the +file for a set of rules which are to be added or removed from the packet +filter rule set. +.PP +Each rule processed by \fBipf\fP +is added to the kernel's internal lists if there are no parsing problems. +Rules are added to the end of the internal lists, matching the order in +which they appear when given to \fBipf\fP. +.SH OPTIONS +.TP +.B \-A +Set the list to make changes to the active list (default). +.TP +.B \-d +Turn debug mode on. Causes a hexdump of filter rules to be generated as +it processes each one. +.TP +.B \-D +Disable the filter (if enabled). Not effective for loadable kernel versions. +.TP +.B \-E +Enable the filter (if disabled). Not effective for loadable kernel versions. +.TP +.BR \-F \0<param> +This option specifies which filter list to flush. The parameter should +either be "i" (input), "o" (output) or "a" (remove all filter rules). +Either a single letter or an entire word starting with the appropriate +letter maybe used. This option maybe before, or after, any other with +the order on the command line being that used to execute options. +.TP +.BR \-f \0<filename> +This option specifies which files +\fBipf\fP should use to get input from for modifying the packet filter rule +lists. +.TP +.B \-I +Set the list to make changes to the inactive list. +.TP +.B \-l \0<param> +Use of the \fB-l\fP flag toggles default logging of packets. Valid +arguments to this option are \fBpass\fP, \fBblock\fP and \fBnomatch\fP. +When an option is set, any packet which exits filtering and matches the +set category is logged. This is most useful for causing all packets +which don't match any of the loaded rules to be logged. +.TP +.B \-n +This flag (no-change) prevents \fBipf\fP from actually making any ioctl +calls or doing anything which would alter the currently running kernel. +.TP +.B \-o +Force rules by default to be added/deleted to/from the output list, rather +than the (default) input list. +.TP +.B \-r +Remove matching filter rules rather than add them to the internal lists +.TP +.B \-s +Swap the active filter list in use to be the "other" one. +.TP +.B \-U +(SOLARIS 2 ONLY) Block packets travelling along the data stream which aren't +recognised as IP packets. They will be printed out on the console. +.TP +.B \-v +Turn verbose mode on. Displays information relating to rule processing. +.TP +.B \-y +(SOLARIS 2 ONLY) Manually resync the in-kernel interface list maintained +by IP Filter with the current interface status list. +.TP +.B \-z +For each rule in the input file, reset the statistics for it to zero and +display the statistics prior to them being zero'd. +.TP +.B \-Z +Zero global statistics held in the kernel for filtering only (this doesn't +affect fragment or state statistics). +.DT +.SH SEE ALSO +ipfstat(1), ipftest(1), ipf(5) +.SH DIAGNOSTICS +.PP +Needs to be run as root for the packet filtering lists to actually +be affected inside the kernel. +.SH BUGS +.PP +If you find any, please send email to me at darrenr@cyber.com.au diff --git a/contrib/ipfilter/man/ipf.4 b/contrib/ipfilter/man/ipf.4 new file mode 100644 index 0000000..ff17f4f --- /dev/null +++ b/contrib/ipfilter/man/ipf.4 @@ -0,0 +1,184 @@ +.TH IPF 4 +.SH NAME +ipf \- packet filtering kernel interface +.SH SYNOPSIS +#include <sys/ip_fil.h> +.SH IOCTLS +.PP +To add and delete rules to the filter list, three 'basic' ioctls are provided +for use. The ioctl's are called as: +.LP +.nf + ioctl(fd, SIOCADDFR, struct frentry *) + ioctl(fd, SIOCDELFR, struct frentry *) + ioctl(fd, SIOCIPFFL, int *) +.fi +.PP +However, the full complement is as follows: +.LP +.nf + ioctl(fd, SIOCADAFR, struct frentry *) (same as SUICADDFR) + ioctl(fd, SIOCRMAFR, struct frentry *) (same as SUICDELFR) + ioctl(fd, SIOCADIFR, struct frentry *) + ioctl(fd, SIOCRMIFR, struct frentry *) + ioctl(fd, SIOCINAFR, struct frentry *) + ioctl(fd, SIOCINIFR, struct frentry *) + ioctl(fd, SIOCIPFFL, int *) +.fi +.PP +The variations, SIOCADAFR vs. SIOCADIFR, allow operation on the two lists, +active and inactive, respectively. All of these ioctl's are implemented +as being routing ioctls and thus the same rules for the various routing +ioctls and the file descriptor are employed, mainly being that the fd must +be that of the device associated with the module (i.e., /dev/ipl). +.LP +.PP +The three groups of ioctls above perform adding rules to the end of the +list (SIOCAD*), deletion of rules from any place in the list (SIOCRM*) +and insertion of a rule into the list (SIOCIN*). The rule place into +which it is inserted is stored in the "fr_hits" field, below. +.LP +.nf +typedef struct frentry { + struct frentry *fr_next; + struct ifnet *fr_ifa; + u_long fr_hits; + u_long fr_bytes; /* this is only incremented when a packet */ + /* stops matching on this rule */ + /* + * Fields after this may not change whilst in the kernel. + */ + struct fr_ip fr_ip; + struct fr_ip fr_mip; + + u_char fr_tcpfm; /* tcp flags mask */ + u_char fr_tcpf; /* tcp flags */ + + u_short fr_icmpm; /* data for ICMP packets (mask) */ + u_short fr_icmp; + + u_char fr_scmp; /* data for port comparisons */ + u_char fr_dcmp; + u_short fr_dport; + u_short fr_sport; + u_short fr_stop; /* top port for <> and >< */ + u_short fr_dtop; /* top port for <> and >< */ + u_long fr_flags; /* per-rule flags && options (see below) */ + int (*fr_func)(); /* call this function */ + char fr_icode; /* return ICMP code */ + char fr_ifname[IFNAMSIZ]; + struct frdest fr_tif; /* "to" interface */ + struct frdest fr_dif; /* duplicate packet interfaces */ +} frentry_t; +.fi +.PP +When adding a new rule, all unused fields (in the filter rule) should be +initialised to be zero. To insert a rule, at a particular position in the +filter list, the number of the rule which it is to be inserted before must +be put in the "fr_hits" field (the first rule is number 0). +.LP +.PP +Flags which are recognised in fr_pass: +.nf + + FR_BLOCK 0x00001 /* do not allow packet to pass */ + FR_PASS 0x00002 /* allow packet to pass */ + FR_OUTQUE 0x00004 /* outgoing packets */ + FR_INQUE 0x00008 /* ingoing packets */ + FR_LOG 0x00010 /* Log */ + FR_LOGP 0x00011 /* Log-pass */ + FR_LOGB 0x00012 /* Log-fail */ + FR_LOGBODY 0x00020 /* log the body of packets too */ + FR_LOGFIRST 0x00040 /* log only the first packet to match */ + FR_RETRST 0x00080 /* return a TCP RST packet if blocked */ + FR_RETICMP 0x00100 /* return an ICMP packet if blocked */ + FR_NOMATCH 0x00200 /* no match occured */ + FR_ACCOUNT 0x00400 /* count packet bytes */ + FR_KEEPFRAG 0x00800 + FR_KEEPSTATE 0x01000 /* keep packet flow state information */ + FR_INACTIVE 0x02000 + FR_QUICK 0x04000 /* quick-match and return */ + FR_FASTROUTE 0x08000 + FR_CALLFUNC 0x10000 + FR_CALLNOW 0x20000 + FR_DUP 0x40000 /* duplicate the packet (not Solaris2) + +.fi +.PP +Values for fr_scomp and fr_dcomp (source and destination port value +comparisons) : +.LP +.nf + FR_NONE 0 + FR_EQUAL 1 + FR_NEQUAL 2 + FR_LESST 3 + FR_GREATERT 4 + FR_LESSTE 5 + FR_GREATERTE 6 + FR_OUTRANGE 7 + FR_INRANGE 8 +.fi +.PP +The third ioctl, SIOCIPFFL, flushes either the input filter list, the +output filter list or both and it returns the number of filters removed +from the list(s). The values which it will take and recognise are FR_INQUE +and FR_OUTQUE (see above). + +\fBGeneral Logging Flags\fP +There are two flags which can be set to log packets independantly of the +rules used. These allow for packets which are either passed or blocked +to be logged. To set (and clear)/get these flags, two ioctls are +provided: +.IP SIOCSETFF 16 +Takes an unsigned integer as the parameter. The flags are then set to +those provided (clearing/setting all in one). +.nf + + FF_LOGPASS 1 + FF_LOGBLOCK 2 +.fi +.IP SIOCGETFF 16 +Takes a pointer to an unsigned integer as the parameter. A copy of the +flags currently in used is copied to user space. +.LP +\fBFilter statistics\fP +Statistics on the various operations performed by this package on packets +is kept inside the kernel. These statistics apply to packets traversing +through the kernel. To retrieve this structure, use this ioctl: +.nf + + ioctl(fd, SIOCGETFS, struct friostat *) + +struct friostat { + struct filterstats f_st[2]; + struct frentry *f_fin; + struct frentry *f_fout; +}; + +struct filterstats { + u_long fr_pass; /* packets allowed */ + u_long fr_block; /* packets denied */ + u_long fr_nom; /* packets which don't match any rule */ + u_long fr_ppkl; /* packets allowed and logged */ + u_long fr_bpkl; /* packets denied and logged */ + u_long fr_npkl; /* packets unmatched and logged */ + u_long fr_pkl; /* packets logged */ + u_long fr_skip; /* packets to be logged but buffer full */ + u_long fr_ret; /* packets for which a return is sent */ + u_long fr_acct; /* packets for which counting was performed */ + u_long fr_bnfr; /* bad attempts to allocate fragment state */ + u_long fr_nfr; /* new fragment state kept */ + u_long fr_cfr; /* add new fragment state but complete pkt */ + u_long fr_bads; /* bad attempts to allocate packet state */ + u_long fr_ads; /* new packet state kept */ + u_long fr_chit; /* cached hit */ +#if SOLARIS + u_long fr_bad; /* bad IP packets to the filter */ + u_long fr_notip; /* packets passed through no on ip queue */ + u_long fr_drop; /* packets dropped - no info for them! */ +#endif +}; +.fi +.SH SEE ALSO +ipfstat(1), ipf(1), ipf(5) diff --git a/contrib/ipfilter/man/ipf.5 b/contrib/ipfilter/man/ipf.5 new file mode 100644 index 0000000..417a0ea --- /dev/null +++ b/contrib/ipfilter/man/ipf.5 @@ -0,0 +1,433 @@ +.TH IPF 5 +.SH NAME +ipf \- IP packet filter rule syntax +.SH DESCRIPTION +.PP +A rule file for \fBipf\fP may have any name or even be stdin. As +\fBipfstat\fP produces parseable rules as output when displaying the internal +kernel filter lists, it is quite plausible to use its output to feed back +into \fBipf\fP. Thus, to remove all filters on input packets, the following +could be done: +.nf + +\fC# ipfstat \-i | ipf \-rf \-\fP +.fi +.SH GRAMMAR +.PP +The format used by \fBipf\fP for construction of filtering rules can be +described using the following grammar in BNF: +\fC +.nf +filter-rule = [ insert ] action in-out [ options ] [ match ] [ keep ] + +insert = "@" decnumber . +action = block | "pass" | log | "count" | call . +in-out = "in" | "out" . +options = [ log ] [ "quick" ] [ "on" interface-name [ dup ] [ froute ] ] . +match = [ tos ] [ ttl ] [ proto ] [ ip ] . +keep = "keep state" | "keep frags" . + +block = "block" [ "return-icmp"[return-code] | "return-rst" ] . +log = "log" [ "body" ] [ "first" ] [ "or-block" ] . +call = "call" [ "now" ] function-name . + +dup = "dup-to" interface-name[":"ipaddr] . +froute = "fastroute" | "to" interface-name . + +tos = "tos" decnumber | "tos" hexnumber . +ttl = "ttl" decnumber . +proto = "proto" protocol . +ip = srcdst [ flags ] [ with withopt ] [ icmp ] [ keep ] . + +protocol = "tcp/udp" | "udp" | "tcp" | "icmp" | decnumber . +srcdst = "all" | fromto . +fromto = "from" object "to" object . + +object = addr [ port-comp | port-range ] . +addr = "any" | nummask | host-name [ "mask" ipaddr | "mask" hexnumber ] . +port-comp = "port" compare port-num . +port-range = "port" port-num range port-num . + +flags = "flags" flag { flag } [ "/" flag { flag } ] . +with = "with" | "and" . +icmp = "icmp-type" icmp-type [ "code" decnumber ] . +return-code = "("icmp-code")" . + +nummask = host-name [ "/" decnumber ] . +host-name = ipaddr | hostname | "any" . +ipaddr = host-num "." host-num "." host-num "." host-num . +host-num = digit [ digit [ digit ] ] . +port-num = service-name | decnumber . + +withopt = [ "not" | "no" ] opttype [ withopt ] . +opttype = "ipopts" | "short" | "frag" | "opt" ipopts . +optname = ipopts [ "," optname ] . +ipopts = optlist | "sec-class" [ secname ] . +secname = seclvl [ "," secname ] . +seclvl = "unclass" | "confid" | "reserv-1" | "reserv-2" | "reserv-3" | + "reserv-4" | "secret" | "topsecret" . +icmp-type = "unreach" | "echo" | "echorep" | "squench" | "redir" | + "timex" | "paramprob" | "timest" | "timestrep" | "inforeq" | + "inforep" | "maskreq" | "maskrep" | decnumber . +icmp-code = decumber | "net-unr" | "host-unr" | "proto-unr" | "port-unr" | + "needfrag" | "srcfail" | "net-unk" | "host-unk" | "isolate" | + "net-prohib" | "host-prohib" | "net-tos" | "host-tos" . +optlist = "nop" | "rr" | "zsu" | "mtup" | "mtur" | "encode" | "ts" | "tr" | + "sec" | "lsrr" | "e-sec" | "cipso" | "satid" | "ssrr" | "addext" | + "visa" | "imitd" | "eip" | "finn" . + +hexnumber = "0" "x" hexstring . +hexstring = hexdigit [ hexstring ] . +decnumber = digit [ decnumber ] . + +compare = "=" | "!=" | "<" | ">" | "<=" | ">=" | "eq" | "ne" | "lt" | "gt" | + "le" | "ge" . +range = "<>" | "><" . +hexdigit = digit | "a" | "b" | "c" | "d" | "e" | "f" . +digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" . +flag = "F" | "S" | "R" | "P" | "A" | "U" . +.fi +.PP +This syntax is somewhat simplified for readability, some combinations +that match this grammar are disallowed by the software because they do +not make sense (such as tcp \fBflags\fP for non-TCP packets). +.SH FILTER RULES +.PP +The "briefest" valid rules are (currently) no-ops and are of the form: +.nf + block in + pass in + log in + count in +.fi +.PP +These are supposed to be the same as, but currently differ from: +.\" XXX How, why do they differ?? +.nf + block in all + pass in from any to any + log in all + count in all +.fi +.PP +Filter rules are checked in order, with the last matching rule +determining the fate of the packet (but see the \fBquick\fP option, +below). +.PP +Filters are installed by default at the end of the kernel's filter +lists, prepending the rule with \fB@n\fP will cause it to be inserted +as the n'th entry in the current list. This is especially useful when +modifying and testing active filter rulesets. See ipf(1) for more +information. +.SH ACTIONS +.PP +The action indicates what to do with the packet if it matches the rest +of the filter rule. Each rule MUST have an action. The following +actions are recognised: +.TP +.B block +indicates that the packet should be flagged to be dropped. In response +to blocking a packet, the filter may be instructed to send a reply +packet, either an ICMP packet (\fBreturn-icmp\fP) or a TCP "reset" +(\fBreturn-rst\fP). An ICMP packet may be generated in response to +any IP packet, and its type may optionally be specified, but a TCP +reset may only be used with a rule which is being applied to TCP +packets. +.TP +.B pass +will flag the packet to be let through the filter. +.TP +.B log +causes the packet to be logged (as described in the LOGGING section +below) and has no effect on whether the packet will be allowed through +the filter. +.TP +.B count +causes the packet to be included in the accounting statistics kept by +the filter, and has no effect on whether the packet will be allowed through +the filter. These statistics are viewable with ipfstat(8). +.TP +.B call +this action is used to invoke the named function in the kernel, which +must conform to a specific calling interface. Customised actions and +semantics can thus be implemented to supplement those available. This +feature is for use by knowledgeable hackers, and is not currently +documented. +.PP +The next word must be either \fBin\fP or \fBout\fP. Each packet +moving through the kernel is either inbound (just been received on an +interface, and moving towards the kernel's protocol processing) or +outbound (transmitted or forwarded by the stack, and on its way to an +interface). There is a requirement that each filter rule explicitly +state which side of the I/O it is to be used on. +.SH OPTIONS +.PP +The list of options is brief, and all are indeed optional. Where +options are used, they must be present in the order shown here. These +are the currently supported options: +.TP +.B log +indicates that, should this be the last matching rule, the packet +header will be written to the \fBipl\fP log (as described in the +LOGGING section below). +.TP +.B quick +allows "short-cut" rules in order to speed up the filter or override +later rules. If a packet matches a filter rule which is marked as +\fBquick\fP, this rule will be the last rule checked, allowing a +"short-circuit" path to avoid processing later rules for this +packet. The current status of the packet (after any effects of the +current rule) will determine whether it is passed or blocked. +.IP +If this option is missing, the rule is taken to be a "fall-through" +rule, meaning that the result of the match (block/pass) is saved and +that processing will continue to see if there are any more matches. +.TP +.B on +allows an interface name to be incorporated into the matching +procedure. Interface names are as printed by "netstat \-i". If this +option is used, the rule will only match if the packet is going +through that interface in the specified direction (in/out). If this +option is absent, the rule is taken to be applied to a packet +regardless of the interface it is present on (i.e. on all interfaces). +Filter rulesets are common to all interfaces, rather than having a +filter list for each interface. +.IP +This option is especially useful for simple IP-spoofing protection: +packets should only be allowed to pass inbound on the interface from +which the specified source address would be expected, others may be +logged and/or dropped. +.TP +.B dup-to +causes the packet to be copied, and the duplicate packet to be sent outbound on the specified interface, optionally with the destination IP address changed to that specified. This is useful for off-host logging, using a network sniffer. +.TP +.B to +causes the packet to be moved to the outbound queue on the +specified interface. This can be used to circumvent kernel routing +decisions, and even to bypass the rest of the kernel processing of the +packet (if applied to an inbound rule). It is thus possible to +construct a firewall that behaves transparently, like a filtering hub +or switch, rather than a router. The \fBfastroute\fP keyword is a +synonym for this option. +.SH MATCHING PARAMETERS +.PP +The keywords described in this section are used to describe attributes +of the packet to be used when determining whether rules match or don't +match. The following general-purpose attributes are provided for +matching, and must be used in this order: +.TP +.B tos +packets with different Type-Of-Service values can be filtered. +Individual service levels or combinations can be filtered upon. The +value for the TOS mask can either be represented as a hex number or a +decimal integer value. +.\" XXX TOS mask?? not in grammar! +.TP +.B ttl +packets may also be selected by their Time-To-Live value. The value given in +the filter rule must exactly match that in the packet for a match to occur. +This value can only be given as a decimal integer value. +.TP +.B proto +allows a specific protocol to be matched against. All protocol names +found in \fB/etc/protocols\fP are recognised and may be used. +However, the protocol may also be given as a DECIMAL number, allowing +for rules to match your own protocols, or new ones which would +out-date any attempted listing. +.IP +The special protocol keyword \fBtcp/udp\fP may be used to match either +a TCP or a UDP packet, and has been added as a convenience to save +duplication of otherwise-identical rules. +.\" XXX grammar should reflect this (/etc/protocols) +.PP +The \fBfrom\fP and \fBto\fP keywords are used to match against IP +addresses (and optionally port numbers). Rules must specify BOTH +source and destination parameters. +.PP +IP addresses may be specified in one of two ways: as a numerical +address\fB/\fPmask, or as a hostname \fBmask\fP netmask. The hostname +may either be a valid hostname, from either the hosts file or DNS +(depending on your configuration and library) or of the dotted numeric +form. There is no special designation for networks but network names +are recognised. Note that having your filter rules depend on DNS +results can introduce an avenue of attack, and is discouraged. +.PP +There is a special case for the hostname \fBany\fP which is taken to +be 0.0.0.0/0 (see below for mask syntax) and matches all IP addresses. +Only the presence of "any" has an implied mask, in all other +situations, a hostname MUST be accompanied by a mask. It is possible +to give "any" a hostmask, but in the context of this language, it is +non-sensical. +.PP +The numerical format "x\fB/\fPy" indicates that a mask of y +consecutive 1 bits set is generated, starting with the MSB, so a y value +of 16 would give 0xffff0000. The symbolic "x \fBmask\fP y" indicates +that the mask y is in dotted IP notation or a hexadecimal number of +the form 0x12345678. Note that all the bits of the IP address +indicated by the bitmask must match the address on the packet exactly; +there isn't currently a way to invert the sense of the match, or to +match ranges of IP addresses which do not express themselves easily as +bitmasks (anthropomorphization; it's not just for breakfast anymore). +.PP +If a \fBport\fP match is included, for either or both of source and +destination, then it is only applied to +.\" XXX - "may only be" ? how does this apply to other protocols? will it not match, or will it be ignored? +TCP and UDP packets. If there is no \fBproto\fP match parameter, +packets from both protocols are compared. This is equivalent to "proto +tcp/udp". When composing \fBport\fP comparisons, either the service +name or an integer port number may be used. Port comparisons may be +done in a number of forms, with a number of comparison operators, or +port ranges may be specified. See the examples for more information. +.PP +The \fBall\fP keyword is essentially a synonym for "from any to any" +with no other match parameters. +.PP +Following the source and destination matching parameters, the +following additional parameters may be used: +.TP +.B with +is used to match irregular attributes that some packets may have +associated with them. To match the presence of IP options in general, +use \fBwith ipopts\fP. To match packets that are too short to contain +a complete header, use \fBwith short\fP. To match fragmented packets, +use \fBwith frag\fP. For more specific filtering on IP options, +individual options can be listed. +.IP +Before any parameter used after the \fBwith\fP keyword, the word +\fBnot\fP or \fBno\fP may be inserted to cause the filter rule to only +match if the option(s) is not present. +.IP +Multiple consecutive \fBwith\fP clauses are allowed. Alternatively, +the keyword \fBand\fP may be used in place of \fBwith\fP, this is +provided purely to make the rules more readable ("with ... and ..."). +When multiple clauses are listed, all those must match to cause a +match of the rule. +.\" XXX describe the options more specifically in a separate section +.TP +.B flags +is only effective for TCP filtering. Each of the letters possible +represents one of the possible flags that can be set in the TCP +header. The association is as follows: +.LP +.nf + F - FIN + S - SYN + R - RST + P - PUSH + A - ACK + U - URG +.fi +.IP +The various flag symbols may be used in combination, so that "SA" +would represent a SYN-ACK combination present in a packet. There is +nothing preventing the specification of combinations, such as "SFR", +that would not normally be generated by law-abiding TCP +implementations. However, to guard against weird aberrations, it is +necessary to state which flags you are filtering against. To allow +this, it is possible to set a mask indicating which TCP flags you wish +to compare (i.e., those you deem significant). This is done by +appending "/<flags>" to the set of TCP flags you wish to match +against, e.g.: +.LP +.nf + ... flags S + # becomes "flags S/AUPRFS" and will match + # packets with ONLY the SYN flag set. + + ... flags SA + # becomes "flags SA/AUPRFS" and will match any + # packet with only the SYN and ACK flags set. + + ... flags S/SA + # will match any packet with just the SYN flag set + # out of the SYN-ACK pair; the common "establish" + # keyword action. "S/SA" will NOT match a packet + # with BOTH SYN and ACK set, but WILL match "SFP". +.fi +.TP +.B icmp-type +is only effective when used with \fBproto icmp\fP and must NOT be used +in conjuction with \fBflags\fP. There are a number of types, which can be +referred to by an abbreviation recognised by this language, or the numbers +with which they are associated can be used. The most important from +a security point of view is the ICMP redirect. +.SH KEEP HISTORY +.PP +The last parameter which can be set for a filter rule is whether on not to +record historical information for that packet, and what sort to keep. The following information can be kept: +.TP +.B state +keeps information about the flow of a communication session. State can +be kept for TCP, UDP, and ICMP packets. +.TP +.B frags +keeps information on fragmented packets, to be applied to later +fragments. +.PP +allowing packets which match these to flow straight through, rather +than going through the access control list. +.SH LOGGING +.PP +When a packet is logged, with either the \fBlog\fP action or option, +the headers of the packet are written to the \fBipl\fP packet logging +psuedo-device. Immediately following the \fBlog\fP keyword, the +following qualifiers may be used (in order): +.TP +.B body +indicates that the first 128 bytes of the packet contents will be +logged after the headers. +.TP +.B first +?? +.TP +.B or-block +indicates that, if for some reason the filter is unable to log the packet (such as the log reader being too slow) then the rule should be interpreted as if the action was \fBblock\fP for this packet. +.PP +See ipl(4) for the format of records written +to this device. The ipmon(8) program can be used to read and format +this log. +.SH EXAMPLES +.PP +The \fBquick\fP option is good for rules such as: +\fC +.nf +block in quick from any to any with ipopts +.fi +.PP +which will match any packet with a non-standard header length (IP +options present) and abort further processing of later rules, +recording a match and also that the packet should be blocked. +.PP +The "fall-through" rule parsing allows for effects such as this: +.LP +.nf + block in from any to any port < 6000 + pass in from any to any port >= 6000 + block in from any to port > 6003 +.fi +.PP +which sets up the range 6000-6003 as being permitted and all others being +denied. Note that the effect of the first rule is overridden by subsequent +rules. Another (easier) way to do the same is: +.LP +.nf + block in from any to any port 6000 <> 6003 + pass in from any to any port 5999 >< 6004 +.fi +.PP +Note that both the "block" and "pass" are needed here to effect a +result as a failed match on the "block" action does not imply a pass, +only that the rule hasn't taken effect. To then allow ports < 1024, a +rule such as: +.LP +.nf + pass in quick from any to any port < 1024 +.fi +.PP +would be needed before the first block. +.SH FILES +/etc/services +.br +/etc/hosts +.SH SEE ALSO +ipf(1), ipftest(1) diff --git a/contrib/ipfilter/man/ipfstat.8 b/contrib/ipfilter/man/ipfstat.8 new file mode 100644 index 0000000..db23e39 --- /dev/null +++ b/contrib/ipfilter/man/ipfstat.8 @@ -0,0 +1,73 @@ +.TH ipfstat 8 +.SH NAME +ipfstat \- reports on packet filter statistics and filter list +.SH SYNOPSIS +.B ipfstat +[ +.B \-hIinov +] [ +.B \-d +<device> +] +.SH DESCRIPTION +.PP +\fBipfstat\fP examines /dev/kmem using the symbols \fB_fr_flags\fP, +\fB_frstats\fP, \fB_filterin\fP, and \fB_filterout\fP. +To run and work, it needs to be able to read both /dev/kmem and the +kernel itself. The kernel name defaults to \fB/vmunix\fP. +.PP +The default behaviour of \fBipfstat\fP +is to retrieve and display the accumulated statistics which have been +accumulated over time as the kernel has put packets through the filter. +.SH OPTIONS +.TP +.B \-a +Display the accounting filter list and show bytes counted against each rule. +.TP +.BR \-d \0<device> +Use a device other than \fB/dev/ipl\fP for interfacing with the kernel. +.TP +.B \-f +Show fragment state information (statistics) and held state information (in +the kernel) if any is present. +.TP +.B \-h +Show per-rule the number of times each one scores a "hit". For use in +combination with \fB\-i\fP. +.TP +.B \-i +Display the filter list used for the input side of the kernel IP processing. +.TP +.B \-I +Swap between retrieving "inactive"/"active" filter list details. For use +in combination with \fB\-i\fP. +.TP +.B \-n +Show the "rule number" for each rule as it is printed. +.TP +.B \-o +Display the filter list used for the output side of the kernel IP processing. +.TP +.B \-s +Show packet/flow state information (statistics) and held state information (in +the kernel) if any is present. +.TP +.B \-v +Turn verbose mode on. Displays more debugging information. +.SH SYNOPSIS +The role of \fBipfstat\fP is to display current kernel statistics gathered +as a result of applying the filters in place (if any) to packets going in and +out of the kernel. This is the default operation when no command line +parameters are present. +.PP +When supplied with either \fB\-i\fP or \fB\-o\fP, it will retrieve and display +the appropriate list of filter rules currently installed and in use by the +kernel. +.SH FILES +/dev/kmem +.br +/vmunix +.SH SEE ALSO +ipf(1), ipfstat(1) +.SH BUGS +none known. diff --git a/contrib/ipfilter/man/ipftest.1 b/contrib/ipfilter/man/ipftest.1 new file mode 100644 index 0000000..912b3a3 --- /dev/null +++ b/contrib/ipfilter/man/ipftest.1 @@ -0,0 +1,127 @@ +.TH ipftest 8 +.SH NAME +ipftest \- test packet filter rules with arbitary input. +.SH SYNOPSIS +.B ipftest +[ +.B \-vbdPSTEHX +] [ +.B \-I +interface +] +.B \-r +<filename> +[ +.B \-i +<filename> +] +.SH DESCRIPTION +.PP +\fBipftest\fP is provided for the purpose of being able to test a set of +filter rules without having to put them in place, in operation and proceed +to test their effectiveness. The hope is that this minimises disruptions +in providing a secure IP environment. +.PP +\fBipftest\fP will parse any standard ruleset for use with \fBipf\fP +and apply input, returning output as to the result. However, \fBipftest\fP +will return one of three values for packets passed through the filter: +pass, block or nomatch. This is intended to give the operator a better +idea of what is happening with packets passing through their filter +ruleset. +.PP +When used without either of \fB\-S\fP, \fB\-T\fP or \fB\-E\fP, +\fBipftest\fP uses its own text input format to generate "fake" IP packets. +The format used is as follows: +.nf + "in"|"out" "on" if ["tcp"|"udp"|"icmp"] + srchost[,srcport] dsthost[,destport] [FSRPAU] +.fi +.PP +This allows for a packet going "in" or "out" of an interface (if) to be +generated, being one of the three main protocols (optionally), and if +either TCP or UDP, a port parameter is also expected. If TCP is selected, +it is possible to (optionally) supply TCP flags at the end. Some examples +are: +.nf + # a UDP packet coming in on le0 + in on le0 udp 10.1.1.1,2210 10.2.1.5,23 + # an IP packet coming in on le0 from localhost - hmm :) + in on le0 localhost 10.4.12.1 + # a TCP packet going out of le0 with the SYN flag set. + out on le0 tcp 10.4.12.1,2245 10.1.1.1,23 S +.fi +.SH OPTIONS +.TP +.B \-v +Verbose mode. This provides more information about which parts of rule +matching the input packet passes and fails. +.TP +.B \-d +Turn on filter rule debugging. Currently, this only shows you what caused +the rule to not match in the IP header checking (addresses/netmasks, etc). +.TP +.B \-b +Cause the output to be a brief summary (one-word) of the result of passing +the packet through the filter; either "pass", "block" or "nomatch". +This is used in the regression testing. +.TP +.BR \-I \0<interface> +Set the interface name (used in rule matching) to be the name supplied. +This is useful with the \fB\-P, \-S, \-T\fP and \fB\-E\fP options, where it is +not otherwise possible to associate a packet with an interface. Normal +"text packets" can override this setting. +.TP +.B \-P +The input file specified by \fB\-i\fP is a binary file produced using libpcap +(i.e., tcpdump version 3). Packets are read from this file as being input +(for rule purposes). An interface maybe specified using \fB\-I\fP. +.TP +.B \-S +The input file is to be in "snoop" format (see RFC 1761). Packets are read +from this file and used as input from any interface. This is perhaps the +most useful input type, currently. +.TP +.B \-T +The input file is to be text output from tcpdump. The text formats which +are currently supported are those which result from the following tcpdump +option combinations: +.PP +.nf + tcpdump -n + tcpdump -nq + tcpdump -nqt + tcpdump -nqtt + tcpdump -nqte +.fi +.LP +.TP +.B \-H +The input file is to be hex digits, representing the binary makeup of the +packet. No length correction is made, if an incorrect length is put in +the IP header. +.TP +.B \-X +The input file is composed of text descriptions of IP packets. +.TP +.B \-E +The input file is to be text output from etherfind. The text formats which +are currently supported are those which result from the following etherfind +option combinations: +.PP +.nf + etherfind -n + etherfind -n -t +.fi +.LP +.TP +.BR \-i \0<filename> +Specify the filename from which to take input. Default is stdin. +.TP +.BR \-r \0<filename> +Specify the filename from which to read filter rules. +.SH FILES +.SH SEE ALSO +ipf(1), ipf(5), snoop(1m), tcpdump(8), etherfind(8c) +.SH BUGS +Not all of the input formats are sufficiently capable of introducing a +wide enough variety of packets for them to be all useful in testing. diff --git a/contrib/ipfilter/man/ipl.4 b/contrib/ipfilter/man/ipl.4 new file mode 100644 index 0000000..0e58a50 --- /dev/null +++ b/contrib/ipfilter/man/ipl.4 @@ -0,0 +1,62 @@ +.TH IPL 4 +.SH NAME +ipl \- IP packet log device +.SH DESCRIPTION +The \fBipl\fP 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. +.PP +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: +.LP +.nf +struct ipl_ci { + u_long sec; /* time when the packet was logged */ + u_long usec; + u_long plen; /* length of packet data logged */ + u_short hlen; /* length of headers logged */ + u_short rule; /* rule number (for log ...) or 0 if result = log */ + u_long flags:24; /* XXX FIXME do we care about the extra bytes? */ +#if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) + u_long filler:8; /* XXX FIXME do we care? */ + u_char ifname[IFNAMSIZ]; +#else + u_long unit:8; + u_char ifname[4]; +#endif +}; +.fi +.PP +In the case of the header causing the buffer to finish on a non-32bit +boundary, padding will be `appended' to ensure that the next log entry +is aligned to a 32bit boundary. +.LP +.PP +If the packet contents is more then 128 bytes, then only 128 bytes of the +packet contents is logged. Should the packet contents finish on a non-32bit +boundary, then the last few bytes are not logged to ensure the log entry +is aligned to a 32bit boundary. + +\fBipl\fP is a read-only (sequential) character pseudo-device. + +The ioctls which are loaded with this device can be found under \fBipf(4)\fP. +The only ioctl which is used for logging and doesn't affect the filter is: +.LP +.nf + ioctl(fd, SIOCIPFFB, int *) +.fi +.PP +This ioctl flushes the log buffer and returns the number of bytes flushed. +.PP +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). +.SH SEE ALSO +ipf(4) +.SH BUGS +Packet headers are dropped when the internal buffer (static size) fills. +.SH FILES +/dev/ipl0 diff --git a/contrib/ipfilter/man/ipmon.8 b/contrib/ipfilter/man/ipmon.8 new file mode 100644 index 0000000..11ac23a --- /dev/null +++ b/contrib/ipfilter/man/ipmon.8 @@ -0,0 +1,56 @@ +.TH ipmon 8 +.SH NAME +ipmon \- monitors /dev/ipl for logged packets +.SH SYNOPSIS +.B ipmon +[ +.B \-sfN +] [ +<filename> +] +.SH DESCRIPTION +.LP +\fBipmon\fP opens \fB/dev/ipl\fP 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 standard output by +default or a filename, if given on the command line. Should the \fB\-s\fP +option be used, output is instead sent to \fBsyslogd(8)\fP. 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. +.SH OPTIONS +.TP +.B \-s +Packet information read in will be sent through syslogd rather than +saved to a file. The following levels are used: +.IP +.B LOG_INFO +\- packets logged using the "log" keyword as the action rather +than pass or block. +.IP +.B LOG_NOTICE +\- packets logged which are also passed +.IP +.B LOG_WARNING +\- packets logged which are also blocked +.IP +.B LOG_ERR +\- packets which have been logged and which can be considered +"short". +.TP +.B \-f +Flush the current packet log buffer. The number of bytes flushed is displayed, +even should the result be zero. +.TP +.B \-N +IP addresses and port numbers will be mapped, where possible, back into +hostnames and service names. +.SH DIAGNOSTICS +\fBipmon\fP expects data that it reads to be consistant with how it should be +saved and will abort if it fails an assertion which detects an anomoly in the +recorded data. +.SH FILES +/dev/ipl +.SH SEE ALSO +ipf(1), ipfstat(1) +.SH BUGS diff --git a/contrib/ipfilter/man/ipnat.1 b/contrib/ipfilter/man/ipnat.1 new file mode 100644 index 0000000..c61e03b --- /dev/null +++ b/contrib/ipfilter/man/ipnat.1 @@ -0,0 +1,45 @@ +.TH IPNAT 1 +.SH NAME +ipnat \- user interface to the NAT +.SH SYNOPSIS +.B ipnat +[ +.B \-lnrsvCF +] +.B \-f <\fIfilename\fP> +.SH DESCRIPTION +.PP +\fBipnat\fP opens the filename given (treating "\-" as stdin) and parses the +file for a set of rules which are to be added or removed from the IP NAT. +.PP +Each rule processed by \fBipnat\fP +is added to the kernels internal lists if there are no parsing problems. +Rules are added to the end of the internal lists, matching the order in +which they appear when given to \fBipnat\fP. +.SH OPTIONS +.TP +.B \-C +delete all entries in the current NAT listing (NAT rules) +.TP +.B \-F +delete all active entries in the current NAT table (currently active +NAT mappings) +.TP +.B \-l +Show the list of current NAT table entry mappings. +.TP +.B \-n +This flag (no-change) prevents \fBipf\fP from actually making any ioctl +calls or doing anything which would alter the currently running kernel. +.TP +.B \-s +Retrieve and display NAT statistics +.TP +.B \-r +Remove matching NAT rules rather than add them to the internal lists +.TP +.B \-v +Turn verbose mode on. Displays information relating to rule processing. +.DT +.SH SEE ALSO +ipfstat(1), ipftest(1), ipf(1), ipnat(5) diff --git a/contrib/ipfilter/man/ipnat.4 b/contrib/ipfilter/man/ipnat.4 new file mode 100644 index 0000000..3346ef9 --- /dev/null +++ b/contrib/ipfilter/man/ipnat.4 @@ -0,0 +1,88 @@ +.TH IPNAT 4 +.SH NAME +ipnat \- Network Address Translation kernel interface +.SH SYNOPSIS +#include <sys/ip_fil.h> +.SH IOCTLS +.PP +To add and delete rules to the NAT list, two 'basic' ioctls are provided +for use. The ioctl's are called as: +.LP +.nf + ioctl(fd, SIOCADNAT, struct ipnat *) + ioctl(fd, SIOCRMNAT, struct ipnat *) +.fi +.PP +Unlike \fBipf(4)\fP, there is only a single list supported by the kernel NAT +interface. An inactive list which can be swapped to is not currently +supported. + +These ioctl's are implemented as being routing ioctls and thus the same rules +for the various routing ioctls and the file descriptor are employed, mainly +being that the fd must be that of the device associated with the module +(i.e., /dev/ipl). +.LP +.PP +The strcture used with the NAT interface is described below: +.LP +.nf +typedef struct ipnat { + struct ipnat *in_next; + void *in_ifp; + u_short in_flags; + u_short in_pnext; + u_short in_port[2]; + struct in_addr in_in[2]; + struct in_addr in_out[2]; + struct in_addr in_nextip; + int in_space; + int in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */ + char in_ifname[IFNAMSIZ]; +} ipnat_t; + +#define in_pmin in_port[0] /* Also holds static redir port */ +#define in_pmax in_port[1] +#define in_nip in_nextip.s_addr +#define in_inip in_in[0].s_addr +#define in_inmsk in_in[1].s_addr +#define in_outip in_out[0].s_addr +#define in_outmsk in_out[1].s_addr + +.fi +.PP +Recognised values for in_redir: +.LP +.nf +#define NAT_MAP 0 +#define NAT_REDIRECT 1 +.fi +.PP +.LP +\fBNAT statistics\fP +Statistics on the the number of packets mapped, going in and out are kept, +the number of times a new entry is added and deleted (through expiration) to +the NAT table and the current usage level of the NAT table. +.PP +Pointers to the NAT table inside the kernel, as well as to the top of the +internal NAT lists constructed with the \fBSIOCADNAT\fP ioctls. The table +itself is a hash table of size NAT_SIZE (default size is 367). +.PP +To retrieve the statistics, the \fBSIOCGNATS\fP ioctl must be used, with +the appropriate structure passed by reference, as follows: +.nf + ioctl(fd, SIOCGNATS, struct natstat *) + +typedef struct natstat { + u_long ns_mapped[2]; + u_long ns_added; + u_long ns_expire; + u_long ns_inuse; + nat_t ***ns_table; + ipnat_t *ns_list; +} natstat_t; +.fi +.SH BUGS +It would be nice if there were more flexibility when adding and deleting +filter rules. +.SH SEE ALSO +ipfstat(1), ipf(1), ipf(4), ipnat(5) diff --git a/contrib/ipfilter/man/ipnat.5 b/contrib/ipfilter/man/ipnat.5 new file mode 100644 index 0000000..7832623 --- /dev/null +++ b/contrib/ipfilter/man/ipnat.5 @@ -0,0 +1,70 @@ +.TH IPNAT 5 +.SH NAME +ipnat \- IP NAT file format +.SH DESCRIPTION +The format for files accepted by ipnat is described by the following grammar: +.LP +.nf +ipmap :: = mapit ifname ipmask "->" ipmask [ mapport ] . + +mapit ::= "map" | "rdr" . +ipmask ::= ip "/" bits | ip "/" mask | ip "netmask" mask . +mapport ::= "portmap" tcpudp portnumber ":" portnumber . + +tcpudp ::= "tcp" | "udp" | "tcp/udp" . +portnumber ::= number { numbers } . +ifname ::= 'A' - 'Z' { 'A' - 'Z' } numbers . + +numbers ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' . +.fi +.PP +For standard NAT functionality, a rule should start with \fBmap\fP and then +proceeds to specify the interface for which outgoing packets will have their +source address rewritten. +.PP +Packets which will be rewritten can only be selected by matching the original +source address. A netmask must be specified with the IP address. +.PP +The address selected for replacing the original is chosen from an IP#/netmask +pair. A netmask of all 1's indicating a hostname is valid. A netmask of +31 1's (255.255.255.254) is considered invalid as there is no space for +allocating host IP#'s after consideration for broadcast and network +addresses. +.PP +When remapping TCP and UDP packets, it is also possible to change the source +port number. Either TCP or UDP or both can be selected by each rule, with a +range of port numbers to remap into given as \fBport-number:port-number\fP. +.SH Examples +.PP +To change IP#'s used internally from network 10 into an ISP provided 8 bit +subnet at 209.1.2.0, the following would be used: +.LP +.nf +map 10.0.0.0/8 -> 209.1.2.0/24 +.fi +.PP +The obvious problem here is we're trying to squeeze over 16,000,000 IP +addresses into a 254 address space. To increase the scope, remapping for TCP +and/or UDP, port remapping can be used; +.LP +.nf +map 10.0.0.0/8 -> 209.1.2.0/24 portmap tcp/udp 1025:65000 +.fi +.PP +which falls only 527,566 `addresses' short of the space available in network +10. If we were to combine these rules, they would need to be specified as +follows: +.LP +.nf +map 10.0.0.0/8 -> 209.1.2.0/24 portmap tcp/udp 1025:65000 +map 10.0.0.0/8 -> 209.1.2.0/24 +.fi +.PP +so that all TCP/UDP packets were port mapped and only other protocols, such as +ICMP, only have their IP# changed. +.SH FILES +/etc/services +.br +/etc/hosts +.SH SEE ALSO +ipnat(1), ipf(5), ipnat(4) |