Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 1 | .TH IPTABLES 8 "Mar 09, 2002" "" "" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 2 | .\" |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 3 | .\" Man page written by Herve Eychenne <rv@wallfire.org> (May 1999) |
| 4 | .\" It is based on ipchains page. |
| 5 | .\" TODO : add a word for protocol helpers (FTP, IRC, SNMP-ALG) |
| 6 | .\" add EXTRA EXTENSIONS matches |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 7 | .\" |
| 8 | .\" ipchains page by Paul ``Rusty'' Russell March 1997 |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 9 | .\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl> |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 10 | .\" |
| 11 | .\" This program is free software; you can redistribute it and/or modify |
| 12 | .\" it under the terms of the GNU General Public License as published by |
| 13 | .\" the Free Software Foundation; either version 2 of the License, or |
| 14 | .\" (at your option) any later version. |
| 15 | .\" |
| 16 | .\" This program is distributed in the hope that it will be useful, |
| 17 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | .\" GNU General Public License for more details. |
| 20 | .\" |
| 21 | .\" You should have received a copy of the GNU General Public License |
| 22 | .\" along with this program; if not, write to the Free Software |
| 23 | .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | .\" |
| 25 | .\" |
| 26 | .SH NAME |
| 27 | iptables \- IP packet filter administration |
| 28 | .SH SYNOPSIS |
| 29 | .BR "iptables -[ADC] " "chain rule-specification [options]" |
| 30 | .br |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 31 | .BR "iptables -I " "chain [rulenum] rule-specification [options]" |
| 32 | .br |
| 33 | .BR "iptables -R " "chain rulenum rule-specification [options]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 34 | .br |
| 35 | .BR "iptables -D " "chain rulenum [options]" |
| 36 | .br |
| 37 | .BR "iptables -[LFZ] " "[chain] [options]" |
| 38 | .br |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 39 | .BR "iptables -N " "chain" |
| 40 | .br |
| 41 | .BR "iptables -X " "[chain]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 42 | .br |
| 43 | .BR "iptables -P " "chain target [options]" |
| 44 | .br |
| 45 | .BR "iptables -E " "old-chain-name new-chain-name" |
| 46 | .SH DESCRIPTION |
| 47 | .B Iptables |
| 48 | is used to set up, maintain, and inspect the tables of IP packet |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 49 | filter rules in the Linux kernel. Several different tables |
| 50 | may be defined. Each table contains a number of built-in |
| 51 | chains and may also contain user-defined chains. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 52 | |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 53 | Each chain is a list of rules which can match a set of packets. Each |
| 54 | rule specifies what to do with a packet that matches. This is called |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 55 | a `target', which may be a jump to a user-defined chain in the same |
| 56 | table. |
| 57 | |
| 58 | .SH TARGETS |
| 59 | A firewall rule specifies criteria for a packet, and a target. If the |
| 60 | packet does not match, the next rule in the chain is the examined; if |
| 61 | it does match, then the next rule is specified by the value of the |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 62 | target, which can be the name of a user-defined chain or one of the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 63 | special values |
| 64 | .IR ACCEPT , |
| 65 | .IR DROP , |
| 66 | .IR QUEUE , |
| 67 | or |
| 68 | .IR RETURN . |
| 69 | .PP |
| 70 | .I ACCEPT |
| 71 | means to let the packet through. |
| 72 | .I DROP |
| 73 | means to drop the packet on the floor. |
| 74 | .I QUEUE |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 75 | means to pass the packet to userspace (if supported by the kernel). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 76 | .I RETURN |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 77 | means stop traversing this chain and resume at the next rule in the |
| 78 | previous (calling) chain. If the end of a built-in chain is reached |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 79 | or a rule in a built-in chain with target |
| 80 | .I RETURN |
| 81 | is matched, the target specified by the chain policy determines the |
| 82 | fate of the packet. |
| 83 | .SH TABLES |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 84 | There are current three independent tables (which tables are present |
| 85 | at any time depends on the kernel configuration options and which |
| 86 | modules are present). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 87 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 88 | .BI "-t, --table " "table" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 89 | This option specifies the packet matching table which the command |
| 90 | should operate on. If the kernel is configured with automatic module |
| 91 | loading, an attempt will be made to load the appropriate module for |
| 92 | that table if it is not already there. |
| 93 | |
| 94 | The tables are as follows: |
Harald Welte | 87d4be4 | 2001-07-05 06:26:37 +0000 | [diff] [blame] | 95 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 96 | .B "filter" |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 97 | This is the default table. It contains the built-in chains INPUT (for |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 98 | packets coming into the box itself), FORWARD (for packets being routed |
| 99 | through the box), and OUTPUT (for locally-generated packets). |
Harald Welte | 87d4be4 | 2001-07-05 06:26:37 +0000 | [diff] [blame] | 100 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 101 | .B "nat" |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 102 | This table is consulted when a packet that creates a new |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 103 | connection is encountered. It consists of three built-ins: PREROUTING |
| 104 | (for altering packets as soon as they come in), OUTPUT (for altering |
| 105 | locally-generated packets before routing), and POSTROUTING (for |
| 106 | altering packets as they are about to go out). |
Harald Welte | 87d4be4 | 2001-07-05 06:26:37 +0000 | [diff] [blame] | 107 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 108 | .B "mangle" |
| 109 | This table is used for specialized packet alteration. Until kernel |
| 110 | 2.4.17 it had two built-in chains: PREROUTING (for altering incoming |
| 111 | packets before routing) and OUTPUT (for altering locally-generated |
| 112 | packets before routing). Since kernel 2.4.18, three other built-in |
| 113 | chains are also supported : INPUT (for packets coming into the box itself), |
| 114 | FORWARD (for altering packets being routed through the box), and |
| 115 | POSTROUTING (for altering packets as they are about to go out). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 116 | .SH OPTIONS |
| 117 | The options that are recognized by |
| 118 | .B iptables |
| 119 | can be divided into several different groups. |
| 120 | .SS COMMANDS |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 121 | These options specify the specific action to perform. Only one of them |
| 122 | can be specified on the command line unless otherwise specified |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 123 | below. For all the long versions of the command and option names, you |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 124 | need to use only enough letters to ensure that |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 125 | .B iptables |
| 126 | can differentiate it from all other options. |
| 127 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 128 | .BI "-A, --append " "chain rule-specification" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 129 | Append one or more rules to the end of the selected chain. |
| 130 | When the source and/or destination names resolve to more than one |
| 131 | address, a rule will be added for each possible address combination. |
| 132 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 133 | .BI "-D, --delete " "chain rule-specification" |
| 134 | .ns |
| 135 | .TP |
| 136 | .BI "-D, --delete " "chain rulenum" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 137 | Delete one or more rules from the selected chain. There are two |
| 138 | versions of this command: the rule can be specified as a number in the |
| 139 | chain (starting at 1 for the first rule) or a rule to match. |
| 140 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 141 | .BR "-I, --insert " "\fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 142 | Insert one or more rules in the selected chain as the given rule |
| 143 | number. So, if the rule number is 1, the rule or rules are inserted |
| 144 | at the head of the chain. This is also the default if no rule number |
| 145 | is specified. |
| 146 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 147 | .BI "-R, --replace " "chain rulenum rule-specification" |
| 148 | Replace a rule in the selected chain. If the source and/or |
| 149 | destination names resolve to multiple addresses, the command will |
| 150 | fail. Rules are numbered starting at 1. |
| 151 | .TP |
| 152 | .BR "-L, --list " "[\fIchain\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 153 | List all rules in the selected chain. If no chain is selected, all |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 154 | chains are listed. As every other iptables command, it applies to the |
| 155 | specified table (filter is the default), so NAT rules get listed by |
| 156 | .br |
| 157 | iptables -t nat -n -L |
| 158 | .br |
| 159 | Please note that it is often used with the |
| 160 | .B -n |
| 161 | option, in order to avoid long reverse DNS lookups. |
| 162 | It is legal to specify the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 163 | .B -Z |
| 164 | (zero) option as well, in which case the chain(s) will be atomically |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 165 | listed and zeroed. The exact output is affected by the other |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 166 | arguments given. |
| 167 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 168 | .BR "-F, --flush " "[\fIchain\fP]" |
| 169 | Flush the selected chain (all the chains in the table if none is given). |
| 170 | This is equivalent to deleting all the rules one by one. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 171 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 172 | .BR "-Z, --zero " "[\fIchain\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 173 | Zero the packet and byte counters in all chains. It is legal to |
| 174 | specify the |
| 175 | .B "-L, --list" |
| 176 | (list) option as well, to see the counters immediately before they are |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 177 | cleared. (See above.) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 178 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 179 | .BI "-N, --new-chain " "chain" |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 180 | Create a new user-defined chain by the given name. There must be no |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 181 | target of that name already. |
| 182 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 183 | .BR "-X, --delete-chain " "[\fIchain\fP]" |
| 184 | Delete the optional user-defined chain specified. There must be no references |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 185 | to the chain. If there are, you must delete or replace the referring |
| 186 | rules before the chain can be deleted. If no argument is given, it |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 187 | will attempt to delete every non-builtin chain in the table. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 188 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 189 | .BI "-P, --policy " "chain target" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 190 | Set the policy for the chain to the given target. See the section |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 191 | .B TARGETS |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 192 | for the legal targets. Only built-in (non-user-defined) chains can have |
| 193 | policies, and neither built-in nor user-defined chains can be policy |
| 194 | targets. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 195 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 196 | .BI "-E, --rename-chain " "old-chain new-chain" |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 197 | Rename the user specified chain to the user supplied name. This is |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 198 | cosmetic, and has no effect on the structure of the table. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 199 | .TP |
| 200 | .B -h |
| 201 | Help. |
| 202 | Give a (currently very brief) description of the command syntax. |
| 203 | .SS PARAMETERS |
| 204 | The following parameters make up a rule specification (as used in the |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 205 | add, delete, insert, replace and append commands). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 206 | .TP |
Rusty Russell | 2e0a321 | 2000-04-19 11:23:18 +0000 | [diff] [blame] | 207 | .BR "-p, --protocol " "[!] \fIprotocol\fP" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 208 | The protocol of the rule or of the packet to check. |
| 209 | The specified protocol can be one of |
| 210 | .IR tcp , |
| 211 | .IR udp , |
| 212 | .IR icmp , |
| 213 | or |
| 214 | .IR all , |
| 215 | or it can be a numeric value, representing one of these protocols or a |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 216 | different one. A protocol name from /etc/protocols is also allowed. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 217 | A "!" argument before the protocol inverts the |
| 218 | test. The number zero is equivalent to |
| 219 | .IR all . |
| 220 | Protocol |
| 221 | .I all |
| 222 | will match with all protocols and is taken as default when this |
| 223 | option is omitted. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 224 | .TP |
| 225 | .BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]" |
| 226 | Source specification. |
| 227 | .I Address |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 228 | can be either a network name, a hostname (please note that specifying |
| 229 | any name to be resolved with a remote query such as DNS is a really bad idea), |
| 230 | a network IP address (with /mask), or a plain IP address. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 231 | The |
| 232 | .I mask |
| 233 | can be either a network mask or a plain number, |
| 234 | specifying the number of 1's at the left side of the network mask. |
| 235 | Thus, a mask of |
| 236 | .I 24 |
| 237 | is equivalent to |
| 238 | .IR 255.255.255.0 . |
| 239 | A "!" argument before the address specification inverts the sense of |
| 240 | the address. The flag |
| 241 | .B --src |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 242 | is an alias for this option. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 243 | .TP |
| 244 | .BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]" |
| 245 | Destination specification. |
| 246 | See the description of the |
| 247 | .B -s |
| 248 | (source) flag for a detailed description of the syntax. The flag |
| 249 | .B --dst |
| 250 | is an alias for this option. |
| 251 | .TP |
| 252 | .BI "-j, --jump " "target" |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 253 | This specifies the target of the rule; i.e., what to do if the packet |
| 254 | matches it. The target can be a user-defined chain (other than the |
| 255 | one this rule is in), one of the special builtin targets which decide |
| 256 | the fate of the packet immediately, or an extension (see |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 257 | .B EXTENSIONS |
| 258 | below). If this |
| 259 | option is omitted in a rule, then matching the rule will have no |
| 260 | effect on the packet's fate, but the counters on the rule will be |
| 261 | incremented. |
| 262 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 263 | .BR "-i, --in-interface " "[!] \fIname\fP" |
| 264 | Name of an interface via which a packet is going to be received (only for |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 265 | packets entering the |
| 266 | .BR INPUT , |
| 267 | .B FORWARD |
| 268 | and |
| 269 | .B PREROUTING |
| 270 | chains). When the "!" argument is used before the interface name, the |
| 271 | sense is inverted. If the interface name ends in a "+", then any |
| 272 | interface which begins with this name will match. If this option is |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 273 | omitted, any interface name will match. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 274 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 275 | .BR "-o, --out-interface " "[!] \fIname\fP" |
| 276 | Name of an interface via which a packet is going to be sent (for packets |
| 277 | entering the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 278 | .BR FORWARD , |
| 279 | .B OUTPUT |
| 280 | and |
| 281 | .B POSTROUTING |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 282 | chains). When the "!" argument is used before the interface name, the |
| 283 | sense is inverted. If the interface name ends in a "+", then any |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 284 | interface which begins with this name will match. If this option is |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 285 | omitted, any interface name will match. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 286 | .TP |
| 287 | .B "[!] " "-f, --fragment" |
| 288 | This means that the rule only refers to second and further fragments |
| 289 | of fragmented packets. Since there is no way to tell the source or |
| 290 | destination ports of such a packet (or ICMP type), such a packet will |
| 291 | not match any rules which specify them. When the "!" argument |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 292 | precedes the "-f" flag, the rule will only match head fragments, or |
| 293 | unfragmented packets. |
Harald Welte | ccd49e5 | 2001-01-23 22:54:34 +0000 | [diff] [blame] | 294 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 295 | .BI "-c, --set-counters " "PKTS BYTES" |
Harald Welte | ccd49e5 | 2001-01-23 22:54:34 +0000 | [diff] [blame] | 296 | This enables the administrater to initialize the packet and byte |
| 297 | counters of a rule (during |
| 298 | .B INSERT, |
| 299 | .B APPEND, |
| 300 | .B REPLACE |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 301 | operations). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 302 | .SS "OTHER OPTIONS" |
| 303 | The following additional options can be specified: |
| 304 | .TP |
| 305 | .B "-v, --verbose" |
| 306 | Verbose output. This option makes the list command show the interface |
| 307 | address, the rule options (if any), and the TOS masks. The packet and |
| 308 | byte counters are also listed, with the suffix 'K', 'M' or 'G' for |
| 309 | 1000, 1,000,000 and 1,000,000,000 multipliers respectively (but see |
| 310 | the |
| 311 | .B -x |
| 312 | flag to change this). |
| 313 | For appending, insertion, deletion and replacement, this causes |
| 314 | detailed information on the rule or rules to be printed. |
| 315 | .TP |
| 316 | .B "-n, --numeric" |
| 317 | Numeric output. |
| 318 | IP addresses and port numbers will be printed in numeric format. |
| 319 | By default, the program will try to display them as host names, |
| 320 | network names, or services (whenever applicable). |
| 321 | .TP |
| 322 | .B "-x, --exact" |
| 323 | Expand numbers. |
| 324 | Display the exact value of the packet and byte counters, |
| 325 | instead of only the rounded number in K's (multiples of 1000) |
| 326 | M's (multiples of 1000K) or G's (multiples of 1000M). This option is |
Marc Boucher | f127a19 | 2000-03-20 08:32:15 +0000 | [diff] [blame] | 327 | only relevant for the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 328 | .B -L |
| 329 | command. |
| 330 | .TP |
| 331 | .B "--line-numbers" |
| 332 | When listing rules, add line numbers to the beginning of each rule, |
| 333 | corresponding to that rule's position in the chain. |
Chapman Brad | 45493a8 | 2001-02-23 09:08:13 +0000 | [diff] [blame] | 334 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 335 | .B "--modprobe=command" |
Chapman Brad | 45493a8 | 2001-02-23 09:08:13 +0000 | [diff] [blame] | 336 | When adding or inserting rules into a chain, use |
| 337 | .B command |
| 338 | to load any necessary modules (targets, match extensions, etc). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 339 | .SH MATCH EXTENSIONS |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 340 | iptables can use extended packet matching modules. These are loaded |
| 341 | in two ways: implicitly, when |
| 342 | .B -p |
| 343 | or |
| 344 | .B --protocol |
| 345 | is specified, or with the |
| 346 | .B -m |
| 347 | or |
| 348 | .B --match |
| 349 | options, followed by the matching module name; after these, various |
| 350 | extra command line options become available, depending on the specific |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 351 | module. You can specify multiple extended match modules in one line, |
| 352 | and you can use the |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 353 | .B -h |
| 354 | or |
| 355 | .B --help |
| 356 | options after the module has been specified to receive help specific |
| 357 | to that module. |
| 358 | |
| 359 | The following are included in the base package, and most of these can |
| 360 | be preceded by a |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 361 | .B ! |
| 362 | to invert the sense of the match. |
| 363 | .SS tcp |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 364 | These extensions are loaded if `--protocol tcp' is specified. It |
| 365 | provides the following options: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 366 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 367 | .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 368 | Source port or port range specification. This can either be a service |
| 369 | name or a port number. An inclusive range can also be specified, |
| 370 | using the format |
James Morris | 59e90fd | 2000-06-23 16:44:47 +0000 | [diff] [blame] | 371 | .IR port : port . |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 372 | If the first port is omitted, "0" is assumed; if the last is omitted, |
| 373 | "65535" is assumed. |
| 374 | If the second port greater then the first they will be swapped. |
| 375 | The flag |
| 376 | .B --sport |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 377 | is a convenient alias for this option. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 378 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 379 | .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" |
| 380 | Destination port or port range specification. The flag |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 381 | .B --dport |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 382 | is a convenient alias for this option. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 383 | .TP |
| 384 | .BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP" |
| 385 | Match when the TCP flags are as specified. The first argument is the |
| 386 | flags which we should examine, written as a comma-separated list, and |
| 387 | the second argument is a comma-separated list of flags which must be |
| 388 | set. Flags are: |
| 389 | .BR "SYN ACK FIN RST URG PSH ALL NONE" . |
| 390 | Hence the command |
| 391 | .br |
Marc Boucher | f127a19 | 2000-03-20 08:32:15 +0000 | [diff] [blame] | 392 | iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 393 | .br |
| 394 | will only match packets with the SYN flag set, and the ACK, FIN and |
| 395 | RST flags unset. |
| 396 | .TP |
| 397 | .B "[!] --syn" |
| 398 | Only match TCP packets with the SYN bit set and the ACK and FIN bits |
| 399 | cleared. Such packets are used to request TCP connection initiation; |
| 400 | for example, blocking such packets coming in an interface will prevent |
| 401 | incoming TCP connections, but outgoing TCP connections will be |
| 402 | unaffected. |
| 403 | It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP. |
| 404 | If the "!" flag precedes the "--syn", the sense of the |
| 405 | option is inverted. |
| 406 | .TP |
| 407 | .BR "--tcp-option " "[!] \fInumber\fP" |
| 408 | Match if TCP option set. |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 409 | .TP |
| 410 | .BR "--mss " "\fIvalue\fP[:\fIvalue\fP]" |
| 411 | Match TCP SYN or SYN/ACK packets with the specified MSS value (or range), |
| 412 | which control the maximum packet size for that connection. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 413 | .SS udp |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 414 | These extensions are loaded if `--protocol udp' is specified. It |
| 415 | provides the following options: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 416 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 417 | .BR "--source-port " "[!] \fIport\fP[:\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 418 | Source port or port range specification. |
| 419 | See the description of the |
| 420 | .B --source-port |
| 421 | option of the TCP extension for details. |
| 422 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 423 | .BR "--destination-port " "[!] \fIport\fP[:\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 424 | Destination port or port range specification. |
| 425 | See the description of the |
| 426 | .B --destination-port |
| 427 | option of the TCP extension for details. |
| 428 | .SS icmp |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 429 | This extension is loaded if `--protocol icmp' is specified. It |
| 430 | provides the following option: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 431 | .TP |
| 432 | .BR "--icmp-type " "[!] \fItypename\fP" |
| 433 | This allows specification of the ICMP type, which can be a numeric |
| 434 | ICMP type, or one of the ICMP type names shown by the command |
| 435 | .br |
| 436 | iptables -p icmp -h |
| 437 | .br |
| 438 | .SS mac |
| 439 | .TP |
| 440 | .BR "--mac-source " "[!] \fIaddress\fP" |
| 441 | Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX. |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 442 | Note that this only makes sense for packets coming from an Ethernet device |
| 443 | and entering the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 444 | .BR PREROUTING , |
Rusty Russell | 4b3c03d | 2000-07-03 10:11:55 +0000 | [diff] [blame] | 445 | .B FORWARD |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 446 | or |
| 447 | .B INPUT |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 448 | chains. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 449 | .SS limit |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 450 | This module matches at a limited rate using a token bucket filter. |
| 451 | A rule using this extension will match until this limit is reached |
| 452 | (unless the `!' flag is used). It can be used in combination with the |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 453 | .B LOG |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 454 | target to give limited logging, for example. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 455 | .TP |
| 456 | .BI "--limit " "rate" |
| 457 | Maximum average matching rate: specified as a number, with an optional |
| 458 | `/second', `/minute', `/hour', or `/day' suffix; the default is |
| 459 | 3/hour. |
| 460 | .TP |
| 461 | .BI "--limit-burst " "number" |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 462 | Maximum initial number of packets to match: this number gets |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 463 | recharged by one every time the limit specified above is not reached, |
| 464 | up to this number; the default is 5. |
| 465 | .SS multiport |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 466 | This module matches a set of source or destination ports. Up to 15 |
| 467 | ports can be specified. It can only be used in conjunction with |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 468 | .B "-p tcp" |
| 469 | or |
| 470 | .BR "-p udp" . |
| 471 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 472 | .BR "--source-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" |
| 473 | Match if the source port is one of the given ports. The flag |
| 474 | .B --sports |
| 475 | is a convenient alias for this option. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 476 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 477 | .BR "--destination-ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" |
| 478 | Match if the destination port is one of the given ports. The flag |
| 479 | .B --dports |
| 480 | is a convenient alias for this option. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 481 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 482 | .BR "--ports " "\fIport\fP[,\fIport\fP[,\fIport\fP...]]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 483 | Match if the both the source and destination ports are equal to each |
| 484 | other and to one of the given ports. |
| 485 | .SS mark |
| 486 | This module matches the netfilter mark field associated with a packet |
| 487 | (which can be set using the |
| 488 | .B MARK |
| 489 | target below). |
| 490 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 491 | .BR "--mark " "\fIvalue\fP[/\fImask\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 492 | Matches packets with the given unsigned mark value (if a mask is |
Harald Welte | 87d4be4 | 2001-07-05 06:26:37 +0000 | [diff] [blame] | 493 | specified, this is logically ANDed with the mask before the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 494 | comparison). |
| 495 | .SS owner |
| 496 | This module attempts to match various characteristics of the packet |
| 497 | creator, for locally-generated packets. It is only valid in the |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 498 | .B OUTPUT |
| 499 | chain, and even this some packets (such as ICMP ping responses) may |
| 500 | have no owner, and hence never match. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 501 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 502 | .BI "--uid-owner " "userid" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 503 | Matches if the packet was created by a process with the given |
| 504 | effective user id. |
| 505 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 506 | .BI "--gid-owner " "groupid" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 507 | Matches if the packet was created by a process with the given |
| 508 | effective group id. |
| 509 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 510 | .BI "--pid-owner " "processid" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 511 | Matches if the packet was created by a process with the given |
| 512 | process id. |
| 513 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 514 | .BI "--sid-owner " "sessionid" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 515 | Matches if the packet was created by a process in the given session |
| 516 | group. |
Marc Boucher | f5c32d6 | 2002-01-19 12:46:04 +0000 | [diff] [blame] | 517 | .TP |
| 518 | .BI "--cmd-owner " "name" |
| 519 | Matches if the packet was created by a process with the given command name. |
| 520 | (this option is present only if iptables was compiled under a kernel |
| 521 | supporting this feature) |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 522 | .SS state |
| 523 | This module, when combined with connection tracking, allows access to |
| 524 | the connection tracking state for this packet. |
| 525 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 526 | .BI "--state " "state" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 527 | Where state is a comma separated list of the connection states to |
| 528 | match. Possible states are |
| 529 | .B INVALID |
| 530 | meaning that the packet is associated with no known connection, |
| 531 | .B ESTABLISHED |
| 532 | meaning that the packet is associated with a connection which has seen |
| 533 | packets in both directions, |
| 534 | .B NEW |
| 535 | meaning that the packet has started a new connection, or otherwise |
| 536 | associated with a connection which has not seen packets in both |
| 537 | directions, and |
| 538 | .B RELATED |
| 539 | meaning that the packet is starting a new connection, but is |
| 540 | associated with an existing connection, such as an FTP data transfer, |
| 541 | or an ICMP error. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 542 | .SS tos |
| 543 | This module matches the 8 bits of Type of Service field in the IP |
| 544 | header (ie. including the precedence bits). |
| 545 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 546 | .BI "--tos " "tos" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 547 | The argument is either a standard name, (use |
| 548 | .br |
| 549 | iptables -m tos -h |
| 550 | .br |
| 551 | to see the list), or a numeric value to match. |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 552 | .SS ah |
| 553 | This module matches the SPIs in AH header of IPSec packets. |
| 554 | .TP |
| 555 | .BR "--ahspi " "[!] \fIspi\fP[:\fIspi\fP]" |
| 556 | .SS esp |
| 557 | This module matches the SPIs in ESP header of IPSec packets. |
| 558 | .TP |
| 559 | .BR "--espspi " "[!] \fIspi\fP[:\fIspi\fP]" |
| 560 | .SS length |
| 561 | This module matches the length of a packet against a specific value |
| 562 | or range of values. |
| 563 | .TP |
| 564 | .BR "--length " "\fIlength\fP[:\fIlength\fP]" |
| 565 | .SS ttl |
| 566 | This module matches the time to live field in the IP header. |
| 567 | .TP |
| 568 | .BI "--ttl " "ttl" |
| 569 | Matches the given TTL value. |
| 570 | .SS owner |
| 571 | This module attempts to match various characteristics of the packet |
| 572 | creator, for locally-generated packets. It is only valid in the |
| 573 | .B OUTPUT |
| 574 | chain, and even this some packets (such as ICMP ping responses) may |
| 575 | have no owner, and hence never match. This is regarded as experimental. |
| 576 | .TP |
| 577 | .BI "--uid-owner " "userid" |
| 578 | Matches if the packet was created by a process with the given |
| 579 | effective user id. |
| 580 | .TP |
| 581 | .BI "--gid-owner " "groupid" |
| 582 | Matches if the packet was created by a process with the given |
| 583 | effective group id. |
| 584 | .TP |
| 585 | .BI "--pid-owner " "processid" |
| 586 | Matches if the packet was created by a process with the given |
| 587 | process id. |
| 588 | .TP |
| 589 | .BI "--sid-owner " "sessionid" |
| 590 | Matches if the packet was created by a process in the given session |
| 591 | group. |
| 592 | .SS unclean |
| 593 | This module takes no options, but attempts to match packets which seem |
| 594 | malformed or unusual. This is regarded as experimental. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 595 | .SH TARGET EXTENSIONS |
| 596 | iptables can use extended target modules: the following are included |
| 597 | in the standard distribution. |
| 598 | .SS LOG |
| 599 | Turn on kernel logging of matching packets. When this option is set |
| 600 | for a rule, the Linux kernel will print some information on all |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 601 | matching packets (like most IP header fields) via the kernel log |
| 602 | (where it can be read with |
| 603 | .I dmesg |
| 604 | or |
| 605 | .IR syslogd (8)). |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 606 | This is a "non-terminating target", i.e. rule traversal continues at |
| 607 | the next rule. So if you want to LOG the packets you refuse, use two |
| 608 | separate rules with the same matching criterias, first using target LOG |
| 609 | then DROP (or REJECT). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 610 | .TP |
| 611 | .BI "--log-level " "level" |
| 612 | Level of logging (numeric or see \fIsyslog.conf\fP(5)). |
| 613 | .TP |
| 614 | .BI "--log-prefix " "prefix" |
Rusty Russell | f81427e | 2000-09-13 04:20:38 +0000 | [diff] [blame] | 615 | Prefix log messages with the specified prefix; up to 29 letters long, |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 616 | and useful for distinguishing messages in the logs. |
| 617 | .TP |
| 618 | .B --log-tcp-sequence |
| 619 | Log TCP sequence numbers. This is a security risk if the log is |
| 620 | readable by users. |
| 621 | .TP |
| 622 | .B --log-tcp-options |
| 623 | Log options from the TCP packet header. |
| 624 | .TP |
| 625 | .B --log-ip-options |
| 626 | Log options from the IP packet header. |
| 627 | .SS MARK |
| 628 | This is used to set the netfilter mark value associated with the |
| 629 | packet. It is only valid in the |
| 630 | .B mangle |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 631 | table. It can for example be used in conjunction with iproute2. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 632 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 633 | .BI "--set-mark " "mark" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 634 | .SS REJECT |
| 635 | This is used to send back an error packet in response to the matched |
| 636 | packet: otherwise it is equivalent to |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 637 | .B DROP |
| 638 | so it is a terminating TARGET, ending rule traversal. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 639 | This target is only valid in the |
| 640 | .BR INPUT , |
| 641 | .B FORWARD |
| 642 | and |
| 643 | .B OUTPUT |
Rusty Russell | 9cadb43 | 2000-05-10 00:18:06 +0000 | [diff] [blame] | 644 | chains, and user-defined chains which are only called from those |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 645 | chains. The following option controls the nature of the error packet |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 646 | returned: |
| 647 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 648 | .BI "--reject-with " "type" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 649 | The type given can be |
| 650 | .BR icmp-net-unreachable , |
| 651 | .BR icmp-host-unreachable , |
Rusty Russell | 14f390f | 2000-07-30 01:10:04 +0000 | [diff] [blame] | 652 | .BR icmp-port-unreachable , |
| 653 | .BR icmp-proto-unreachable , |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 654 | .BR "icmp-net-prohibited or" |
Rusty Russell | 14f390f | 2000-07-30 01:10:04 +0000 | [diff] [blame] | 655 | .BR icmp-host-prohibited , |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 656 | which return the appropriate ICMP error message (\fBport-unreachable\fP is |
| 657 | the default). The option |
Rusty Russell | 14f390f | 2000-07-30 01:10:04 +0000 | [diff] [blame] | 658 | .B tcp-reset |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 659 | can be used on rules which only match the TCP protocol: this causes a |
| 660 | TCP RST packet to be sent back. This is mainly useful for blocking |
| 661 | .I ident |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 662 | (113/tcp) probes which frequently occur when sending mail to broken mail |
| 663 | hosts (which won't accept your mail otherwise). |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 664 | .SS TOS |
| 665 | This is used to set the 8-bit Type of Service field in the IP header. |
| 666 | It is only valid in the |
| 667 | .B mangle |
| 668 | table. |
| 669 | .TP |
Bert Hubert | 20ecf7a | 2000-03-24 01:56:37 +0000 | [diff] [blame] | 670 | .BI "--set-tos " "tos" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 671 | You can use a numeric TOS values, or use |
| 672 | .br |
| 673 | iptables -j TOS -h |
| 674 | .br |
| 675 | to see the list of valid TOS names. |
| 676 | .SS MIRROR |
| 677 | This is an experimental demonstration target which inverts the source |
| 678 | and destination fields in the IP header and retransmits the packet. |
| 679 | It is only valid in the |
| 680 | .BR INPUT , |
| 681 | .B FORWARD |
| 682 | and |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 683 | .B PREROUTING |
| 684 | chains, and user-defined chains which are only called from those |
| 685 | chains. Note that the outgoing packets are |
| 686 | .B NOT |
| 687 | seen by any packet filtering chains, connection tracking or NAT, to |
| 688 | avoid loops and other problems. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 689 | .SS SNAT |
| 690 | This target is only valid in the |
| 691 | .B nat |
| 692 | table, in the |
| 693 | .B POSTROUTING |
| 694 | chain. It specifies that the source address of the packet should be |
| 695 | modified (and all future packets in this connection will also be |
| 696 | mangled), and rules should cease being examined. It takes one option: |
| 697 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 698 | .BR "--to-source " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 699 | which can specify a single new source IP address, an inclusive range |
| 700 | of IP addresses, and optionally, a port range (which is only valid if |
| 701 | the rule also specifies |
| 702 | .B "-p tcp" |
| 703 | or |
| 704 | .BR "-p udp" ). |
| 705 | If no port range is specified, then source ports below 512 will be |
Harald Welte | 0112abb | 2001-02-19 21:48:13 +0000 | [diff] [blame] | 706 | mapped to other ports below 512: those between 512 and 1023 inclusive |
| 707 | will be mapped to ports below 1024, and other ports will be mapped to |
| 708 | 1024 or above. Where possible, no port alteration will occur. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 709 | .SS DNAT |
| 710 | This target is only valid in the |
| 711 | .B nat |
| 712 | table, in the |
| 713 | .B PREROUTING |
| 714 | and |
| 715 | .B OUTPUT |
Rusty Russell | 9cadb43 | 2000-05-10 00:18:06 +0000 | [diff] [blame] | 716 | chains, and user-defined chains which are only called from those |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 717 | chains. It specifies that the destination address of the packet |
| 718 | should be modified (and all future packets in this connection will |
| 719 | also be mangled), and rules should cease being examined. It takes one |
| 720 | option: |
| 721 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 722 | .BR "--to-destination " "\fIipaddr\fP[-\fIipaddr\fP][:\fIport\fP-\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 723 | which can specify a single new destination IP address, an inclusive |
| 724 | range of IP addresses, and optionally, a port range (which is only |
| 725 | valid if the rule also specifies |
| 726 | .B "-p tcp" |
| 727 | or |
| 728 | .BR "-p udp" ). |
| 729 | If no port range is specified, then the destination port will never be |
| 730 | modified. |
| 731 | .SS MASQUERADE |
| 732 | This target is only valid in the |
| 733 | .B nat |
| 734 | table, in the |
| 735 | .B POSTROUTING |
| 736 | chain. It should only be used with dynamically assigned IP (dialup) |
| 737 | connections: if you have a static IP address, you should use the SNAT |
| 738 | target. Masquerading is equivalent to specifying a mapping to the IP |
| 739 | address of the interface the packet is going out, but also has the |
| 740 | effect that connections are |
| 741 | .I forgotten |
Marc Boucher | f127a19 | 2000-03-20 08:32:15 +0000 | [diff] [blame] | 742 | when the interface goes down. This is the correct behavior when the |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 743 | next dialup is unlikely to have the same interface address (and hence |
| 744 | any established connections are lost anyway). It takes one option: |
| 745 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 746 | .BR "--to-ports " "\fIport\fP[-\fIport\fP]" |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 747 | This specifies a range of source ports to use, overriding the default |
| 748 | .B SNAT |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 749 | source port-selection heuristics (see above). This is only valid |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 750 | if the rule also specifies |
| 751 | .B "-p tcp" |
| 752 | or |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 753 | .BR "-p udp" . |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 754 | .SS REDIRECT |
| 755 | This target is only valid in the |
| 756 | .B nat |
| 757 | table, in the |
| 758 | .B PREROUTING |
| 759 | and |
| 760 | .B OUTPUT |
Rusty Russell | 9cadb43 | 2000-05-10 00:18:06 +0000 | [diff] [blame] | 761 | chains, and user-defined chains which are only called from those |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 762 | chains. It alters the destination IP address to send the packet to |
| 763 | the machine itself (locally-generated packets are mapped to the |
Rusty Russell | 9cadb43 | 2000-05-10 00:18:06 +0000 | [diff] [blame] | 764 | 127.0.0.1 address). It takes one option: |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 765 | .TP |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 766 | .BR "--to-ports " "\fIport\fP[-\fIport\fP]" |
| 767 | This specifies a destination port or range of ports to use: without |
| 768 | this, the destination port is never altered. This is only valid |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 769 | if the rule also specifies |
| 770 | .B "-p tcp" |
| 771 | or |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 772 | .BR "-p udp" . |
| 773 | .SS ULOG |
| 774 | This target provides userspace logging of matching packets. When this |
| 775 | target is set for a rule, the Linux kernel will multicast this packet |
| 776 | through a |
| 777 | .IR netlink |
| 778 | socket. One or more userspace processes may then subscribe to various |
| 779 | multicast groups and receive the packets. |
| 780 | .TP |
| 781 | .BI "--ulog-nlgroup " "nlgroup" |
| 782 | This specifies the netlink group (1-32) to which the packet is sent. |
| 783 | Default value is 1. |
| 784 | .TP |
| 785 | .BI "--ulog-prefix " "prefix" |
| 786 | Prefix log messages with the specified prefix; up to 32 characters |
| 787 | long, and useful fro distinguishing messages in the logs. |
| 788 | .TP |
| 789 | .BI "--ulog-cprange " "size" |
| 790 | Number of bytes to be copied to userspace. A value of 0 always copies |
| 791 | the entire packet, regardless of its size. Default is 0. |
| 792 | .TP |
| 793 | .BI "--ulog-qthreshold " "size" |
| 794 | Number of packet to queue inside kernel. Setting this value to, e.g. 10 |
| 795 | accumulates ten packets inside the kernel and transmits them as one |
| 796 | netlink multipart message to userspace. Default is 1 (for backwards |
| 797 | compatibility). |
| 798 | .SS TCPMSS |
| 799 | This target allows to alter the MSS value of TCP SYN packets, to control |
| 800 | the maximum size for that connection (usually limiting it to your |
| 801 | outgoing interface's MTU minus 40). Of course, it can only be used |
| 802 | in conjunction with |
| 803 | .BR "-p tcp" . |
| 804 | .br |
| 805 | This target is used to overcome criminally braindead ISPs or servers |
| 806 | which block ICMP Fragmentation Needed packets. The symptoms of this |
| 807 | problem are that everything works fine from your Linux |
| 808 | firewall/router, but machines behind it can never exchange large |
| 809 | packets: |
| 810 | .br |
| 811 | 1) Web browsers connect, then hang with no data received. |
| 812 | .br |
| 813 | 2) Small mail works fine, but large emails hang. |
| 814 | .br |
| 815 | 3) ssh works fine, but scp hangs after initial handshaking. |
| 816 | .br |
| 817 | Workaround: activate this option and add a rule to your firewall |
| 818 | configuration like: |
| 819 | .br |
| 820 | iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN \\ |
| 821 | .br |
| 822 | -j TCPMSS --clamp-mss-to-pmtu |
| 823 | .TP |
| 824 | .BI "--set-mss " "value" |
| 825 | Explicitly set MSS option to specified value. |
| 826 | .TP |
| 827 | .B "--clamp-mss-to-pmtu" |
| 828 | Automatically clamp MSS value to (path_MTU - 40). |
| 829 | .TP |
| 830 | These options are mutually exclusive. |
Rusty Russell | 86573e5 | 2000-10-11 06:01:13 +0000 | [diff] [blame] | 831 | .SH EXTRA EXTENSIONS |
| 832 | The following extensions are not included by default in the standard |
| 833 | distribution. |
Rusty Russell | 86573e5 | 2000-10-11 06:01:13 +0000 | [diff] [blame] | 834 | .SS TTL |
| 835 | This target is used to modify the time to live field in the IP header. |
| 836 | It is only valid in the |
| 837 | .B mangle |
| 838 | table. |
| 839 | .TP |
| 840 | .BI "--ttl-set " "ttl" |
| 841 | Set the TTL to the given value. |
| 842 | .TP |
| 843 | .BI "--ttl-dec " "ttl" |
| 844 | Decrement the TTL by the given value. |
| 845 | .TP |
| 846 | .BI "--ttl-inc " "ttl" |
| 847 | Increment the TTL by the given value. |
Rusty Russell | 86573e5 | 2000-10-11 06:01:13 +0000 | [diff] [blame] | 848 | .SH DIAGNOSTICS |
| 849 | Various error messages are printed to standard error. The exit code |
| 850 | is 0 for correct functioning. Errors which appear to be caused by |
| 851 | invalid or abused command line parameters cause an exit code of 2, and |
| 852 | other errors cause an exit code of 1. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 853 | .SH BUGS |
| 854 | Check is not implemented (yet). |
| 855 | .SH COMPATIBILITY WITH IPCHAINS |
| 856 | This |
| 857 | .B iptables |
| 858 | is very similar to ipchains by Rusty Russell. The main difference is |
| 859 | that the chains |
| 860 | .B INPUT |
| 861 | and |
| 862 | .B OUTPUT |
| 863 | are only traversed for packets coming into the local host and |
| 864 | originating from the local host respectively. Hence every packet only |
| 865 | passes through one of the three chains; previously a forwarded packet |
| 866 | would pass through all three. |
| 867 | .PP |
| 868 | The other main difference is that |
| 869 | .B -i |
| 870 | refers to the input interface; |
| 871 | .B -o |
| 872 | refers to the output interface, and both are available for packets |
| 873 | entering the |
| 874 | .B FORWARD |
| 875 | chain. |
| 876 | .PP The various forms of NAT have been separated out; |
| 877 | .B iptables |
| 878 | is a pure packet filter when using the default `filter' table, with |
| 879 | optional extension modules. This should simplify much of the previous |
| 880 | confusion over the combination of IP masquerading and packet filtering |
| 881 | seen previously. So the following options are handled differently: |
| 882 | .br |
| 883 | -j MASQ |
| 884 | .br |
| 885 | -M -S |
| 886 | .br |
| 887 | -M -L |
| 888 | .br |
| 889 | There are several other changes in iptables. |
| 890 | .SH SEE ALSO |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 891 | The packet-filtering-HOWTO, which details more iptables usage for |
| 892 | packet filtering, the NAT-HOWTO, which details NAT, |
| 893 | and the netfilter-hacking-HOWTO which details the internals. |
| 894 | .br |
| 895 | See |
| 896 | .BR "http://www.netfilter.org/" . |
Marc Boucher | f127a19 | 2000-03-20 08:32:15 +0000 | [diff] [blame] | 897 | .SH AUTHORS |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 898 | Rusty Russell wrote iptables, in early consultation with Michael |
| 899 | Neuling. |
| 900 | .PP |
Marc Boucher | f127a19 | 2000-03-20 08:32:15 +0000 | [diff] [blame] | 901 | Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet |
| 902 | selection framework in iptables, then wrote the mangle table, the owner match, |
| 903 | the mark stuff, and ran around doing cool stuff everywhere. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 904 | .PP |
| 905 | James Morris wrote the TOS target, and tos match. |
| 906 | .PP |
| 907 | Jozsef Kadlecsik wrote the REJECT target. |
| 908 | .PP |
Rusty Russell | 86573e5 | 2000-10-11 06:01:13 +0000 | [diff] [blame] | 909 | Harald Welte wrote the ULOG target, TTL match+target and libipulog. |
Rusty Russell | 5245182 | 2000-08-27 07:47:46 +0000 | [diff] [blame] | 910 | .PP |
James Morris | edfce4e | 2001-12-07 10:23:22 +0000 | [diff] [blame] | 911 | The Netfilter Core Team is: Marc Boucher, Jozsef Kadlecsik, James Morris, |
| 912 | Harald Welte and Rusty Russell. |
Hervé Eychenne | 9e51806 | 2002-03-14 09:25:40 +0000 | [diff] [blame^] | 913 | .PP |
| 914 | Man page written by Herve Eychenne <rv@wallfire.org>. |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 915 | .\" .. and did I mention that we are incredibly cool people? |
Rusty Russell | 363112d | 2000-08-11 13:49:26 +0000 | [diff] [blame] | 916 | .\" .. sexy, too .. |
Rusty Russell | 86573e5 | 2000-10-11 06:01:13 +0000 | [diff] [blame] | 917 | .\" .. witty, charming, powerful .. |
James Morris | 060ae4c | 2000-10-29 01:29:57 +0000 | [diff] [blame] | 918 | .\" .. and most of all, modest .. |