From 9e5180649864703b05dbdb5db6ec38aee04c28d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Eychenne?= Date: Thu, 14 Mar 2002 09:25:40 +0000 Subject: manpage updates by Herve Eychenne --- ip6tables.8 | 233 ++++++++++++++++++++++---------------- iptables.8 | 364 +++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 370 insertions(+), 227 deletions(-) diff --git a/ip6tables.8 b/ip6tables.8 index 8c8d140b..065932cf 100644 --- a/ip6tables.8 +++ b/ip6tables.8 @@ -1,13 +1,13 @@ -.TH IP6TABLES 8 "Okt 07, 2001" "" "" +.TH IP6TABLES 8 "Mar 09, 2002" "" "" .\" .\" Man page written by Andras Kis-Szabo .\" It is based on iptables man page. .\" -.\" iptables page by Herve Eychenne +.\" iptables page by Herve Eychenne .\" It is based on ipchains man page. .\" .\" ipchains page by Paul ``Rusty'' Russell March 1997 -.\" Based on the original ipfwadm man page by Jos Vos (see README) +.\" Based on the original ipfwadm man page by Jos Vos .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -29,13 +29,17 @@ ip6tables \- IPv6 packet filter administration .SH SYNOPSIS .BR "ip6tables -[ADC] " "chain rule-specification [options]" .br -.BR "ip6tables -[RI] " "chain rulenum rule-specification [options]" +.BR "ip6tables -I " "chain [rulenum] rule-specification [options]" +.br +.BR "ip6tables -R " "chain rulenum rule-specification [options]" .br .BR "ip6tables -D " "chain rulenum [options]" .br .BR "ip6tables -[LFZ] " "[chain] [options]" .br -.BR "ip6tables -[NX] " "chain" +.BR "ip6tables -N " "chain" +.br +.BR "ip6tables -X " "[chain]" .br .BR "ip6tables -P " "chain target [options]" .br @@ -82,7 +86,7 @@ There are current three independent tables (which tables are present at any time depends on the kernel configuration options and which modules are present). .TP -.B "-t, --table" +.BI "-t, --table " "table" This option specifies the packet matching table which the command should operate on. If the kernel is configured with automatic module loading, an attempt will be made to load the appropriate module for @@ -90,16 +94,19 @@ that table if it is not already there. The tables are as follows: .TP -.BR "filter" +.B "filter" This is the default table. It contains the built-in chains INPUT (for packets coming into the box itself), FORWARD (for packets being routed through the box), and OUTPUT (for locally-generated packets). .TP -.BR "mangle" -This table is used for specialized packet alteration. It has two -built-in chains: PREROUTING (for altering incoming packets before -routing) and OUTPUT (for altering locally-generated packets before -routing). +.B "mangle" +This table is used for specialized packet alteration. Until kernel +2.4.17 it had two built-in chains: PREROUTING (for altering incoming +packets before routing) and OUTPUT (for altering locally-generated +packets before routing). Since kernel 2.4.18, three other built-in +chains are also supported : INPUT (for packets coming into the box itself), +FORWARD (for altering packets being routed through the box), and +POSTROUTING (for altering packets as they are about to go out). .SH OPTIONS The options that are recognized by .B ip6tables @@ -112,63 +119,75 @@ need to use only enough letters to ensure that .B ip6tables can differentiate it from all other options. .TP -.BR "-A, --append" +.BI "-A, --append " "chain rule-specification" Append one or more rules to the end of the selected chain. When the source and/or destination names resolve to more than one address, a rule will be added for each possible address combination. .TP -.BR "-D, --delete" +.BI "-D, --delete " "chain rule-specification" +.ns +.TP +.BI "-D, --delete " "chain rulenum" Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match. .TP -.B "-R, --replace" -Replace a rule in the selected chain. If the source and/or -destination names resolve to multiple addresses, the command will -fail. Rules are numbered starting at 1. -.TP .B "-I, --insert" Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number is specified. .TP -.B "-L, --list" +.BI "-R, --replace " "chain rulenum rule-specification" +Replace a rule in the selected chain. If the source and/or +destination names resolve to multiple addresses, the command will +fail. Rules are numbered starting at 1. +.TP +.BR "-L, --list " "[\fIchain\fP]" List all rules in the selected chain. If no chain is selected, all -chains are listed. It is legal to specify the +chains are listed. As every other iptables command, it applies to the +specified table (filter is the default), so NAT rules get listed by +.br + iptables -t nat -n -L +.br +Please note that it is often used with the +.B -n +option, in order to avoid long reverse DNS lookups. +It is legal to specify the .B -Z (zero) option as well, in which case the chain(s) will be atomically listed and zeroed. The exact output is affected by the other arguments given. .TP -.B "-F, --flush" -Flush the selected chain. This is equivalent to deleting all the -rules one by one. +.BR "-F, --flush " "[\fIchain\fP]" +Flush the selected chain (all the chains in the table if none is given). +This is equivalent to deleting all the rules one by one. .TP -.B "-Z, --zero" +.BR "-Z, --zero " "[\fIchain\fP]" Zero the packet and byte counters in all chains. It is legal to specify the .B "-L, --list" (list) option as well, to see the counters immediately before they are cleared. (See above.) .TP -.B "-N, --new-chain" +.BI "-N, --new-chain " "chain" Create a new user-defined chain by the given name. There must be no target of that name already. .TP -.B "-X, --delete-chain" -Delete the specified user-defined chain. There must be no references +.BR "-X, --delete-chain " "[\fIchain\fP]" +Delete the optional user-defined chain specified. There must be no references to the chain. If there are, you must delete or replace the referring rules before the chain can be deleted. If no argument is given, it will attempt to delete every non-builtin chain in the table. .TP -.B "-P, --policy" +.BI "-P, --policy " "chain target" Set the policy for the chain to the given target. See the section .B TARGETS -for the legal targets. Only non-user-defined chains can have policies, -and neither built-in nor user-defined chains can be policy targets. +for the legal targets. Only built-in (non-user-defined) chains can have +policies, and neither built-in nor user-defined chains can be policy +targets. .TP -.B "-E, --rename-chain" +.B "-E, --rename-chain " "old-chain new-chain" Rename the user specified chain to the user supplied name. This is cosmetic, and has no effect on the structure of the table. .TP @@ -200,7 +219,9 @@ option is omitted. .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]" Source specification. .I Address -can be either a hostname, or a plain IPv6 address (the network name doesn't supported now). +can be either a hostname (please note that specifying any name to be +resolved with a remote query such as DNS is a really bad idea), +or a plain IPv6 address (the network name isn't supported now). The .I mask can be either a network mask or a plain number, @@ -212,7 +233,7 @@ is equivalent to A "!" argument before the address specification inverts the sense of the address. The flag .B --src -is a convenient alias for this option. +is an alias for this option. .TP .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]" Destination specification. @@ -233,8 +254,8 @@ option is omitted in a rule, then matching the rule will have no effect on the packet's fate, but the counters on the rule will be incremented. .TP -.BR "-i, --in-interface " "[!] [\fIname\fP]" -Optional name of an interface via which a packet is received (for +.BR "-i, --in-interface " "[!] \fIname\fP" +Name of an interface via which a packet is going to be received (only for packets entering the .BR INPUT , .B FORWARD @@ -243,20 +264,18 @@ and chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is -omitted, the string "+" is assumed, which will match with any -interface name. +omitted, any interface name will match. .TP -.BR "-o, --out-interface " "[!] [\fIname\fP]" -Optional name of an interface via which a packet is going to -be sent (for packets entering the +.BR "-o, --out-interface " "[!] \fIname\fP" +Name of an interface via which a packet is going to be sent (for packets +entering the .BR FORWARD and .B OUTPUT -chains). When the "!" argument is used before the interface name, -the sense is inverted. If the interface name ends in a "+", then any +chains). When the "!" argument is used before the interface name, the +sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is -omitted, the string "+" is assumed, which will match with any -interface name. +omitted, any interface name will match. .TP .\" Currently not supported (header-based) .\" @@ -274,7 +293,7 @@ counters of a rule (during .B INSERT, .B APPEND, .B REPLACE -operations) +operations). .SS "OTHER OPTIONS" The following additional options can be specified: .TP @@ -308,7 +327,7 @@ command. When listing rules, add line numbers to the beginning of each rule, corresponding to that rule's position in the chain. .TP -.B "--modprobe=" +.B "--modprobe=command" When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). @@ -324,7 +343,8 @@ or .B --match options, followed by the matching module name; after these, various extra command line options become available, depending on the specific -module. You can specify multiple extended match modules in one line, and you can use the +module. You can specify multiple extended match modules in one line, +and you can use the .B -h or .B --help @@ -339,7 +359,7 @@ to invert the sense of the match. These extensions are loaded if `--protocol tcp' is specified. It provides the following options: .TP -.BR "--source-port " "[!] [\fIport[:port]\fP]" +.BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" Source port or port range specification. This can either be a service name or a port number. An inclusive range can also be specified, using the format @@ -349,12 +369,12 @@ If the first port is omitted, "0" is assumed; if the last is omitted, If the second port greater then the first they will be swapped. The flag .B --sport -is an alias for this option. +is a convenient alias for this option. .TP -.BR "--destination-port " "[!] [\fIport[:port]\fP]" -Destination port or port range specification. The flag +.BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" +Destination port or port range specification. The flag .B --dport -is an alias for this option. +is a convenient alias for this option. .TP .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP" Match when the TCP flags are as specified. The first argument is the @@ -385,13 +405,13 @@ Match if TCP option set. These extensions are loaded if `--protocol udp' is specified. It provides the following options: .TP -.BR "--source-port " "[!] [\fIport[:port]\fP]" +.BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" Source port or port range specification. See the description of the .B --source-port option of the TCP extension for details. .TP -.BR "--destination-port " "[!] [\fIport[:port]\fP]" +.BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" Destination port or port range specification. See the description of the .B --destination-port @@ -410,18 +430,19 @@ IPv6-ICMP type, or one of the IPv6-ICMP type names shown by the command .TP .BR "--mac-source " "[!] \fIaddress\fP" Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. -Note that this only makes sense for packets entering the +Note that this only makes sense for packets coming from an Ethernet device +and entering the .BR PREROUTING , .B FORWARD or .B INPUT -chains for packets coming from an ethernet device. +chains. .SS limit -This module matches at a limited rate using a token bucket filter: it -can be used in combination with the +This module matches at a limited rate using a token bucket filter. +A rule using this extension will match until this limit is reached +(unless the `!' flag is used). It can be used in combination with the .B LOG -target to give limited logging. A rule using this extension will -match until this limit is reached (unless the `!' flag is used). +target to give limited logging, for example. .TP .BI "--limit " "rate" Maximum average matching rate: specified as a number, with an optional @@ -429,23 +450,27 @@ Maximum average matching rate: specified as a number, with an optional 3/hour. .TP .BI "--limit-burst " "number" -The maximum initial number of packets to match: this number gets +Maximum initial number of packets to match: this number gets recharged by one every time the limit specified above is not reached, up to this number; the default is 5. .SS multiport -This module matches a set of source or destination ports. Up to 15 -ports can be specified. It can only be used in conjunction with +This module matches a set of source or destination ports. Up to 15 +ports can be specified. It can only be used in conjunction with .B "-p tcp" or .BR "-p udp" . .TP -.BR "--source-port" " [\fIport[,port]\fP]" -Match if the source port is one of the given ports. +.BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" +Match if the source port is one of the given ports. The flag +.B --sports +is a convenient alias for this option. .TP -.BR "--destination-port" " [\fIport[,port]\fP]" -Match if the destination port is one of the given ports. +.BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" +Match if the destination port is one of the given ports. The flag +.B --dports +is a convenient alias for this option. .TP -.BR "--port" " [\fIport[,port]\fP]" +.BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" Match if the both the source and destination ports are equal to each other and to one of the given ports. .SS mark @@ -454,7 +479,7 @@ This module matches the netfilter mark field associated with a packet .B MARK target below). .TP -.BI "--mark " "value[/mask]" +.BR "--mark " "\fIvalue\fP[/\fImask\fP]" Matches packets with the given unsigned mark value (if a mask is specified, this is logically ANDed with the mask before the comparison). @@ -463,7 +488,7 @@ This module attempts to match various characteristics of the packet creator, for locally-generated packets. It is only valid in the .B OUTPUT chain, and even this some packets (such as ICMP ping responses) may -have no owner, and hence never match. +have no owner, and hence never match. This is regarded as experimental. .TP .BI "--uid-owner " "userid" Matches if the packet was created by a process with the given @@ -513,9 +538,9 @@ group. .\" iptables -m tos -h .\" .br .\" to see the list), or a numeric value to match. -.\" .SH TARGET EXTENSIONS -.\" iptables can use extended target modules: the following are included -.\" in the standard distribution. +.SH TARGET EXTENSIONS +ip6tables can use extended target modules: the following are included +in the standard distribution. .SS LOG Turn on kernel logging of matching packets. When this option is set for a rule, the Linux kernel will print some information on all @@ -524,6 +549,10 @@ matching packets (like most IPv6 IPv6-header fields) via the kernel log .I dmesg or .IR syslogd (8)). +This is a "non-terminating target", i.e. rule traversal continues at +the next rule. So if you want to LOG the packets you refuse, use two +separate rules with the same matching criterias, first using target LOG +then DROP (or REJECT). .TP .BI "--log-level " "level" Level of logging (numeric or see \fIsyslog.conf\fP(5)). @@ -551,14 +580,15 @@ table. .SS REJECT This is used to send back an error packet in response to the matched packet: otherwise it is equivalent to -.BR DROP . +.B DROP +so it is a terminating TARGET, ending rule traversal. This target is only valid in the .BR INPUT , .B FORWARD and .B OUTPUT chains, and user-defined chains which are only called from those -chains. Several options control the nature of the error packet +chains. The following option controls the nature of the error packet returned: .TP .BI "--reject-with " "type" @@ -571,14 +601,14 @@ The type given can be .BR addr-unreach , .BR icmp6-port-unreachable , .BR port-unreach , -which return the appropriate IPv6-ICMP error message (port-unreach is +which return the appropriate IPv6-ICMP error message (\fBport-unreach\fP is the default). Finally, the option .B tcp-reset can be used on rules which only match the TCP protocol: this causes a TCP RST packet to be sent back. This is mainly useful for blocking .I ident -probes which frequently occur when sending mail to broken mail hosts -(which won't accept your mail otherwise). +(113/tcp) probes which frequently occur when sending mail to broken mail +hosts (which won't accept your mail otherwise). .\" .SS TOS .\" This is used to set the 8-bit Type of Service field in the IP header. .\" It is only valid in the @@ -613,7 +643,7 @@ probes which frequently occur when sending mail to broken mail hosts .\" modified (and all future packets in this connection will also be .\" mangled), and rules should cease being examined. It takes one option: .\" .TP -.\" .BI "--to-source " "[-][:port-port]" +.\" .BR "--to-source " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" .\" which can specify a single new source IP address, an inclusive range .\" of IP addresses, and optionally, a port range (which is only valid if .\" the rule also specifies @@ -637,7 +667,7 @@ probes which frequently occur when sending mail to broken mail hosts .\" also be mangled), and rules should cease being examined. It takes one .\" option: .\" .TP -.\" .BI "--to-destination " "[-][:port-port]" +.\" .BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" .\" which can specify a single new destination IP address, an inclusive .\" range of IP addresses, and optionally, a port range (which is only .\" valid if the rule also specifies @@ -661,14 +691,14 @@ probes which frequently occur when sending mail to broken mail hosts .\" next dialup is unlikely to have the same interface address (and hence .\" any established connections are lost anyway). It takes one option: .\" .TP -.\" .BI "--to-ports " "[-]" +.\" .BR "--to-ports " "\fIport\fP[-\fIport\fP]" .\" This specifies a range of source ports to use, overriding the default .\" .B SNAT -.\" source port-selection heuristics (see above). This is only valid with +.\" source port-selection heuristics (see above). This is only valid .\" if the rule also specifies .\" .B "-p tcp" .\" or -.\" .BR "-p udp" ). +.\" .BR "-p udp" . .\" .SS REDIRECT .\" This target is only valid in the .\" .B nat @@ -681,13 +711,13 @@ probes which frequently occur when sending mail to broken mail hosts .\" the machine itself (locally-generated packets are mapped to the .\" 127.0.0.1 address). It takes one option: .\" .TP -.\" .BI "--to-ports " "[-]" -.\" This specifies a destination port or range or ports to use: without -.\" this, the destination port is never altered. This is only valid with +.\" .BR "--to-ports " "\fIport\fP[-\fIport\fP]" +.\" This specifies a destination port or range of ports to use: without +.\" this, the destination port is never altered. This is only valid .\" if the rule also specifies .\" .B "-p tcp" .\" or -.\" .BR "-p udp" ). +.\" .BR "-p udp" . .\" .SH EXTRA EXTENSIONS .\" The following extensions are not included by default in the standard .\" distribution. @@ -718,23 +748,23 @@ probes which frequently occur when sending mail to broken mail hosts .\" socket. One or more userspace processes may then subscribe to various .\" multicast groups and receive the packets. .\" .TP -.\" .BI "--ulog-nlgroup " "" +.\" .BI "--ulog-nlgroup " "nlgroup" .\" This specifies the netlink group (1-32) to which the packet is sent. .\" Default value is 1. .\" .TP -.\" .BI "--ulog-prefix " "" +.\" .BI "--ulog-prefix " "prefix" .\" Prefix log messages with the specified prefix; up to 32 characters .\" long, and useful fro distinguishing messages in the logs. .\" .TP -.\" .BI "--ulog-cprange " "" +.\" .BI "--ulog-cprange " "size" .\" Number of bytes to be copied to userspace. A value of 0 always copies -.\" the entire packet, regardless of its size. Default is 0 +.\" the entire packet, regardless of its size. Default is 0. .\" .TP -.\" .BI "--ulog-qthreshold " "" +.\" .BI "--ulog-qthreshold " "size" .\" Number of packet to queue inside kernel. Setting this value to, e.g. 10 .\" accumulates ten packets inside the kernel and transmits them as one -.\" netlink multipart message to userspace. Default is 1 (for backwards -.\" compatibility) +.\" netlink multipart message to userspace. Default is 1 (for backwards +.\" compatibility). .SH DIAGNOSTICS Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by @@ -778,9 +808,12 @@ chain. .\" .br There are several other changes in ip6tables. .SH SEE ALSO -The packet-filtering-HOWTO, which details more iptables usage for packet filtering, -and the netfilter-hacking-HOWTO which details the -internals. +The packet-filtering-HOWTO, which details more iptables usage for +packet filtering, the NAT-HOWTO, which details NAT, +and the netfilter-hacking-HOWTO which details the internals. +.br +See +.BR "http://www.netfilter.org/" . .SH AUTHORS Rusty Russell wrote iptables, in early consultation with Michael Neuling. @@ -797,6 +830,10 @@ Harald Welte wrote the ULOG target, TTL match+target and libipulog. .PP The Netfilter Core Team is: Marc Boucher, Jozsef Kadlecsik, James Morris, Harald Welte and Rusty Russell. +.PP +ip6tables man page created by Andras Kis-Szabo, based on +iptables man page written by Herve Eychenne . + .\" .. and did I mention that we are incredibly cool people? .\" .. sexy, too .. .\" .. witty, charming, powerful .. diff --git a/iptables.8 b/iptables.8 index baa3d33b..870eeb12 100644 --- a/iptables.8 +++ b/iptables.8 @@ -1,10 +1,12 @@ -.TH IPTABLES 8 "Aug 11, 2000" "" "" +.TH IPTABLES 8 "Mar 09, 2002" "" "" .\" -.\" Man page written by Herve Eychenne -.\" It is based on ipchains man page. +.\" Man page written by Herve Eychenne (May 1999) +.\" It is based on ipchains page. +.\" TODO : add a word for protocol helpers (FTP, IRC, SNMP-ALG) +.\" add EXTRA EXTENSIONS matches .\" .\" ipchains page by Paul ``Rusty'' Russell March 1997 -.\" Based on the original ipfwadm man page by Jos Vos (see README) +.\" Based on the original ipfwadm man page by Jos Vos .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -26,13 +28,17 @@ iptables \- IP packet filter administration .SH SYNOPSIS .BR "iptables -[ADC] " "chain rule-specification [options]" .br -.BR "iptables -[RI] " "chain rulenum rule-specification [options]" +.BR "iptables -I " "chain [rulenum] rule-specification [options]" +.br +.BR "iptables -R " "chain rulenum rule-specification [options]" .br .BR "iptables -D " "chain rulenum [options]" .br .BR "iptables -[LFZ] " "[chain] [options]" .br -.BR "iptables -[NX] " "chain" +.BR "iptables -N " "chain" +.br +.BR "iptables -X " "[chain]" .br .BR "iptables -P " "chain target [options]" .br @@ -79,7 +85,7 @@ There are current three independent tables (which tables are present at any time depends on the kernel configuration options and which modules are present). .TP -.B "-t, --table" +.BI "-t, --table " "table" This option specifies the packet matching table which the command should operate on. If the kernel is configured with automatic module loading, an attempt will be made to load the appropriate module for @@ -87,23 +93,26 @@ that table if it is not already there. The tables are as follows: .TP -.BR "filter" +.B "filter" This is the default table. It contains the built-in chains INPUT (for packets coming into the box itself), FORWARD (for packets being routed through the box), and OUTPUT (for locally-generated packets). .TP -.BR "nat" +.B "nat" This table is consulted when a packet that creates a new connection is encountered. It consists of three built-ins: PREROUTING (for altering packets as soon as they come in), OUTPUT (for altering locally-generated packets before routing), and POSTROUTING (for altering packets as they are about to go out). .TP -.BR "mangle" -This table is used for specialized packet alteration. It has two -built-in chains: PREROUTING (for altering incoming packets before -routing) and OUTPUT (for altering locally-generated packets before -routing). +.B "mangle" +This table is used for specialized packet alteration. Until kernel +2.4.17 it had two built-in chains: PREROUTING (for altering incoming +packets before routing) and OUTPUT (for altering locally-generated +packets before routing). Since kernel 2.4.18, three other built-in +chains are also supported : INPUT (for packets coming into the box itself), +FORWARD (for altering packets being routed through the box), and +POSTROUTING (for altering packets as they are about to go out). .SH OPTIONS The options that are recognized by .B iptables @@ -116,63 +125,75 @@ need to use only enough letters to ensure that .B iptables can differentiate it from all other options. .TP -.BR "-A, --append" +.BI "-A, --append " "chain rule-specification" Append one or more rules to the end of the selected chain. When the source and/or destination names resolve to more than one address, a rule will be added for each possible address combination. .TP -.BR "-D, --delete" +.BI "-D, --delete " "chain rule-specification" +.ns +.TP +.BI "-D, --delete " "chain rulenum" Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the chain (starting at 1 for the first rule) or a rule to match. .TP -.B "-R, --replace" -Replace a rule in the selected chain. If the source and/or -destination names resolve to multiple addresses, the command will -fail. Rules are numbered starting at 1. -.TP -.B "-I, --insert" +.BR "-I, --insert " "\fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP" Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number is specified. .TP -.B "-L, --list" +.BI "-R, --replace " "chain rulenum rule-specification" +Replace a rule in the selected chain. If the source and/or +destination names resolve to multiple addresses, the command will +fail. Rules are numbered starting at 1. +.TP +.BR "-L, --list " "[\fIchain\fP]" List all rules in the selected chain. If no chain is selected, all -chains are listed. It is legal to specify the +chains are listed. As every other iptables command, it applies to the +specified table (filter is the default), so NAT rules get listed by +.br + iptables -t nat -n -L +.br +Please note that it is often used with the +.B -n +option, in order to avoid long reverse DNS lookups. +It is legal to specify the .B -Z (zero) option as well, in which case the chain(s) will be atomically listed and zeroed. The exact output is affected by the other arguments given. .TP -.B "-F, --flush" -Flush the selected chain. This is equivalent to deleting all the -rules one by one. +.BR "-F, --flush " "[\fIchain\fP]" +Flush the selected chain (all the chains in the table if none is given). +This is equivalent to deleting all the rules one by one. .TP -.B "-Z, --zero" +.BR "-Z, --zero " "[\fIchain\fP]" Zero the packet and byte counters in all chains. It is legal to specify the .B "-L, --list" (list) option as well, to see the counters immediately before they are cleared. (See above.) .TP -.B "-N, --new-chain" +.BI "-N, --new-chain " "chain" Create a new user-defined chain by the given name. There must be no target of that name already. .TP -.B "-X, --delete-chain" -Delete the specified user-defined chain. There must be no references +.BR "-X, --delete-chain " "[\fIchain\fP]" +Delete the optional user-defined chain specified. There must be no references to the chain. If there are, you must delete or replace the referring rules before the chain can be deleted. If no argument is given, it will attempt to delete every non-builtin chain in the table. .TP -.B "-P, --policy" +.BI "-P, --policy " "chain target" Set the policy for the chain to the given target. See the section .B TARGETS -for the legal targets. Only non-user-defined chains can have policies, -and neither built-in nor user-defined chains can be policy targets. +for the legal targets. Only built-in (non-user-defined) chains can have +policies, and neither built-in nor user-defined chains can be policy +targets. .TP -.B "-E, --rename-chain" +.BI "-E, --rename-chain " "old-chain new-chain" Rename the user specified chain to the user supplied name. This is cosmetic, and has no effect on the structure of the table. .TP @@ -204,7 +225,9 @@ option is omitted. .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]" Source specification. .I Address -can be either a hostname, a network name, or a plain IP address. +can be either a network name, a hostname (please note that specifying +any name to be resolved with a remote query such as DNS is a really bad idea), +a network IP address (with /mask), or a plain IP address. The .I mask can be either a network mask or a plain number, @@ -216,7 +239,7 @@ is equivalent to A "!" argument before the address specification inverts the sense of the address. The flag .B --src -is a convenient alias for this option. +is an alias for this option. .TP .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]" Destination specification. @@ -237,8 +260,8 @@ option is omitted in a rule, then matching the rule will have no effect on the packet's fate, but the counters on the rule will be incremented. .TP -.BR "-i, --in-interface " "[!] [\fIname\fP]" -Optional name of an interface via which a packet is received (for +.BR "-i, --in-interface " "[!] \fIname\fP" +Name of an interface via which a packet is going to be received (only for packets entering the .BR INPUT , .B FORWARD @@ -247,21 +270,19 @@ and chains). When the "!" argument is used before the interface name, the sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is -omitted, the string "+" is assumed, which will match with any -interface name. +omitted, any interface name will match. .TP -.BR "-o, --out-interface " "[!] [\fIname\fP]" -Optional name of an interface via which a packet is going to -be sent (for packets entering the +.BR "-o, --out-interface " "[!] \fIname\fP" +Name of an interface via which a packet is going to be sent (for packets +entering the .BR FORWARD , .B OUTPUT and .B POSTROUTING -chains). When the "!" argument is used before the interface name, -the sense is inverted. If the interface name ends in a "+", then any +chains). When the "!" argument is used before the interface name, the +sense is inverted. If the interface name ends in a "+", then any interface which begins with this name will match. If this option is -omitted, the string "+" is assumed, which will match with any -interface name. +omitted, any interface name will match. .TP .B "[!] " "-f, --fragment" This means that the rule only refers to second and further fragments @@ -271,13 +292,13 @@ not match any rules which specify them. When the "!" argument precedes the "-f" flag, the rule will only match head fragments, or unfragmented packets. .TP -.B "-c, --set-counters " "PKTS BYTES" +.BI "-c, --set-counters " "PKTS BYTES" This enables the administrater to initialize the packet and byte counters of a rule (during .B INSERT, .B APPEND, .B REPLACE -operations) +operations). .SS "OTHER OPTIONS" The following additional options can be specified: .TP @@ -311,7 +332,7 @@ command. When listing rules, add line numbers to the beginning of each rule, corresponding to that rule's position in the chain. .TP -.B "--modprobe=" +.B "--modprobe=command" When adding or inserting rules into a chain, use .B command to load any necessary modules (targets, match extensions, etc). @@ -327,7 +348,8 @@ or .B --match options, followed by the matching module name; after these, various extra command line options become available, depending on the specific -module. You can specify multiple extended match modules in one line, and you can use the +module. You can specify multiple extended match modules in one line, +and you can use the .B -h or .B --help @@ -342,7 +364,7 @@ to invert the sense of the match. These extensions are loaded if `--protocol tcp' is specified. It provides the following options: .TP -.BR "--source-port " "[!] [\fIport[:port]\fP]" +.BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" Source port or port range specification. This can either be a service name or a port number. An inclusive range can also be specified, using the format @@ -352,12 +374,12 @@ If the first port is omitted, "0" is assumed; if the last is omitted, If the second port greater then the first they will be swapped. The flag .B --sport -is an alias for this option. +is a convenient alias for this option. .TP -.BR "--destination-port " "[!] [\fIport[:port]\fP]" -Destination port or port range specification. The flag +.BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" +Destination port or port range specification. The flag .B --dport -is an alias for this option. +is a convenient alias for this option. .TP .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP" Match when the TCP flags are as specified. The first argument is the @@ -384,17 +406,21 @@ option is inverted. .TP .BR "--tcp-option " "[!] \fInumber\fP" Match if TCP option set. +.TP +.BR "--mss " "\fIvalue\fP[:\fIvalue\fP]" +Match TCP SYN or SYN/ACK packets with the specified MSS value (or range), +which control the maximum packet size for that connection. .SS udp These extensions are loaded if `--protocol udp' is specified. It provides the following options: .TP -.BR "--source-port " "[!] [\fIport[:port]\fP]" +.BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" Source port or port range specification. See the description of the .B --source-port option of the TCP extension for details. .TP -.BR "--destination-port " "[!] [\fIport[:port]\fP]" +.BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" Destination port or port range specification. See the description of the .B --destination-port @@ -413,18 +439,19 @@ ICMP type, or one of the ICMP type names shown by the command .TP .BR "--mac-source " "[!] \fIaddress\fP" Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. -Note that this only makes sense for packets entering the +Note that this only makes sense for packets coming from an Ethernet device +and entering the .BR PREROUTING , .B FORWARD or .B INPUT -chains for packets coming from an ethernet device. +chains. .SS limit -This module matches at a limited rate using a token bucket filter: it -can be used in combination with the +This module matches at a limited rate using a token bucket filter. +A rule using this extension will match until this limit is reached +(unless the `!' flag is used). It can be used in combination with the .B LOG -target to give limited logging. A rule using this extension will -match until this limit is reached (unless the `!' flag is used). +target to give limited logging, for example. .TP .BI "--limit " "rate" Maximum average matching rate: specified as a number, with an optional @@ -432,23 +459,27 @@ Maximum average matching rate: specified as a number, with an optional 3/hour. .TP .BI "--limit-burst " "number" -The maximum initial number of packets to match: this number gets +Maximum initial number of packets to match: this number gets recharged by one every time the limit specified above is not reached, up to this number; the default is 5. .SS multiport -This module matches a set of source or destination ports. Up to 15 -ports can be specified. It can only be used in conjunction with +This module matches a set of source or destination ports. Up to 15 +ports can be specified. It can only be used in conjunction with .B "-p tcp" or .BR "-p udp" . .TP -.BR "--source-port" " [\fIport[,port]\fP]" -Match if the source port is one of the given ports. +.BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" +Match if the source port is one of the given ports. The flag +.B --sports +is a convenient alias for this option. .TP -.BR "--destination-port" " [\fIport[,port]\fP]" -Match if the destination port is one of the given ports. +.BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" +Match if the destination port is one of the given ports. The flag +.B --dports +is a convenient alias for this option. .TP -.BR "--port" " [\fIport[,port]\fP]" +.BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" Match if the both the source and destination ports are equal to each other and to one of the given ports. .SS mark @@ -457,7 +488,7 @@ This module matches the netfilter mark field associated with a packet .B MARK target below). .TP -.BI "--mark " "value[/mask]" +.BR "--mark " "\fIvalue\fP[/\fImask\fP]" Matches packets with the given unsigned mark value (if a mask is specified, this is logically ANDed with the mask before the comparison). @@ -508,9 +539,6 @@ directions, and meaning that the packet is starting a new connection, but is associated with an existing connection, such as an FTP data transfer, or an ICMP error. -.SS unclean -This module takes no options, but attempts to match packets which seem -malformed or unusual. This is regarded as experimental. .SS tos This module matches the 8 bits of Type of Service field in the IP header (ie. including the precedence bits). @@ -521,6 +549,49 @@ The argument is either a standard name, (use iptables -m tos -h .br to see the list), or a numeric value to match. +.SS ah +This module matches the SPIs in AH header of IPSec packets. +.TP +.BR "--ahspi " "[!] \fIspi\fP[:\fIspi\fP]" +.SS esp +This module matches the SPIs in ESP header of IPSec packets. +.TP +.BR "--espspi " "[!] \fIspi\fP[:\fIspi\fP]" +.SS length +This module matches the length of a packet against a specific value +or range of values. +.TP +.BR "--length " "\fIlength\fP[:\fIlength\fP]" +.SS ttl +This module matches the time to live field in the IP header. +.TP +.BI "--ttl " "ttl" +Matches the given TTL value. +.SS owner +This module attempts to match various characteristics of the packet +creator, for locally-generated packets. It is only valid in the +.B OUTPUT +chain, and even this some packets (such as ICMP ping responses) may +have no owner, and hence never match. This is regarded as experimental. +.TP +.BI "--uid-owner " "userid" +Matches if the packet was created by a process with the given +effective user id. +.TP +.BI "--gid-owner " "groupid" +Matches if the packet was created by a process with the given +effective group id. +.TP +.BI "--pid-owner " "processid" +Matches if the packet was created by a process with the given +process id. +.TP +.BI "--sid-owner " "sessionid" +Matches if the packet was created by a process in the given session +group. +.SS unclean +This module takes no options, but attempts to match packets which seem +malformed or unusual. This is regarded as experimental. .SH TARGET EXTENSIONS iptables can use extended target modules: the following are included in the standard distribution. @@ -532,6 +603,10 @@ matching packets (like most IP header fields) via the kernel log .I dmesg or .IR syslogd (8)). +This is a "non-terminating target", i.e. rule traversal continues at +the next rule. So if you want to LOG the packets you refuse, use two +separate rules with the same matching criterias, first using target LOG +then DROP (or REJECT). .TP .BI "--log-level " "level" Level of logging (numeric or see \fIsyslog.conf\fP(5)). @@ -553,20 +628,21 @@ Log options from the IP packet header. This is used to set the netfilter mark value associated with the packet. It is only valid in the .B mangle -table. +table. It can for example be used in conjunction with iproute2. .TP .BI "--set-mark " "mark" .SS REJECT This is used to send back an error packet in response to the matched packet: otherwise it is equivalent to -.BR DROP . +.B DROP +so it is a terminating TARGET, ending rule traversal. This target is only valid in the .BR INPUT , .B FORWARD and .B OUTPUT chains, and user-defined chains which are only called from those -chains. Several options control the nature of the error packet +chains. The following option controls the nature of the error packet returned: .TP .BI "--reject-with " "type" @@ -575,19 +651,16 @@ The type given can be .BR icmp-host-unreachable , .BR icmp-port-unreachable , .BR icmp-proto-unreachable , -.BR icmp-net-prohibited or +.BR "icmp-net-prohibited or" .BR icmp-host-prohibited , -which return the appropriate ICMP error message (port-unreachable is -the default). The option -.B echo-reply -is also allowed; it can only be used for rules which specify an ICMP -ping packet, and generates a ping reply. Finally, the option +which return the appropriate ICMP error message (\fBport-unreachable\fP is +the default). The option .B tcp-reset can be used on rules which only match the TCP protocol: this causes a TCP RST packet to be sent back. This is mainly useful for blocking .I ident -probes which frequently occur when sending mail to broken mail hosts -(which won't accept your mail otherwise). +(113/tcp) probes which frequently occur when sending mail to broken mail +hosts (which won't accept your mail otherwise). .SS TOS This is used to set the 8-bit Type of Service field in the IP header. It is only valid in the @@ -622,7 +695,7 @@ chain. It specifies that the source address of the packet should be modified (and all future packets in this connection will also be mangled), and rules should cease being examined. It takes one option: .TP -.BI "--to-source " "[-][:port-port]" +.BR "--to-source " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" which can specify a single new source IP address, an inclusive range of IP addresses, and optionally, a port range (which is only valid if the rule also specifies @@ -646,7 +719,7 @@ should be modified (and all future packets in this connection will also be mangled), and rules should cease being examined. It takes one option: .TP -.BI "--to-destination " "[-][:port-port]" +.BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" which can specify a single new destination IP address, an inclusive range of IP addresses, and optionally, a port range (which is only valid if the rule also specifies @@ -670,14 +743,14 @@ when the interface goes down. This is the correct behavior when the next dialup is unlikely to have the same interface address (and hence any established connections are lost anyway). It takes one option: .TP -.BI "--to-ports " "[-]" +.BR "--to-ports " "\fIport\fP[-\fIport\fP]" This specifies a range of source ports to use, overriding the default .B SNAT -source port-selection heuristics (see above). This is only valid with +source port-selection heuristics (see above). This is only valid if the rule also specifies .B "-p tcp" or -.BR "-p udp" ). +.BR "-p udp" . .SS REDIRECT This target is only valid in the .B nat @@ -690,35 +763,13 @@ chains. It alters the destination IP address to send the packet to the machine itself (locally-generated packets are mapped to the 127.0.0.1 address). It takes one option: .TP -.BI "--to-ports " "[-]" -This specifies a destination port or range or ports to use: without -this, the destination port is never altered. This is only valid with +.BR "--to-ports " "\fIport\fP[-\fIport\fP]" +This specifies a destination port or range of ports to use: without +this, the destination port is never altered. This is only valid if the rule also specifies .B "-p tcp" or -.BR "-p udp" ). -.SH EXTRA EXTENSIONS -The following extensions are not included by default in the standard -distribution. -.SS ttl -This module matches the time to live field in the IP header. -.TP -.BI "--ttl " "ttl" -Matches the given TTL value. -.SS TTL -This target is used to modify the time to live field in the IP header. -It is only valid in the -.B mangle -table. -.TP -.BI "--ttl-set " "ttl" -Set the TTL to the given value. -.TP -.BI "--ttl-dec " "ttl" -Decrement the TTL by the given value. -.TP -.BI "--ttl-inc " "ttl" -Increment the TTL by the given value. +.BR "-p udp" . .SS ULOG This target provides userspace logging of matching packets. When this target is set for a rule, the Linux kernel will multicast this packet @@ -727,23 +778,73 @@ through a socket. One or more userspace processes may then subscribe to various multicast groups and receive the packets. .TP -.BI "--ulog-nlgroup " "" +.BI "--ulog-nlgroup " "nlgroup" This specifies the netlink group (1-32) to which the packet is sent. Default value is 1. .TP -.BI "--ulog-prefix " "" +.BI "--ulog-prefix " "prefix" Prefix log messages with the specified prefix; up to 32 characters long, and useful fro distinguishing messages in the logs. .TP -.BI "--ulog-cprange " "" +.BI "--ulog-cprange " "size" Number of bytes to be copied to userspace. A value of 0 always copies -the entire packet, regardless of its size. Default is 0 +the entire packet, regardless of its size. Default is 0. .TP -.BI "--ulog-qthreshold " "" +.BI "--ulog-qthreshold " "size" Number of packet to queue inside kernel. Setting this value to, e.g. 10 accumulates ten packets inside the kernel and transmits them as one -netlink multipart message to userspace. Default is 1 (for backwards -compatibility) +netlink multipart message to userspace. Default is 1 (for backwards +compatibility). +.SS TCPMSS +This target allows to alter the MSS value of TCP SYN packets, to control +the maximum size for that connection (usually limiting it to your +outgoing interface's MTU minus 40). Of course, it can only be used +in conjunction with +.BR "-p tcp" . +.br +This target is used to overcome criminally braindead ISPs or servers +which block ICMP Fragmentation Needed packets. The symptoms of this +problem are that everything works fine from your Linux +firewall/router, but machines behind it can never exchange large +packets: +.br + 1) Web browsers connect, then hang with no data received. +.br + 2) Small mail works fine, but large emails hang. +.br + 3) ssh works fine, but scp hangs after initial handshaking. +.br +Workaround: activate this option and add a rule to your firewall +configuration like: +.br + iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\ +.br + -j TCPMSS --clamp-mss-to-pmtu +.TP +.BI "--set-mss " "value" +Explicitly set MSS option to specified value. +.TP +.B "--clamp-mss-to-pmtu" +Automatically clamp MSS value to (path_MTU - 40). +.TP +These options are mutually exclusive. +.SH EXTRA EXTENSIONS +The following extensions are not included by default in the standard +distribution. +.SS TTL +This target is used to modify the time to live field in the IP header. +It is only valid in the +.B mangle +table. +.TP +.BI "--ttl-set " "ttl" +Set the TTL to the given value. +.TP +.BI "--ttl-dec " "ttl" +Decrement the TTL by the given value. +.TP +.BI "--ttl-inc " "ttl" +Increment the TTL by the given value. .SH DIAGNOSTICS Various error messages are printed to standard error. The exit code is 0 for correct functioning. Errors which appear to be caused by @@ -787,9 +888,12 @@ seen previously. So the following options are handled differently: .br There are several other changes in iptables. .SH SEE ALSO -The packet-filtering-HOWTO, which details more iptables usage for packet filtering, the NAT-HOWTO, -which details NAT, and the netfilter-hacking-HOWTO which details the -internals. +The packet-filtering-HOWTO, which details more iptables usage for +packet filtering, the NAT-HOWTO, which details NAT, +and the netfilter-hacking-HOWTO which details the internals. +.br +See +.BR "http://www.netfilter.org/" . .SH AUTHORS Rusty Russell wrote iptables, in early consultation with Michael Neuling. @@ -806,6 +910,8 @@ Harald Welte wrote the ULOG target, TTL match+target and libipulog. .PP The Netfilter Core Team is: Marc Boucher, Jozsef Kadlecsik, James Morris, Harald Welte and Rusty Russell. +.PP +Man page written by Herve Eychenne . .\" .. and did I mention that we are incredibly cool people? .\" .. sexy, too .. .\" .. witty, charming, powerful .. -- cgit v1.2.3