Jan Engelhardt | 8d67190 | 2009-01-08 18:03:45 +0100 | [diff] [blame] | 1 | .TH IPTABLES 8 "" "@PACKAGE_AND_VERSION@" "@PACKAGE_AND_VERSION@" |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 2 | .\" |
| 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 | .\" |
| 7 | .\" ipchains page by Paul ``Rusty'' Russell March 1997 |
| 8 | .\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl> |
| 9 | .\" |
| 10 | .\" This program is free software; you can redistribute it and/or modify |
| 11 | .\" it under the terms of the GNU General Public License as published by |
| 12 | .\" the Free Software Foundation; either version 2 of the License, or |
| 13 | .\" (at your option) any later version. |
| 14 | .\" |
| 15 | .\" This program is distributed in the hope that it will be useful, |
| 16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | .\" GNU General Public License for more details. |
| 19 | .\" |
| 20 | .\" You should have received a copy of the GNU General Public License |
| 21 | .\" along with this program; if not, write to the Free Software |
| 22 | .\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | .\" |
| 24 | .\" |
| 25 | .SH NAME |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 26 | iptables - administration tool for IPv4 packet filtering and NAT |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 27 | .SH SYNOPSIS |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 28 | \fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-A\fP|\fB\-D\fP} \fIchain\fP \fIrule-specification\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 29 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 30 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-I\fP [\fIrulenum\fP] \fIrule-specification\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 31 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 32 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-R\fP \fIrulenum rule-specification\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 33 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 34 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-D\fP \fIchain rulenum\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 35 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 36 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-S\fP [\fIchain\fP] |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 37 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 38 | \fBiptables\fP [\fB\-t\fP \fItable\fP] {\fB\-F\fP|\fB\-L\fP|\fB\-Z\fP} [\fIchain\fP] [\fIoptions...\fP] |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 39 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 40 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-N\fP \fIchain\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 41 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 42 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-X\fP [\fIchain\fP] |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 43 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 44 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-P\fP \fIchain target\fP |
Jan Engelhardt | 8a679dc | 2008-10-29 09:48:23 +0100 | [diff] [blame] | 45 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 46 | \fBiptables\fP [\fB\-t\fP \fItable\fP] \fB\-E\fP \fIold-chain-name new-chain-name\fP |
Jan Engelhardt | 6362bc8 | 2008-10-29 09:48:59 +0100 | [diff] [blame] | 47 | .PP |
| 48 | rule-specification = [\fImatches...\fP] [\fItarget\fP] |
| 49 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 50 | match = \fB\-m\fP \fImatchname\fP [\fIper-match-options\fP] |
Jan Engelhardt | 6362bc8 | 2008-10-29 09:48:59 +0100 | [diff] [blame] | 51 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 52 | target = \fB\-j\fP \fItargetname\fP [\fIper\-target\-options\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 53 | .SH DESCRIPTION |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 54 | \fBIptables\fP is used to set up, maintain, and inspect the |
| 55 | tables of IPv4 packet |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 56 | filter rules in the Linux kernel. Several different tables |
| 57 | may be defined. Each table contains a number of built-in |
| 58 | chains and may also contain user-defined chains. |
Jan Engelhardt | 0c2b5a4 | 2009-01-08 18:04:40 +0100 | [diff] [blame] | 59 | .PP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 60 | Each chain is a list of rules which can match a set of packets. Each |
| 61 | rule specifies what to do with a packet that matches. This is called |
| 62 | a `target', which may be a jump to a user-defined chain in the same |
| 63 | table. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 64 | .SH TARGETS |
Jan Engelhardt | 6cf172e | 2008-03-10 17:48:59 +0100 | [diff] [blame] | 65 | A firewall rule specifies criteria for a packet and a target. If the |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 66 | packet does not match, the next rule in the chain is the examined; if |
| 67 | it does match, then the next rule is specified by the value of the |
| 68 | target, which can be the name of a user-defined chain or one of the |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 69 | special values \fBACCEPT\fP, \fBDROP\fP, \fBQUEUE\fP or \fBRETURN\fP. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 70 | .PP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 71 | \fBACCEPT\fP means to let the packet through. |
| 72 | \fBDROP\fP means to drop the packet on the floor. |
| 73 | \fBQUEUE\fP means to pass the packet to userspace. |
| 74 | (How the packet can be received |
Harald Welte | 7bdfca4 | 2005-07-28 15:24:02 +0000 | [diff] [blame] | 75 | by a userspace process differs by the particular queue handler. 2.4.x |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 76 | and 2.6.x kernels up to 2.6.13 include the \fBip_queue\fP |
| 77 | queue handler. Kernels 2.6.14 and later additionally include the |
| 78 | \fBnfnetlink_queue\fP queue handler. Packets with a target of QUEUE will be |
| 79 | sent to queue number '0' in this case. Please also see the \fBNFQUEUE\fP |
Harald Welte | 7bdfca4 | 2005-07-28 15:24:02 +0000 | [diff] [blame] | 80 | target as described later in this man page.) |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 81 | \fBRETURN\fP means stop traversing this chain and resume at the next |
| 82 | rule in the |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 83 | previous (calling) chain. If the end of a built-in chain is reached |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 84 | or a rule in a built-in chain with target \fBRETURN\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 85 | is matched, the target specified by the chain policy determines the |
| 86 | fate of the packet. |
| 87 | .SH TABLES |
| 88 | There are currently three independent tables (which tables are present |
| 89 | at any time depends on the kernel configuration options and which |
| 90 | modules are present). |
| 91 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 92 | \fB\-t\fP, \fB\-\-table\fP \fItable\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 93 | This option specifies the packet matching table which the command |
| 94 | should operate on. If the kernel is configured with automatic module |
| 95 | loading, an attempt will be made to load the appropriate module for |
| 96 | that table if it is not already there. |
| 97 | |
| 98 | The tables are as follows: |
| 99 | .RS |
| 100 | .TP .4i |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 101 | \fBfilter\fP: |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 102 | This is the default table (if no \-t option is passed). It contains |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 103 | the built-in chains \fBINPUT\fP (for packets destined to local sockets), |
| 104 | \fBFORWARD\fP (for packets being routed through the box), and |
| 105 | \fBOUTPUT\fP (for locally-generated packets). |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 106 | .TP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 107 | \fBnat\fP: |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 108 | This table is consulted when a packet that creates a new |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 109 | connection is encountered. It consists of three built-ins: \fBPREROUTING\fP |
| 110 | (for altering packets as soon as they come in), \fBOUTPUT\fP |
| 111 | (for altering locally-generated packets before routing), and \fBPOSTROUTING\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 112 | (for altering packets as they are about to go out). |
| 113 | .TP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 114 | \fBmangle\fP: |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 115 | This table is used for specialized packet alteration. Until kernel |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 116 | 2.4.17 it had two built-in chains: \fBPREROUTING\fP |
| 117 | (for altering incoming packets before routing) and \fBOUTPUT\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 118 | (for altering locally-generated packets before routing). |
| 119 | Since kernel 2.4.18, three other built-in chains are also supported: |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 120 | \fBINPUT\fP (for packets coming into the box itself), \fBFORWARD\fP |
| 121 | (for altering packets being routed through the box), and \fBPOSTROUTING\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 122 | (for altering packets as they are about to go out). |
Harald Welte | a188599 | 2004-10-06 12:32:54 +0000 | [diff] [blame] | 123 | .TP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 124 | \fBraw\fP: |
Harald Welte | a188599 | 2004-10-06 12:32:54 +0000 | [diff] [blame] | 125 | This table is used mainly for configuring exemptions from connection |
| 126 | tracking in combination with the NOTRACK target. It registers at the netfilter |
| 127 | hooks with higher priority and is thus called before ip_conntrack, or any other |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 128 | IP tables. It provides the following built-in chains: \fBPREROUTING\fP |
| 129 | (for packets arriving via any network interface) \fBOUTPUT\fP |
Harald Welte | a188599 | 2004-10-06 12:32:54 +0000 | [diff] [blame] | 130 | (for packets generated by local processes) |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 131 | .RE |
| 132 | .SH OPTIONS |
| 133 | The options that are recognized by |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 134 | \fBiptables\fP can be divided into several different groups. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 135 | .SS COMMANDS |
Jan Engelhardt | 6cf172e | 2008-03-10 17:48:59 +0100 | [diff] [blame] | 136 | These options specify the desired action to perform. Only one of them |
| 137 | can be specified on the command line unless otherwise stated |
| 138 | below. For long versions of the command and option names, you |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 139 | need to use only enough letters to ensure that |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 140 | \fBiptables\fP can differentiate it from all other options. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 141 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 142 | \fB\-A\fP, \fB\-\-append\fP \fIchain rule-specification\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 143 | Append one or more rules to the end of the selected chain. |
| 144 | When the source and/or destination names resolve to more than one |
| 145 | address, a rule will be added for each possible address combination. |
| 146 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 147 | \fB\-D\fP, \fB\-\-delete\fP \fIchain rule-specification\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 148 | .ns |
| 149 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 150 | \fB\-D\fP, \fB\-\-delete\fP \fIchain rulenum\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 151 | Delete one or more rules from the selected chain. There are two |
| 152 | versions of this command: the rule can be specified as a number in the |
| 153 | chain (starting at 1 for the first rule) or a rule to match. |
| 154 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 155 | \fB\-I\fP, \fB\-\-insert\fP \fIchain\fP [\fIrulenum\fP] \fIrule-specification\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 156 | Insert one or more rules in the selected chain as the given rule |
| 157 | number. So, if the rule number is 1, the rule or rules are inserted |
| 158 | at the head of the chain. This is also the default if no rule number |
| 159 | is specified. |
| 160 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 161 | \fB\-R\fP, \fB\-\-replace\fP \fIchain rulenum rule-specification\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 162 | Replace a rule in the selected chain. If the source and/or |
| 163 | destination names resolve to multiple addresses, the command will |
| 164 | fail. Rules are numbered starting at 1. |
| 165 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 166 | \fB\-L\fP, \fB\-\-list\fP [\fIchain\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 167 | List all rules in the selected chain. If no chain is selected, all |
Jan Engelhardt | 6cf172e | 2008-03-10 17:48:59 +0100 | [diff] [blame] | 168 | chains are listed. Like every other iptables command, it applies to the |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 169 | specified table (filter is the default), so NAT rules get listed by |
| 170 | .nf |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 171 | iptables \-t nat \-n \-L |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 172 | .fi |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 173 | Please note that it is often used with the \fB\-n\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 174 | option, in order to avoid long reverse DNS lookups. |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 175 | It is legal to specify the \fB\-Z\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 176 | (zero) option as well, in which case the chain(s) will be atomically |
| 177 | listed and zeroed. The exact output is affected by the other |
| 178 | arguments given. The exact rules are suppressed until you use |
| 179 | .nf |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 180 | iptables \-L \-v |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 181 | .fi |
| 182 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 183 | \fB\-S\fP, \fB\-\-list\-rules\fP [\fIchain\fP] |
Henrik Nordstrom | 96296cf | 2008-05-13 13:08:26 +0200 | [diff] [blame] | 184 | Print all rules in the selected chain. If no chain is selected, all |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 185 | chains are printed like iptables\-save. Like every other iptables command, |
Henrik Nordstrom | 96296cf | 2008-05-13 13:08:26 +0200 | [diff] [blame] | 186 | it applies to the specified table (filter is the default). |
| 187 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 188 | \fB\-F\fP, \fB\-\-flush\fP [\fIchain\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 189 | Flush the selected chain (all the chains in the table if none is given). |
| 190 | This is equivalent to deleting all the rules one by one. |
| 191 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 192 | \fB\-Z\fP, \fB\-\-zero\fP [\fIchain\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 193 | Zero the packet and byte counters in all chains. It is legal to |
| 194 | specify the |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 195 | \fB\-L\fP, \fB\-\-list\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 196 | (list) option as well, to see the counters immediately before they are |
| 197 | cleared. (See above.) |
| 198 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 199 | \fB\-N\fP, \fB\-\-new\-chain\fP \fIchain\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 200 | Create a new user-defined chain by the given name. There must be no |
| 201 | target of that name already. |
| 202 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 203 | \fB\-X\fP, \fB\-\-delete\-chain\fP [\fIchain\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 204 | Delete the optional user-defined chain specified. There must be no references |
Harald Welte | 3a02693 | 2005-11-22 22:22:28 +0000 | [diff] [blame] | 205 | to the chain. If there are, you must delete or replace the referring rules |
| 206 | before the chain can be deleted. The chain must be empty, i.e. not contain |
| 207 | any rules. If no argument is given, it will attempt to delete every |
| 208 | non-builtin chain in the table. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 209 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 210 | \fB\-P\fP, \fB\-\-policy\fP \fIchain target\fP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 211 | Set the policy for the chain to the given target. See the section \fBTARGETS\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 212 | for the legal targets. Only built-in (non-user-defined) chains can have |
| 213 | policies, and neither built-in nor user-defined chains can be policy |
| 214 | targets. |
| 215 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 216 | \fB\-E\fP, \fB\-\-rename\-chain\fP \fIold\-chain new\-chain\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 217 | Rename the user specified chain to the user supplied name. This is |
| 218 | cosmetic, and has no effect on the structure of the table. |
| 219 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 220 | \fB\-\h\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 221 | Help. |
| 222 | Give a (currently very brief) description of the command syntax. |
| 223 | .SS PARAMETERS |
| 224 | The following parameters make up a rule specification (as used in the |
| 225 | add, delete, insert, replace and append commands). |
| 226 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 227 | [\fB!\fP] \fB\-p\fP, \fB\-\-protocol\fP \fIprotocol\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 228 | The protocol of the rule or of the packet to check. |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 229 | The specified protocol can be one of \fBtcp\fP, \fBudp\fP, \fBudplite\fP, |
| 230 | \fBicmp\fP, \fBesp\fP, \fBah\fP, \fBsctp\fP or \fBall\fP, |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 231 | or it can be a numeric value, representing one of these protocols or a |
| 232 | different one. A protocol name from /etc/protocols is also allowed. |
| 233 | A "!" argument before the protocol inverts the |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 234 | test. The number zero is equivalent to \fBall\fP. |
| 235 | Protocol \fBall\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 236 | will match with all protocols and is taken as default when this |
| 237 | option is omitted. |
| 238 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 239 | [\fB!\fP] \fB\-s\fP, \fB\-\-source\fP \fIaddress\fP[\fB/\fP\fImask\fP] |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 240 | Source specification. \fIAddress\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 241 | can be either a network name, a hostname (please note that specifying |
| 242 | any name to be resolved with a remote query such as DNS is a really bad idea), |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 243 | a network IP address (with \fB/\fP\fImask\fP), or a plain IP address. |
| 244 | The \fImask\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 245 | can be either a network mask or a plain number, |
| 246 | specifying the number of 1's at the left side of the network mask. |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 247 | Thus, a mask of \fI24\fP is equivalent to \fI255.255.255.0\fP. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 248 | A "!" argument before the address specification inverts the sense of |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 249 | the address. The flag \fB\-\-src\fP is an alias for this option. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 250 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 251 | [\fB!\fP] \fB\-d\fP, \fB\-\-destination\fP \fIaddress\fP[\fB/\fP\fImask\fP] |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 252 | Destination specification. |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 253 | See the description of the \fB\-s\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 254 | (source) flag for a detailed description of the syntax. The flag |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 255 | \fB\-\-dst\fP is an alias for this option. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 256 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 257 | \fB\-j\fP, \fB\-\-jump\fP \fItarget\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 258 | This specifies the target of the rule; i.e., what to do if the packet |
| 259 | matches it. The target can be a user-defined chain (other than the |
| 260 | one this rule is in), one of the special builtin targets which decide |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 261 | the fate of the packet immediately, or an extension (see \fBEXTENSIONS\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 262 | below). If this |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 263 | option is omitted in a rule (and \fB\-g\fP |
Henrik Nordstrom | 17fc163 | 2005-11-05 09:26:40 +0000 | [diff] [blame] | 264 | is not used), then matching the rule will have no |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 265 | effect on the packet's fate, but the counters on the rule will be |
| 266 | incremented. |
| 267 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 268 | \fB\-g\fP, \fB\-\-goto\fP \fIchain\fP |
Henrik Nordstrom | 17fc163 | 2005-11-05 09:26:40 +0000 | [diff] [blame] | 269 | This specifies that the processing should continue in a user |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 270 | specified chain. Unlike the \-\-jump option return will not continue |
Henrik Nordstrom | 17fc163 | 2005-11-05 09:26:40 +0000 | [diff] [blame] | 271 | processing in this chain but instead in the chain that called us via |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 272 | \-\-jump. |
Henrik Nordstrom | 17fc163 | 2005-11-05 09:26:40 +0000 | [diff] [blame] | 273 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 274 | [\fB!\fP] \fB\-i\fP, \fB\-\-in\-interface\fP \fIname\fP |
Matthew Strait | 403cf6a | 2004-03-17 14:26:08 +0000 | [diff] [blame] | 275 | Name of an interface via which a packet was received (only for |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 276 | packets entering the \fBINPUT\fP, \fBFORWARD\fP and \fBPREROUTING\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 277 | chains). When the "!" argument is used before the interface name, the |
| 278 | sense is inverted. If the interface name ends in a "+", then any |
| 279 | interface which begins with this name will match. If this option is |
| 280 | omitted, any interface name will match. |
| 281 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 282 | [\fB!\fP] \fB\-o\fP, \fB\-\-out\-interface\fP \fIname\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 283 | Name of an interface via which a packet is going to be sent (for packets |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 284 | entering the \fBFORWARD\fP, \fBOUTPUT\fP and \fBPOSTROUTING\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 285 | chains). When the "!" argument is used before the interface name, the |
| 286 | sense is inverted. If the interface name ends in a "+", then any |
| 287 | interface which begins with this name will match. If this option is |
| 288 | omitted, any interface name will match. |
| 289 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 290 | [\fB!\fP] \fB\-f\fP, \fB\-\-fragment\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 291 | This means that the rule only refers to second and further fragments |
| 292 | of fragmented packets. Since there is no way to tell the source or |
| 293 | destination ports of such a packet (or ICMP type), such a packet will |
| 294 | not match any rules which specify them. When the "!" argument |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 295 | precedes the "\-f" flag, the rule will only match head fragments, or |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 296 | unfragmented packets. |
| 297 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 298 | \fB\-c\fP, \fB\-\-set\-counters\fP \fIpackets bytes\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 299 | This enables the administrator to initialize the packet and byte |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 300 | counters of a rule (during \fBINSERT\fP, \fBAPPEND\fP, \fBREPLACE\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 301 | operations). |
| 302 | .SS "OTHER OPTIONS" |
| 303 | The following additional options can be specified: |
| 304 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 305 | \fB\-v\fP, \fB\-\-verbose\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 306 | Verbose output. This option makes the list command show the interface |
| 307 | name, 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 |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 310 | the \fB\-x\fP flag to change this). |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 311 | For appending, insertion, deletion and replacement, this causes |
| 312 | detailed information on the rule or rules to be printed. |
| 313 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 314 | \fB\-n\fP, \fB\-\-numeric\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 315 | Numeric output. |
| 316 | IP addresses and port numbers will be printed in numeric format. |
| 317 | By default, the program will try to display them as host names, |
| 318 | network names, or services (whenever applicable). |
| 319 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 320 | \fB\-x\fP, \fB\-\-exact\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 321 | Expand numbers. |
| 322 | Display the exact value of the packet and byte counters, |
| 323 | instead of only the rounded number in K's (multiples of 1000) |
| 324 | M's (multiples of 1000K) or G's (multiples of 1000M). This option is |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 325 | only relevant for the \fB\-L\fP command. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 326 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 327 | \fB\-\-line\-numbers\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 328 | When listing rules, add line numbers to the beginning of each rule, |
| 329 | corresponding to that rule's position in the chain. |
| 330 | .TP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 331 | \fB\-\-modprobe=\fP\fIcommand\fP |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 332 | When adding or inserting rules into a chain, use \fIcommand\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 333 | to load any necessary modules (targets, match extensions, etc). |
| 334 | .SH MATCH EXTENSIONS |
| 335 | iptables can use extended packet matching modules. These are loaded |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 336 | in two ways: implicitly, when \fB\-p\fP or \fB\-\-protocol\fP |
| 337 | is specified, or with the \fB\-m\fP or \fB\-\-match\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 338 | options, followed by the matching module name; after these, various |
| 339 | extra command line options become available, depending on the specific |
| 340 | module. You can specify multiple extended match modules in one line, |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 341 | and you can use the \fB\-h\fP or \fB\-\-help\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 342 | options after the module has been specified to receive help specific |
| 343 | to that module. |
Jan Engelhardt | 0c2b5a4 | 2009-01-08 18:04:40 +0100 | [diff] [blame] | 344 | .PP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 345 | The following are included in the base package, and most of these can |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 346 | be preceded by a "\fB!\fP" to invert the sense of the match. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 347 | .\" @MATCH@ |
| 348 | .SH TARGET EXTENSIONS |
| 349 | iptables can use extended target modules: the following are included |
| 350 | in the standard distribution. |
| 351 | .\" @TARGET@ |
| 352 | .SH DIAGNOSTICS |
| 353 | Various error messages are printed to standard error. The exit code |
| 354 | is 0 for correct functioning. Errors which appear to be caused by |
| 355 | invalid or abused command line parameters cause an exit code of 2, and |
| 356 | other errors cause an exit code of 1. |
| 357 | .SH BUGS |
| 358 | Bugs? What's this? ;-) |
Harald Welte | 64d900f | 2005-06-24 16:37:00 +0000 | [diff] [blame] | 359 | Well, you might want to have a look at http://bugzilla.netfilter.org/ |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 360 | .SH COMPATIBILITY WITH IPCHAINS |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 361 | This \fBiptables\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 362 | is very similar to ipchains by Rusty Russell. The main difference is |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 363 | that the chains \fBINPUT\fP and \fBOUTPUT\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 364 | are only traversed for packets coming into the local host and |
| 365 | originating from the local host respectively. Hence every packet only |
| 366 | passes through one of the three chains (except loopback traffic, which |
| 367 | involves both INPUT and OUTPUT chains); previously a forwarded packet |
| 368 | would pass through all three. |
| 369 | .PP |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 370 | The other main difference is that \fB\-i\fP refers to the input interface; |
| 371 | \fB\-o\fP refers to the output interface, and both are available for packets |
Jan Engelhardt | 55dffef | 2008-07-03 20:27:50 +0200 | [diff] [blame] | 372 | entering the \fBFORWARD\fP chain. |
| 373 | .PP |
| 374 | The various forms of NAT have been separated out; \fBiptables\fP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 375 | is a pure packet filter when using the default `filter' table, with |
| 376 | optional extension modules. This should simplify much of the previous |
| 377 | confusion over the combination of IP masquerading and packet filtering |
| 378 | seen previously. So the following options are handled differently: |
| 379 | .nf |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 380 | \-j MASQ |
| 381 | \-M \-S |
| 382 | \-M \-L |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 383 | .fi |
| 384 | There are several other changes in iptables. |
| 385 | .SH SEE ALSO |
Jan Engelhardt | 0e8984a | 2009-01-12 07:06:12 +0100 | [diff] [blame] | 386 | \fBiptables\-save\fP(8), |
| 387 | \fBiptables\-restore\fP(8), |
| 388 | \fBip6tables\fP(8), |
| 389 | \fBip6tables\-save\fP(8), |
| 390 | \fBip6tables\-restore\fP(8), |
| 391 | \fBlibipq\fP(3). |
| 392 | .PP |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 393 | The packet-filtering-HOWTO details iptables usage for |
| 394 | packet filtering, the NAT-HOWTO details NAT, |
| 395 | the netfilter-extensions-HOWTO details the extensions that are |
| 396 | not in the standard distribution, |
| 397 | and the netfilter-hacking-HOWTO details the netfilter internals. |
| 398 | .br |
| 399 | See |
| 400 | .BR "http://www.netfilter.org/" . |
| 401 | .SH AUTHORS |
Harald Welte | 7bdfca4 | 2005-07-28 15:24:02 +0000 | [diff] [blame] | 402 | Rusty Russell originally wrote iptables, in early consultation with Michael |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 403 | Neuling. |
| 404 | .PP |
| 405 | Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet |
| 406 | selection framework in iptables, then wrote the mangle table, the owner match, |
| 407 | the mark stuff, and ran around doing cool stuff everywhere. |
| 408 | .PP |
| 409 | James Morris wrote the TOS target, and tos match. |
| 410 | .PP |
| 411 | Jozsef Kadlecsik wrote the REJECT target. |
| 412 | .PP |
Harald Welte | 7bdfca4 | 2005-07-28 15:24:02 +0000 | [diff] [blame] | 413 | Harald Welte wrote the ULOG and NFQUEUE target, the new libiptc, as well as the TTL, DSCP, ECN matches and targets. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 414 | .PP |
Patrick McHardy | 110a89a | 2007-01-28 01:24:55 +0000 | [diff] [blame] | 415 | The Netfilter Core Team is: Marc Boucher, Martin Josefsson, Yasuyuki Kozakai, |
Yasuyuki KOZAKAI | e605d76 | 2007-02-15 06:41:58 +0000 | [diff] [blame] | 416 | Jozsef Kadlecsik, Patrick McHardy, James Morris, Pablo Neira Ayuso, |
| 417 | Harald Welte and Rusty Russell. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 418 | .PP |
Harald Welte | 7bdfca4 | 2005-07-28 15:24:02 +0000 | [diff] [blame] | 419 | Man page originally written by Herve Eychenne <rv@wallfire.org>. |
Henrik Nordstrom | c279413 | 2004-01-22 15:04:24 +0000 | [diff] [blame] | 420 | .\" .. and did I mention that we are incredibly cool people? |
| 421 | .\" .. sexy, too .. |
| 422 | .\" .. witty, charming, powerful .. |
| 423 | .\" .. and most of all, modest .. |