blob: 08cb8a7f01442fc7e55a509161b56b9f519a3526 [file] [log] [blame]
Rusty Russell363112d2000-08-11 13:49:26 +00001.TH IPTABLES 8 "Aug 11, 2000" "" ""
Marc Bouchere6869a82000-03-20 06:03:29 +00002.\"
3.\" Man page written by Herve Eychenne <eychenne@info.enserb.u-bordeaux.fr>
4.\" It is based on ipchains man page.
5.\"
6.\" ipchains page by Paul ``Rusty'' Russell March 1997
7.\" Based on the original ipfwadm man page by Jos Vos <jos@xos.nl> (see README)
8.\"
9.\" This program is free software; you can redistribute it and/or modify
10.\" it under the terms of the GNU General Public License as published by
11.\" the Free Software Foundation; either version 2 of the License, or
12.\" (at your option) any later version.
13.\"
14.\" This program is distributed in the hope that it will be useful,
15.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.\" GNU General Public License for more details.
18.\"
19.\" You should have received a copy of the GNU General Public License
20.\" along with this program; if not, write to the Free Software
21.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22.\"
23.\"
24.SH NAME
25iptables \- IP packet filter administration
26.SH SYNOPSIS
27.BR "iptables -[ADC] " "chain rule-specification [options]"
28.br
29.BR "iptables -[RI] " "chain rulenum rule-specification [options]"
30.br
31.BR "iptables -D " "chain rulenum [options]"
32.br
33.BR "iptables -[LFZ] " "[chain] [options]"
34.br
35.BR "iptables -[NX] " "chain"
36.br
37.BR "iptables -P " "chain target [options]"
38.br
39.BR "iptables -E " "old-chain-name new-chain-name"
40.SH DESCRIPTION
41.B Iptables
42is used to set up, maintain, and inspect the tables of IP packet
Harald Welte0112abb2001-02-19 21:48:13 +000043filter rules in the Linux kernel. Several different tables
44may be defined. Each table contains a number of built-in
45chains and may also contain user-defined chains.
Marc Bouchere6869a82000-03-20 06:03:29 +000046
Harald Welte0112abb2001-02-19 21:48:13 +000047Each chain is a list of rules which can match a set of packets. Each
48rule specifies what to do with a packet that matches. This is called
Marc Bouchere6869a82000-03-20 06:03:29 +000049a `target', which may be a jump to a user-defined chain in the same
50table.
51
52.SH TARGETS
53A firewall rule specifies criteria for a packet, and a target. If the
54packet does not match, the next rule in the chain is the examined; if
55it does match, then the next rule is specified by the value of the
Harald Welte0112abb2001-02-19 21:48:13 +000056target, which can be the name of a user-defined chain or one of the
Marc Bouchere6869a82000-03-20 06:03:29 +000057special values
58.IR ACCEPT ,
59.IR DROP ,
60.IR QUEUE ,
61or
62.IR RETURN .
63.PP
64.I ACCEPT
65means to let the packet through.
66.I DROP
67means to drop the packet on the floor.
68.I QUEUE
Rusty Russell363112d2000-08-11 13:49:26 +000069means to pass the packet to userspace (if supported by the kernel).
Marc Bouchere6869a82000-03-20 06:03:29 +000070.I RETURN
Harald Welte0112abb2001-02-19 21:48:13 +000071means stop traversing this chain and resume at the next rule in the
72previous (calling) chain. If the end of a built-in chain is reached
Marc Bouchere6869a82000-03-20 06:03:29 +000073or a rule in a built-in chain with target
74.I RETURN
75is matched, the target specified by the chain policy determines the
76fate of the packet.
77.SH TABLES
Rusty Russell363112d2000-08-11 13:49:26 +000078There are current three independent tables (which tables are present
79at any time depends on the kernel configuration options and which
80modules are present).
Marc Bouchere6869a82000-03-20 06:03:29 +000081.TP
82.B "-t, --table"
83This option specifies the packet matching table which the command
84should operate on. If the kernel is configured with automatic module
85loading, an attempt will be made to load the appropriate module for
86that table if it is not already there.
87
88The tables are as follows:
Harald Welte87d4be42001-07-05 06:26:37 +000089.TP
Marc Bouchere6869a82000-03-20 06:03:29 +000090.BR "filter"
Harald Welte0112abb2001-02-19 21:48:13 +000091This is the default table. It contains the built-in chains INPUT (for
Marc Bouchere6869a82000-03-20 06:03:29 +000092packets coming into the box itself), FORWARD (for packets being routed
93through the box), and OUTPUT (for locally-generated packets).
Harald Welte87d4be42001-07-05 06:26:37 +000094.TP
Marc Bouchere6869a82000-03-20 06:03:29 +000095.BR "nat"
Harald Welte0112abb2001-02-19 21:48:13 +000096This table is consulted when a packet that creates a new
Marc Bouchere6869a82000-03-20 06:03:29 +000097connection is encountered. It consists of three built-ins: PREROUTING
98(for altering packets as soon as they come in), OUTPUT (for altering
99locally-generated packets before routing), and POSTROUTING (for
100altering packets as they are about to go out).
Harald Welte87d4be42001-07-05 06:26:37 +0000101.TP
Marc Bouchere6869a82000-03-20 06:03:29 +0000102.BR "mangle"
103This table is used for specialized packet alteration. It has two
104built-in chains: PREROUTING (for altering incoming packets before
105routing) and OUTPUT (for altering locally-generated packets before
106routing).
107.SH OPTIONS
108The options that are recognized by
109.B iptables
110can be divided into several different groups.
111.SS COMMANDS
Harald Welte0112abb2001-02-19 21:48:13 +0000112These options specify the specific action to perform. Only one of them
113can be specified on the command line unless otherwise specified
Marc Bouchere6869a82000-03-20 06:03:29 +0000114below. For all the long versions of the command and option names, you
Harald Welte0112abb2001-02-19 21:48:13 +0000115need to use only enough letters to ensure that
Marc Bouchere6869a82000-03-20 06:03:29 +0000116.B iptables
117can differentiate it from all other options.
118.TP
119.BR "-A, --append"
120Append one or more rules to the end of the selected chain.
121When the source and/or destination names resolve to more than one
122address, a rule will be added for each possible address combination.
123.TP
124.BR "-D, --delete"
125Delete one or more rules from the selected chain. There are two
126versions of this command: the rule can be specified as a number in the
127chain (starting at 1 for the first rule) or a rule to match.
128.TP
129.B "-R, --replace"
130Replace a rule in the selected chain. If the source and/or
131destination names resolve to multiple addresses, the command will
132fail. Rules are numbered starting at 1.
133.TP
134.B "-I, --insert"
135Insert one or more rules in the selected chain as the given rule
136number. So, if the rule number is 1, the rule or rules are inserted
137at the head of the chain. This is also the default if no rule number
138is specified.
139.TP
140.B "-L, --list"
141List all rules in the selected chain. If no chain is selected, all
142chains are listed. It is legal to specify the
143.B -Z
144(zero) option as well, in which case the chain(s) will be atomically
Harald Welte0112abb2001-02-19 21:48:13 +0000145listed and zeroed. The exact output is affected by the other
Marc Bouchere6869a82000-03-20 06:03:29 +0000146arguments given.
147.TP
148.B "-F, --flush"
149Flush the selected chain. This is equivalent to deleting all the
150rules one by one.
151.TP
152.B "-Z, --zero"
153Zero the packet and byte counters in all chains. It is legal to
154specify the
155.B "-L, --list"
156(list) option as well, to see the counters immediately before they are
Harald Welte0112abb2001-02-19 21:48:13 +0000157cleared. (See above.)
Marc Bouchere6869a82000-03-20 06:03:29 +0000158.TP
159.B "-N, --new-chain"
Harald Welte0112abb2001-02-19 21:48:13 +0000160Create a new user-defined chain by the given name. There must be no
Marc Bouchere6869a82000-03-20 06:03:29 +0000161target of that name already.
162.TP
163.B "-X, --delete-chain"
164Delete the specified user-defined chain. There must be no references
Harald Welte0112abb2001-02-19 21:48:13 +0000165to the chain. If there are, you must delete or replace the referring
166rules before the chain can be deleted. If no argument is given, it
Rusty Russell363112d2000-08-11 13:49:26 +0000167will attempt to delete every non-builtin chain in the table.
Marc Bouchere6869a82000-03-20 06:03:29 +0000168.TP
169.B "-P, --policy"
170Set the policy for the chain to the given target. See the section
Rusty Russell363112d2000-08-11 13:49:26 +0000171.B TARGETS
Rusty Russell86573e52000-10-11 06:01:13 +0000172for the legal targets. Only non-user-defined chains can have policies,
Rusty Russell363112d2000-08-11 13:49:26 +0000173and neither built-in nor user-defined chains can be policy targets.
Marc Bouchere6869a82000-03-20 06:03:29 +0000174.TP
175.B "-E, --rename-chain"
Harald Welte0112abb2001-02-19 21:48:13 +0000176Rename the user specified chain to the user supplied name. This is
Marc Bouchere6869a82000-03-20 06:03:29 +0000177cosmetic, and has no effect on the structure of the table.
Marc Bouchere6869a82000-03-20 06:03:29 +0000178.TP
179.B -h
180Help.
181Give a (currently very brief) description of the command syntax.
182.SS PARAMETERS
183The following parameters make up a rule specification (as used in the
Harald Welte0112abb2001-02-19 21:48:13 +0000184add, delete, insert, replace and append commands).
Marc Bouchere6869a82000-03-20 06:03:29 +0000185.TP
Rusty Russell2e0a3212000-04-19 11:23:18 +0000186.BR "-p, --protocol " "[!] \fIprotocol\fP"
Marc Bouchere6869a82000-03-20 06:03:29 +0000187The protocol of the rule or of the packet to check.
188The specified protocol can be one of
189.IR tcp ,
190.IR udp ,
191.IR icmp ,
192or
193.IR all ,
194or it can be a numeric value, representing one of these protocols or a
Rusty Russell363112d2000-08-11 13:49:26 +0000195different one. A protocol name from /etc/protocols is also allowed.
Marc Bouchere6869a82000-03-20 06:03:29 +0000196A "!" argument before the protocol inverts the
197test. The number zero is equivalent to
198.IR all .
199Protocol
200.I all
201will match with all protocols and is taken as default when this
202option is omitted.
Marc Bouchere6869a82000-03-20 06:03:29 +0000203.TP
204.BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
205Source specification.
206.I Address
207can be either a hostname, a network name, or a plain IP address.
208The
209.I mask
210can be either a network mask or a plain number,
211specifying the number of 1's at the left side of the network mask.
212Thus, a mask of
213.I 24
214is equivalent to
215.IR 255.255.255.0 .
216A "!" argument before the address specification inverts the sense of
217the address. The flag
218.B --src
219is a convenient alias for this option.
220.TP
221.BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
222Destination specification.
223See the description of the
224.B -s
225(source) flag for a detailed description of the syntax. The flag
226.B --dst
227is an alias for this option.
228.TP
229.BI "-j, --jump " "target"
Harald Welte0112abb2001-02-19 21:48:13 +0000230This specifies the target of the rule; i.e., what to do if the packet
231matches it. The target can be a user-defined chain (other than the
232one this rule is in), one of the special builtin targets which decide
233the fate of the packet immediately, or an extension (see
Marc Bouchere6869a82000-03-20 06:03:29 +0000234.B EXTENSIONS
235below). If this
236option is omitted in a rule, then matching the rule will have no
237effect on the packet's fate, but the counters on the rule will be
238incremented.
239.TP
240.BR "-i, --in-interface " "[!] [\fIname\fP]"
241Optional name of an interface via which a packet is received (for
242packets entering the
243.BR INPUT ,
244.B FORWARD
245and
246.B PREROUTING
247chains). When the "!" argument is used before the interface name, the
248sense is inverted. If the interface name ends in a "+", then any
249interface which begins with this name will match. If this option is
250omitted, the string "+" is assumed, which will match with any
251interface name.
252.TP
253.BR "-o, --out-interface " "[!] [\fIname\fP]"
254Optional name of an interface via which a packet is going to
255be sent (for packets entering the
256.BR FORWARD ,
257.B OUTPUT
258and
259.B POSTROUTING
260chains). When the "!" argument is used before the interface name,
261the sense is inverted. If the interface name ends in a "+", then any
262interface which begins with this name will match. If this option is
263omitted, the string "+" is assumed, which will match with any
264interface name.
265.TP
266.B "[!] " "-f, --fragment"
267This means that the rule only refers to second and further fragments
268of fragmented packets. Since there is no way to tell the source or
269destination ports of such a packet (or ICMP type), such a packet will
270not match any rules which specify them. When the "!" argument
Rusty Russell363112d2000-08-11 13:49:26 +0000271precedes the "-f" flag, the rule will only match head fragments, or
272unfragmented packets.
Harald Welteccd49e52001-01-23 22:54:34 +0000273.TP
274.B "-c, --set-counters " "PKTS BYTES"
275This enables the administrater to initialize the packet and byte
276counters of a rule (during
277.B INSERT,
278.B APPEND,
279.B REPLACE
280operations)
Marc Bouchere6869a82000-03-20 06:03:29 +0000281.SS "OTHER OPTIONS"
282The following additional options can be specified:
283.TP
284.B "-v, --verbose"
285Verbose output. This option makes the list command show the interface
286address, the rule options (if any), and the TOS masks. The packet and
287byte counters are also listed, with the suffix 'K', 'M' or 'G' for
2881000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
289the
290.B -x
291flag to change this).
292For appending, insertion, deletion and replacement, this causes
293detailed information on the rule or rules to be printed.
294.TP
295.B "-n, --numeric"
296Numeric output.
297IP addresses and port numbers will be printed in numeric format.
298By default, the program will try to display them as host names,
299network names, or services (whenever applicable).
300.TP
301.B "-x, --exact"
302Expand numbers.
303Display the exact value of the packet and byte counters,
304instead of only the rounded number in K's (multiples of 1000)
305M's (multiples of 1000K) or G's (multiples of 1000M). This option is
Marc Boucherf127a192000-03-20 08:32:15 +0000306only relevant for the
Marc Bouchere6869a82000-03-20 06:03:29 +0000307.B -L
308command.
309.TP
310.B "--line-numbers"
311When listing rules, add line numbers to the beginning of each rule,
312corresponding to that rule's position in the chain.
Chapman Brad45493a82001-02-23 09:08:13 +0000313.TP
314.B "--modprobe=<command>"
315When adding or inserting rules into a chain, use
316.B command
317to load any necessary modules (targets, match extensions, etc).
Marc Bouchere6869a82000-03-20 06:03:29 +0000318.SH MATCH EXTENSIONS
Rusty Russell363112d2000-08-11 13:49:26 +0000319iptables can use extended packet matching modules. These are loaded
320in two ways: implicitly, when
321.B -p
322or
323.B --protocol
324is specified, or with the
325.B -m
326or
327.B --match
328options, followed by the matching module name; after these, various
329extra command line options become available, depending on the specific
330module. You can specify multiple extended match modules in one line, and you can use the
331.B -h
332or
333.B --help
334options after the module has been specified to receive help specific
335to that module.
336
337The following are included in the base package, and most of these can
338be preceded by a
Marc Bouchere6869a82000-03-20 06:03:29 +0000339.B !
340to invert the sense of the match.
341.SS tcp
Rusty Russell363112d2000-08-11 13:49:26 +0000342These extensions are loaded if `--protocol tcp' is specified. It
343provides the following options:
Marc Bouchere6869a82000-03-20 06:03:29 +0000344.TP
James Morris59e90fd2000-06-23 16:44:47 +0000345.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000346Source port or port range specification. This can either be a service
347name or a port number. An inclusive range can also be specified,
348using the format
James Morris59e90fd2000-06-23 16:44:47 +0000349.IR port : port .
Marc Bouchere6869a82000-03-20 06:03:29 +0000350If the first port is omitted, "0" is assumed; if the last is omitted,
351"65535" is assumed.
352If the second port greater then the first they will be swapped.
353The flag
354.B --sport
355is an alias for this option.
356.TP
James Morris59e90fd2000-06-23 16:44:47 +0000357.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000358Destination port or port range specification. The flag
359.B --dport
360is an alias for this option.
361.TP
362.BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
363Match when the TCP flags are as specified. The first argument is the
364flags which we should examine, written as a comma-separated list, and
365the second argument is a comma-separated list of flags which must be
366set. Flags are:
367.BR "SYN ACK FIN RST URG PSH ALL NONE" .
368Hence the command
369.br
Marc Boucherf127a192000-03-20 08:32:15 +0000370 iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
Marc Bouchere6869a82000-03-20 06:03:29 +0000371.br
372will only match packets with the SYN flag set, and the ACK, FIN and
373RST flags unset.
374.TP
375.B "[!] --syn"
376Only match TCP packets with the SYN bit set and the ACK and FIN bits
377cleared. Such packets are used to request TCP connection initiation;
378for example, blocking such packets coming in an interface will prevent
379incoming TCP connections, but outgoing TCP connections will be
380unaffected.
381It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP.
382If the "!" flag precedes the "--syn", the sense of the
383option is inverted.
384.TP
385.BR "--tcp-option " "[!] \fInumber\fP"
386Match if TCP option set.
387.SS udp
Rusty Russell363112d2000-08-11 13:49:26 +0000388These extensions are loaded if `--protocol udp' is specified. It
389provides the following options:
Marc Bouchere6869a82000-03-20 06:03:29 +0000390.TP
James Morris59e90fd2000-06-23 16:44:47 +0000391.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000392Source port or port range specification.
393See the description of the
394.B --source-port
395option of the TCP extension for details.
396.TP
James Morris59e90fd2000-06-23 16:44:47 +0000397.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000398Destination port or port range specification.
399See the description of the
400.B --destination-port
401option of the TCP extension for details.
402.SS icmp
Rusty Russell363112d2000-08-11 13:49:26 +0000403This extension is loaded if `--protocol icmp' is specified. It
404provides the following option:
Marc Bouchere6869a82000-03-20 06:03:29 +0000405.TP
406.BR "--icmp-type " "[!] \fItypename\fP"
407This allows specification of the ICMP type, which can be a numeric
408ICMP type, or one of the ICMP type names shown by the command
409.br
410 iptables -p icmp -h
411.br
412.SS mac
413.TP
414.BR "--mac-source " "[!] \fIaddress\fP"
415Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX.
416Note that this only makes sense for packets entering the
417.BR PREROUTING ,
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000418.B FORWARD
Marc Bouchere6869a82000-03-20 06:03:29 +0000419or
420.B INPUT
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000421chains for packets coming from an ethernet device.
Marc Bouchere6869a82000-03-20 06:03:29 +0000422.SS limit
423This module matches at a limited rate using a token bucket filter: it
Rusty Russell363112d2000-08-11 13:49:26 +0000424can be used in combination with the
425.B LOG
426target to give limited logging. A rule using this extension will
427match until this limit is reached (unless the `!' flag is used).
Marc Bouchere6869a82000-03-20 06:03:29 +0000428.TP
429.BI "--limit " "rate"
430Maximum average matching rate: specified as a number, with an optional
431`/second', `/minute', `/hour', or `/day' suffix; the default is
4323/hour.
433.TP
434.BI "--limit-burst " "number"
435The maximum initial number of packets to match: this number gets
436recharged by one every time the limit specified above is not reached,
437up to this number; the default is 5.
438.SS multiport
439This module matches a set of source or destination ports. Up to 15
440ports can be specified. It can only be used in conjunction with
441.B "-p tcp"
442or
443.BR "-p udp" .
444.TP
445.BR "--source-port" " [\fIport[,port]\fP]"
446Match if the source port is one of the given ports.
447.TP
448.BR "--destination-port" " [\fIport[,port]\fP]"
449Match if the destination port is one of the given ports.
450.TP
451.BR "--port" " [\fIport[,port]\fP]"
452Match if the both the source and destination ports are equal to each
453other and to one of the given ports.
454.SS mark
455This module matches the netfilter mark field associated with a packet
456(which can be set using the
457.B MARK
458target below).
459.TP
460.BI "--mark " "value[/mask]"
461Matches packets with the given unsigned mark value (if a mask is
Harald Welte87d4be42001-07-05 06:26:37 +0000462specified, this is logically ANDed with the mask before the
Marc Bouchere6869a82000-03-20 06:03:29 +0000463comparison).
464.SS owner
465This module attempts to match various characteristics of the packet
466creator, for locally-generated packets. It is only valid in the
Rusty Russell363112d2000-08-11 13:49:26 +0000467.B OUTPUT
468chain, and even this some packets (such as ICMP ping responses) may
469have no owner, and hence never match.
Marc Bouchere6869a82000-03-20 06:03:29 +0000470.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000471.BI "--uid-owner " "userid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000472Matches if the packet was created by a process with the given
473effective user id.
474.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000475.BI "--gid-owner " "groupid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000476Matches if the packet was created by a process with the given
477effective group id.
478.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000479.BI "--pid-owner " "processid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000480Matches if the packet was created by a process with the given
481process id.
482.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000483.BI "--sid-owner " "sessionid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000484Matches if the packet was created by a process in the given session
485group.
486.SS state
487This module, when combined with connection tracking, allows access to
488the connection tracking state for this packet.
489.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000490.BI "--state " "state"
Marc Bouchere6869a82000-03-20 06:03:29 +0000491Where state is a comma separated list of the connection states to
492match. Possible states are
493.B INVALID
494meaning that the packet is associated with no known connection,
495.B ESTABLISHED
496meaning that the packet is associated with a connection which has seen
497packets in both directions,
498.B NEW
499meaning that the packet has started a new connection, or otherwise
500associated with a connection which has not seen packets in both
501directions, and
502.B RELATED
503meaning that the packet is starting a new connection, but is
504associated with an existing connection, such as an FTP data transfer,
505or an ICMP error.
506.SS unclean
507This module takes no options, but attempts to match packets which seem
508malformed or unusual. This is regarded as experimental.
509.SS tos
510This module matches the 8 bits of Type of Service field in the IP
511header (ie. including the precedence bits).
512.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000513.BI "--tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000514The argument is either a standard name, (use
515.br
516 iptables -m tos -h
517.br
518to see the list), or a numeric value to match.
519.SH TARGET EXTENSIONS
520iptables can use extended target modules: the following are included
521in the standard distribution.
522.SS LOG
523Turn on kernel logging of matching packets. When this option is set
524for a rule, the Linux kernel will print some information on all
Rusty Russell363112d2000-08-11 13:49:26 +0000525matching packets (like most IP header fields) via the kernel log
526(where it can be read with
527.I dmesg
528or
529.IR syslogd (8)).
Marc Bouchere6869a82000-03-20 06:03:29 +0000530.TP
531.BI "--log-level " "level"
532Level of logging (numeric or see \fIsyslog.conf\fP(5)).
533.TP
534.BI "--log-prefix " "prefix"
Rusty Russellf81427e2000-09-13 04:20:38 +0000535Prefix log messages with the specified prefix; up to 29 letters long,
Marc Bouchere6869a82000-03-20 06:03:29 +0000536and useful for distinguishing messages in the logs.
537.TP
538.B --log-tcp-sequence
539Log TCP sequence numbers. This is a security risk if the log is
540readable by users.
541.TP
542.B --log-tcp-options
543Log options from the TCP packet header.
544.TP
545.B --log-ip-options
546Log options from the IP packet header.
547.SS MARK
548This is used to set the netfilter mark value associated with the
549packet. It is only valid in the
550.B mangle
551table.
552.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000553.BI "--set-mark " "mark"
Marc Bouchere6869a82000-03-20 06:03:29 +0000554.SS REJECT
555This is used to send back an error packet in response to the matched
556packet: otherwise it is equivalent to
557.BR DROP .
558This target is only valid in the
559.BR INPUT ,
560.B FORWARD
561and
562.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000563chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000564chains. Several options control the nature of the error packet
565returned:
566.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000567.BI "--reject-with " "type"
Marc Bouchere6869a82000-03-20 06:03:29 +0000568The type given can be
569.BR icmp-net-unreachable ,
570.BR icmp-host-unreachable ,
Rusty Russell14f390f2000-07-30 01:10:04 +0000571.BR icmp-port-unreachable ,
572.BR icmp-proto-unreachable ,
573.BR icmp-net-prohibited or
574.BR icmp-host-prohibited ,
Rusty Russellddd5b3b2000-05-31 06:32:47 +0000575which return the appropriate ICMP error message (port-unreachable is
Rusty Russella1ce9f92000-03-24 08:39:16 +0000576the default). The option
Marc Bouchere6869a82000-03-20 06:03:29 +0000577.B echo-reply
Rusty Russella1ce9f92000-03-24 08:39:16 +0000578is also allowed; it can only be used for rules which specify an ICMP
Rusty Russell14f390f2000-07-30 01:10:04 +0000579ping packet, and generates a ping reply. Finally, the option
580.B tcp-reset
Rusty Russell363112d2000-08-11 13:49:26 +0000581can be used on rules which only match the TCP protocol: this causes a
582TCP RST packet to be sent back. This is mainly useful for blocking
583.I ident
584probes which frequently occur when sending mail to broken mail hosts
585(which won't accept your mail otherwise).
Marc Bouchere6869a82000-03-20 06:03:29 +0000586.SS TOS
587This is used to set the 8-bit Type of Service field in the IP header.
588It is only valid in the
589.B mangle
590table.
591.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000592.BI "--set-tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000593You can use a numeric TOS values, or use
594.br
595 iptables -j TOS -h
596.br
597to see the list of valid TOS names.
598.SS MIRROR
599This is an experimental demonstration target which inverts the source
600and destination fields in the IP header and retransmits the packet.
601It is only valid in the
602.BR INPUT ,
603.B FORWARD
604and
Rusty Russell363112d2000-08-11 13:49:26 +0000605.B PREROUTING
606chains, and user-defined chains which are only called from those
607chains. Note that the outgoing packets are
608.B NOT
609seen by any packet filtering chains, connection tracking or NAT, to
610avoid loops and other problems.
Marc Bouchere6869a82000-03-20 06:03:29 +0000611.SS SNAT
612This target is only valid in the
613.B nat
614table, in the
615.B POSTROUTING
616chain. It specifies that the source address of the packet should be
617modified (and all future packets in this connection will also be
618mangled), and rules should cease being examined. It takes one option:
619.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000620.BI "--to-source " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000621which can specify a single new source IP address, an inclusive range
622of IP addresses, and optionally, a port range (which is only valid if
623the rule also specifies
624.B "-p tcp"
625or
626.BR "-p udp" ).
627If no port range is specified, then source ports below 512 will be
Harald Welte0112abb2001-02-19 21:48:13 +0000628mapped to other ports below 512: those between 512 and 1023 inclusive
629will be mapped to ports below 1024, and other ports will be mapped to
6301024 or above. Where possible, no port alteration will occur.
Marc Bouchere6869a82000-03-20 06:03:29 +0000631.SS DNAT
632This target is only valid in the
633.B nat
634table, in the
635.B PREROUTING
636and
637.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000638chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000639chains. It specifies that the destination address of the packet
640should be modified (and all future packets in this connection will
641also be mangled), and rules should cease being examined. It takes one
642option:
643.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000644.BI "--to-destination " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000645which can specify a single new destination IP address, an inclusive
646range of IP addresses, and optionally, a port range (which is only
647valid if the rule also specifies
648.B "-p tcp"
649or
650.BR "-p udp" ).
651If no port range is specified, then the destination port will never be
652modified.
653.SS MASQUERADE
654This target is only valid in the
655.B nat
656table, in the
657.B POSTROUTING
658chain. It should only be used with dynamically assigned IP (dialup)
659connections: if you have a static IP address, you should use the SNAT
660target. Masquerading is equivalent to specifying a mapping to the IP
661address of the interface the packet is going out, but also has the
662effect that connections are
663.I forgotten
Marc Boucherf127a192000-03-20 08:32:15 +0000664when the interface goes down. This is the correct behavior when the
Marc Bouchere6869a82000-03-20 06:03:29 +0000665next dialup is unlikely to have the same interface address (and hence
666any established connections are lost anyway). It takes one option:
667.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000668.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000669This specifies a range of source ports to use, overriding the default
670.B SNAT
671source port-selection heuristics (see above). This is only valid with
672if the rule also specifies
673.B "-p tcp"
674or
675.BR "-p udp" ).
676.SS REDIRECT
677This target is only valid in the
678.B nat
679table, in the
680.B PREROUTING
681and
682.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000683chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000684chains. It alters the destination IP address to send the packet to
685the machine itself (locally-generated packets are mapped to the
Rusty Russell9cadb432000-05-10 00:18:06 +0000686127.0.0.1 address). It takes one option:
Marc Bouchere6869a82000-03-20 06:03:29 +0000687.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000688.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000689This specifies a destination port or range or ports to use: without
690this, the destination port is never altered. This is only valid with
691if the rule also specifies
692.B "-p tcp"
693or
694.BR "-p udp" ).
Rusty Russell86573e52000-10-11 06:01:13 +0000695.SH EXTRA EXTENSIONS
696The following extensions are not included by default in the standard
697distribution.
698.SS ttl
699This module matches the time to live field in the IP header.
700.TP
701.BI "--ttl " "ttl"
702Matches the given TTL value.
703.SS TTL
704This target is used to modify the time to live field in the IP header.
705It is only valid in the
706.B mangle
707table.
708.TP
709.BI "--ttl-set " "ttl"
710Set the TTL to the given value.
711.TP
712.BI "--ttl-dec " "ttl"
713Decrement the TTL by the given value.
714.TP
715.BI "--ttl-inc " "ttl"
716Increment the TTL by the given value.
Rusty Russell52451822000-08-27 07:47:46 +0000717.SS ULOG
Rusty Russell86573e52000-10-11 06:01:13 +0000718This target provides userspace logging of matching packets. When this
719target is set for a rule, the Linux kernel will multicast this packet
720through a
Rusty Russell52451822000-08-27 07:47:46 +0000721.IR netlink
Rusty Russell86573e52000-10-11 06:01:13 +0000722socket. One or more userspace processes may then subscribe to various
Rusty Russell52451822000-08-27 07:47:46 +0000723multicast groups and receive the packets.
724.TP
Harald Welte02d00ff2001-01-30 12:05:09 +0000725.BI "--ulog-nlgroup " "<nlgroup>"
Rusty Russell52451822000-08-27 07:47:46 +0000726This specifies the netlink group (1-32) to which the packet is sent.
Harald Welte02d00ff2001-01-30 12:05:09 +0000727Default value is 1.
Rusty Russell52451822000-08-27 07:47:46 +0000728.TP
Harald Welte02d00ff2001-01-30 12:05:09 +0000729.BI "--ulog-prefix " "<prefix>"
Rusty Russell52451822000-08-27 07:47:46 +0000730Prefix log messages with the specified prefix; up to 32 characters
731long, and useful fro distinguishing messages in the logs.
732.TP
Harald Welte02d00ff2001-01-30 12:05:09 +0000733.BI "--ulog-cprange " "<size>"
Rusty Russell86573e52000-10-11 06:01:13 +0000734Number of bytes to be copied to userspace. A value of 0 always copies
Harald Welte02d00ff2001-01-30 12:05:09 +0000735the entire packet, regardless of its size. Default is 0
736.TP
737.BI "--ulog-qthreshold " "<size>"
738Number of packet to queue inside kernel. Setting this value to, e.g. 10
739accumulates ten packets inside the kernel and transmits them as one
740netlink multpart message to userspace. Default is 1 (for backwards
741compatibility)
Rusty Russell86573e52000-10-11 06:01:13 +0000742.SH DIAGNOSTICS
743Various error messages are printed to standard error. The exit code
744is 0 for correct functioning. Errors which appear to be caused by
745invalid or abused command line parameters cause an exit code of 2, and
746other errors cause an exit code of 1.
Marc Bouchere6869a82000-03-20 06:03:29 +0000747.SH BUGS
748Check is not implemented (yet).
749.SH COMPATIBILITY WITH IPCHAINS
750This
751.B iptables
752is very similar to ipchains by Rusty Russell. The main difference is
753that the chains
754.B INPUT
755and
756.B OUTPUT
757are only traversed for packets coming into the local host and
758originating from the local host respectively. Hence every packet only
759passes through one of the three chains; previously a forwarded packet
760would pass through all three.
761.PP
762The other main difference is that
763.B -i
764refers to the input interface;
765.B -o
766refers to the output interface, and both are available for packets
767entering the
768.B FORWARD
769chain.
770.PP The various forms of NAT have been separated out;
771.B iptables
772is a pure packet filter when using the default `filter' table, with
773optional extension modules. This should simplify much of the previous
774confusion over the combination of IP masquerading and packet filtering
775seen previously. So the following options are handled differently:
776.br
777 -j MASQ
778.br
779 -M -S
780.br
781 -M -L
782.br
783There are several other changes in iptables.
784.SH SEE ALSO
Rusty Russell363112d2000-08-11 13:49:26 +0000785The iptables-HOWTO, which details more iptables usage, the NAT-HOWTO,
786which details NAT, and the netfilter-hacking-HOWTO which details the
787internals.
Marc Boucherf127a192000-03-20 08:32:15 +0000788.SH AUTHORS
Marc Bouchere6869a82000-03-20 06:03:29 +0000789Rusty Russell wrote iptables, in early consultation with Michael
790Neuling.
791.PP
Marc Boucherf127a192000-03-20 08:32:15 +0000792Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
793selection framework in iptables, then wrote the mangle table, the owner match,
794the mark stuff, and ran around doing cool stuff everywhere.
Marc Bouchere6869a82000-03-20 06:03:29 +0000795.PP
796James Morris wrote the TOS target, and tos match.
797.PP
798Jozsef Kadlecsik wrote the REJECT target.
799.PP
Rusty Russell86573e52000-10-11 06:01:13 +0000800Harald Welte wrote the ULOG target, TTL match+target and libipulog.
Rusty Russell52451822000-08-27 07:47:46 +0000801.PP
Rusty Russellf61bb5f2000-10-13 07:11:24 +0000802The Netfilter Core Team is: Marc Boucher, James Morris, Harald Welte
803and Rusty Russell.
Marc Bouchere6869a82000-03-20 06:03:29 +0000804.\" .. and did I mention that we are incredibly cool people?
Rusty Russell363112d2000-08-11 13:49:26 +0000805.\" .. sexy, too ..
Rusty Russell86573e52000-10-11 06:01:13 +0000806.\" .. witty, charming, powerful ..
James Morris060ae4c2000-10-29 01:29:57 +0000807.\" .. and most of all, modest ..