blob: 1a7f81029bf23132e9a753d9a6616874db490b89 [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
43filter rules in the Linux kernel. There are several different tables
44which may be defined, and each table contains a number of built-in
45chains, and may contain user-defined chains.
46
47Each chain is a list of rules which can match a set of packets: each
48rule specifies what to do with a packet which matches. This is called
49a `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
56target, which can be the name of a user-defined chain, or one of the
57special 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
71means 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,
73or 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:
89.BR "filter"
90This is the default table, and contains the built-in chains INPUT (for
91packets coming into the box itself), FORWARD (for packets being routed
92through the box), and OUTPUT (for locally-generated packets).
93.BR "nat"
94This table is consulted when a packet which is creates a new
95connection is encountered. It consists of three built-ins: PREROUTING
96(for altering packets as soon as they come in), OUTPUT (for altering
97locally-generated packets before routing), and POSTROUTING (for
98altering packets as they are about to go out).
99.BR "mangle"
100This table is used for specialized packet alteration. It has two
101built-in chains: PREROUTING (for altering incoming packets before
102routing) and OUTPUT (for altering locally-generated packets before
103routing).
104.SH OPTIONS
105The options that are recognized by
106.B iptables
107can be divided into several different groups.
108.SS COMMANDS
109These options specify the specific action to perform; only one of them
110can be specified on the command line, unless otherwise specified
111below. For all the long versions of the command and option names, you
112only need to use enough letters to ensure that
113.B iptables
114can differentiate it from all other options.
115.TP
116.BR "-A, --append"
117Append one or more rules to the end of the selected chain.
118When the source and/or destination names resolve to more than one
119address, a rule will be added for each possible address combination.
120.TP
121.BR "-D, --delete"
122Delete one or more rules from the selected chain. There are two
123versions of this command: the rule can be specified as a number in the
124chain (starting at 1 for the first rule) or a rule to match.
125.TP
126.B "-R, --replace"
127Replace a rule in the selected chain. If the source and/or
128destination names resolve to multiple addresses, the command will
129fail. Rules are numbered starting at 1.
130.TP
131.B "-I, --insert"
132Insert one or more rules in the selected chain as the given rule
133number. So, if the rule number is 1, the rule or rules are inserted
134at the head of the chain. This is also the default if no rule number
135is specified.
136.TP
137.B "-L, --list"
138List all rules in the selected chain. If no chain is selected, all
139chains are listed. It is legal to specify the
140.B -Z
141(zero) option as well, in which case the chain(s) will be atomically
142listed and zeroed. The exact output is effected by the other
143arguments given.
144.TP
145.B "-F, --flush"
146Flush the selected chain. This is equivalent to deleting all the
147rules one by one.
148.TP
149.B "-Z, --zero"
150Zero the packet and byte counters in all chains. It is legal to
151specify the
152.B "-L, --list"
153(list) option as well, to see the counters immediately before they are
154cleared; see above.
155.TP
156.B "-N, --new-chain"
157Create a new user-defined chain of the given name. There must be no
158target of that name already.
159.TP
160.B "-X, --delete-chain"
161Delete the specified user-defined chain. There must be no references
162to the chain (if there are you must delete or replace the referring
163rules before the chain can be deleted). If no argument is given, it
Rusty Russell363112d2000-08-11 13:49:26 +0000164will attempt to delete every non-builtin chain in the table.
Marc Bouchere6869a82000-03-20 06:03:29 +0000165.TP
166.B "-P, --policy"
167Set the policy for the chain to the given target. See the section
Rusty Russell363112d2000-08-11 13:49:26 +0000168.B TARGETS
Rusty Russell86573e52000-10-11 06:01:13 +0000169for the legal targets. Only non-user-defined chains can have policies,
Rusty Russell363112d2000-08-11 13:49:26 +0000170and neither built-in nor user-defined chains can be policy targets.
Marc Bouchere6869a82000-03-20 06:03:29 +0000171.TP
172.B "-E, --rename-chain"
173Rename the user specified chain to the user supplied name; this is
174cosmetic, and has no effect on the structure of the table.
Marc Bouchere6869a82000-03-20 06:03:29 +0000175.TP
176.B -h
177Help.
178Give a (currently very brief) description of the command syntax.
179.SS PARAMETERS
180The following parameters make up a rule specification (as used in the
181add, delete, replace, append and check commands).
182.TP
Rusty Russell2e0a3212000-04-19 11:23:18 +0000183.BR "-p, --protocol " "[!] \fIprotocol\fP"
Marc Bouchere6869a82000-03-20 06:03:29 +0000184The protocol of the rule or of the packet to check.
185The specified protocol can be one of
186.IR tcp ,
187.IR udp ,
188.IR icmp ,
189or
190.IR all ,
191or it can be a numeric value, representing one of these protocols or a
Rusty Russell363112d2000-08-11 13:49:26 +0000192different one. A protocol name from /etc/protocols is also allowed.
Marc Bouchere6869a82000-03-20 06:03:29 +0000193A "!" argument before the protocol inverts the
194test. The number zero is equivalent to
195.IR all .
196Protocol
197.I all
198will match with all protocols and is taken as default when this
199option is omitted.
Marc Bouchere6869a82000-03-20 06:03:29 +0000200.TP
201.BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
202Source specification.
203.I Address
204can be either a hostname, a network name, or a plain IP address.
205The
206.I mask
207can be either a network mask or a plain number,
208specifying the number of 1's at the left side of the network mask.
209Thus, a mask of
210.I 24
211is equivalent to
212.IR 255.255.255.0 .
213A "!" argument before the address specification inverts the sense of
214the address. The flag
215.B --src
216is a convenient alias for this option.
217.TP
218.BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
219Destination specification.
220See the description of the
221.B -s
222(source) flag for a detailed description of the syntax. The flag
223.B --dst
224is an alias for this option.
225.TP
226.BI "-j, --jump " "target"
227This specifies the target of the rule; ie. what to do if the packet
228matches it. The target can be a user-defined chain (not the one this
229rule is in), one of the special builtin targets which decide the fate
230of the packet immediately, or an extension (see
231.B EXTENSIONS
232below). If this
233option is omitted in a rule, then matching the rule will have no
234effect on the packet's fate, but the counters on the rule will be
235incremented.
236.TP
237.BR "-i, --in-interface " "[!] [\fIname\fP]"
238Optional name of an interface via which a packet is received (for
239packets entering the
240.BR INPUT ,
241.B FORWARD
242and
243.B PREROUTING
244chains). When the "!" argument is used before the interface name, the
245sense is inverted. If the interface name ends in a "+", then any
246interface which begins with this name will match. If this option is
247omitted, the string "+" is assumed, which will match with any
248interface name.
249.TP
250.BR "-o, --out-interface " "[!] [\fIname\fP]"
251Optional name of an interface via which a packet is going to
252be sent (for packets entering the
253.BR FORWARD ,
254.B OUTPUT
255and
256.B POSTROUTING
257chains). When the "!" argument is used before the interface name,
258the sense is inverted. If the interface name ends in a "+", then any
259interface which begins with this name will match. If this option is
260omitted, the string "+" is assumed, which will match with any
261interface name.
262.TP
263.B "[!] " "-f, --fragment"
264This means that the rule only refers to second and further fragments
265of fragmented packets. Since there is no way to tell the source or
266destination ports of such a packet (or ICMP type), such a packet will
267not match any rules which specify them. When the "!" argument
Rusty Russell363112d2000-08-11 13:49:26 +0000268precedes the "-f" flag, the rule will only match head fragments, or
269unfragmented packets.
Harald Welteccd49e52001-01-23 22:54:34 +0000270.TP
271.B "-c, --set-counters " "PKTS BYTES"
272This enables the administrater to initialize the packet and byte
273counters of a rule (during
274.B INSERT,
275.B APPEND,
276.B REPLACE
277operations)
Marc Bouchere6869a82000-03-20 06:03:29 +0000278.SS "OTHER OPTIONS"
279The following additional options can be specified:
280.TP
281.B "-v, --verbose"
282Verbose output. This option makes the list command show the interface
283address, the rule options (if any), and the TOS masks. The packet and
284byte counters are also listed, with the suffix 'K', 'M' or 'G' for
2851000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
286the
287.B -x
288flag to change this).
289For appending, insertion, deletion and replacement, this causes
290detailed information on the rule or rules to be printed.
291.TP
292.B "-n, --numeric"
293Numeric output.
294IP addresses and port numbers will be printed in numeric format.
295By default, the program will try to display them as host names,
296network names, or services (whenever applicable).
297.TP
298.B "-x, --exact"
299Expand numbers.
300Display the exact value of the packet and byte counters,
301instead of only the rounded number in K's (multiples of 1000)
302M's (multiples of 1000K) or G's (multiples of 1000M). This option is
Marc Boucherf127a192000-03-20 08:32:15 +0000303only relevant for the
Marc Bouchere6869a82000-03-20 06:03:29 +0000304.B -L
305command.
306.TP
307.B "--line-numbers"
308When listing rules, add line numbers to the beginning of each rule,
309corresponding to that rule's position in the chain.
310.SH MATCH EXTENSIONS
Rusty Russell363112d2000-08-11 13:49:26 +0000311iptables can use extended packet matching modules. These are loaded
312in two ways: implicitly, when
313.B -p
314or
315.B --protocol
316is specified, or with the
317.B -m
318or
319.B --match
320options, followed by the matching module name; after these, various
321extra command line options become available, depending on the specific
322module. You can specify multiple extended match modules in one line, and you can use the
323.B -h
324or
325.B --help
326options after the module has been specified to receive help specific
327to that module.
328
329The following are included in the base package, and most of these can
330be preceded by a
Marc Bouchere6869a82000-03-20 06:03:29 +0000331.B !
332to invert the sense of the match.
333.SS tcp
Rusty Russell363112d2000-08-11 13:49:26 +0000334These extensions are loaded if `--protocol tcp' is specified. It
335provides the following options:
Marc Bouchere6869a82000-03-20 06:03:29 +0000336.TP
James Morris59e90fd2000-06-23 16:44:47 +0000337.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000338Source port or port range specification. This can either be a service
339name or a port number. An inclusive range can also be specified,
340using the format
James Morris59e90fd2000-06-23 16:44:47 +0000341.IR port : port .
Marc Bouchere6869a82000-03-20 06:03:29 +0000342If the first port is omitted, "0" is assumed; if the last is omitted,
343"65535" is assumed.
344If the second port greater then the first they will be swapped.
345The flag
346.B --sport
347is an alias for this option.
348.TP
James Morris59e90fd2000-06-23 16:44:47 +0000349.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000350Destination port or port range specification. The flag
351.B --dport
352is an alias for this option.
353.TP
354.BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
355Match when the TCP flags are as specified. The first argument is the
356flags which we should examine, written as a comma-separated list, and
357the second argument is a comma-separated list of flags which must be
358set. Flags are:
359.BR "SYN ACK FIN RST URG PSH ALL NONE" .
360Hence the command
361.br
Marc Boucherf127a192000-03-20 08:32:15 +0000362 iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
Marc Bouchere6869a82000-03-20 06:03:29 +0000363.br
364will only match packets with the SYN flag set, and the ACK, FIN and
365RST flags unset.
366.TP
367.B "[!] --syn"
368Only match TCP packets with the SYN bit set and the ACK and FIN bits
369cleared. Such packets are used to request TCP connection initiation;
370for example, blocking such packets coming in an interface will prevent
371incoming TCP connections, but outgoing TCP connections will be
372unaffected.
373It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP.
374If the "!" flag precedes the "--syn", the sense of the
375option is inverted.
376.TP
377.BR "--tcp-option " "[!] \fInumber\fP"
378Match if TCP option set.
379.SS udp
Rusty Russell363112d2000-08-11 13:49:26 +0000380These extensions are loaded if `--protocol udp' is specified. It
381provides the following options:
Marc Bouchere6869a82000-03-20 06:03:29 +0000382.TP
James Morris59e90fd2000-06-23 16:44:47 +0000383.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000384Source port or port range specification.
385See the description of the
386.B --source-port
387option of the TCP extension for details.
388.TP
James Morris59e90fd2000-06-23 16:44:47 +0000389.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000390Destination port or port range specification.
391See the description of the
392.B --destination-port
393option of the TCP extension for details.
394.SS icmp
Rusty Russell363112d2000-08-11 13:49:26 +0000395This extension is loaded if `--protocol icmp' is specified. It
396provides the following option:
Marc Bouchere6869a82000-03-20 06:03:29 +0000397.TP
398.BR "--icmp-type " "[!] \fItypename\fP"
399This allows specification of the ICMP type, which can be a numeric
400ICMP type, or one of the ICMP type names shown by the command
401.br
402 iptables -p icmp -h
403.br
404.SS mac
405.TP
406.BR "--mac-source " "[!] \fIaddress\fP"
407Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX.
408Note that this only makes sense for packets entering the
409.BR PREROUTING ,
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000410.B FORWARD
Marc Bouchere6869a82000-03-20 06:03:29 +0000411or
412.B INPUT
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000413chains for packets coming from an ethernet device.
Marc Bouchere6869a82000-03-20 06:03:29 +0000414.SS limit
415This module matches at a limited rate using a token bucket filter: it
Rusty Russell363112d2000-08-11 13:49:26 +0000416can be used in combination with the
417.B LOG
418target to give limited logging. A rule using this extension will
419match until this limit is reached (unless the `!' flag is used).
Marc Bouchere6869a82000-03-20 06:03:29 +0000420.TP
421.BI "--limit " "rate"
422Maximum average matching rate: specified as a number, with an optional
423`/second', `/minute', `/hour', or `/day' suffix; the default is
4243/hour.
425.TP
426.BI "--limit-burst " "number"
427The maximum initial number of packets to match: this number gets
428recharged by one every time the limit specified above is not reached,
429up to this number; the default is 5.
430.SS multiport
431This module matches a set of source or destination ports. Up to 15
432ports can be specified. It can only be used in conjunction with
433.B "-p tcp"
434or
435.BR "-p udp" .
436.TP
437.BR "--source-port" " [\fIport[,port]\fP]"
438Match if the source port is one of the given ports.
439.TP
440.BR "--destination-port" " [\fIport[,port]\fP]"
441Match if the destination port is one of the given ports.
442.TP
443.BR "--port" " [\fIport[,port]\fP]"
444Match if the both the source and destination ports are equal to each
445other and to one of the given ports.
446.SS mark
447This module matches the netfilter mark field associated with a packet
448(which can be set using the
449.B MARK
450target below).
451.TP
452.BI "--mark " "value[/mask]"
453Matches packets with the given unsigned mark value (if a mask is
454specified, this is logically ANDed with the mark before the
455comparison).
456.SS owner
457This module attempts to match various characteristics of the packet
458creator, for locally-generated packets. It is only valid in the
Rusty Russell363112d2000-08-11 13:49:26 +0000459.B OUTPUT
460chain, and even this some packets (such as ICMP ping responses) may
461have no owner, and hence never match.
Marc Bouchere6869a82000-03-20 06:03:29 +0000462.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000463.BI "--uid-owner " "userid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000464Matches if the packet was created by a process with the given
465effective user id.
466.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000467.BI "--gid-owner " "groupid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000468Matches if the packet was created by a process with the given
469effective group id.
470.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000471.BI "--pid-owner " "processid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000472Matches if the packet was created by a process with the given
473process id.
474.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000475.BI "--sid-owner " "sessionid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000476Matches if the packet was created by a process in the given session
477group.
478.SS state
479This module, when combined with connection tracking, allows access to
480the connection tracking state for this packet.
481.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000482.BI "--state " "state"
Marc Bouchere6869a82000-03-20 06:03:29 +0000483Where state is a comma separated list of the connection states to
484match. Possible states are
485.B INVALID
486meaning that the packet is associated with no known connection,
487.B ESTABLISHED
488meaning that the packet is associated with a connection which has seen
489packets in both directions,
490.B NEW
491meaning that the packet has started a new connection, or otherwise
492associated with a connection which has not seen packets in both
493directions, and
494.B RELATED
495meaning that the packet is starting a new connection, but is
496associated with an existing connection, such as an FTP data transfer,
497or an ICMP error.
498.SS unclean
499This module takes no options, but attempts to match packets which seem
500malformed or unusual. This is regarded as experimental.
501.SS tos
502This module matches the 8 bits of Type of Service field in the IP
503header (ie. including the precedence bits).
504.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000505.BI "--tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000506The argument is either a standard name, (use
507.br
508 iptables -m tos -h
509.br
510to see the list), or a numeric value to match.
511.SH TARGET EXTENSIONS
512iptables can use extended target modules: the following are included
513in the standard distribution.
514.SS LOG
515Turn on kernel logging of matching packets. When this option is set
516for a rule, the Linux kernel will print some information on all
Rusty Russell363112d2000-08-11 13:49:26 +0000517matching packets (like most IP header fields) via the kernel log
518(where it can be read with
519.I dmesg
520or
521.IR syslogd (8)).
Marc Bouchere6869a82000-03-20 06:03:29 +0000522.TP
523.BI "--log-level " "level"
524Level of logging (numeric or see \fIsyslog.conf\fP(5)).
525.TP
526.BI "--log-prefix " "prefix"
Rusty Russellf81427e2000-09-13 04:20:38 +0000527Prefix log messages with the specified prefix; up to 29 letters long,
Marc Bouchere6869a82000-03-20 06:03:29 +0000528and useful for distinguishing messages in the logs.
529.TP
530.B --log-tcp-sequence
531Log TCP sequence numbers. This is a security risk if the log is
532readable by users.
533.TP
534.B --log-tcp-options
535Log options from the TCP packet header.
536.TP
537.B --log-ip-options
538Log options from the IP packet header.
539.SS MARK
540This is used to set the netfilter mark value associated with the
541packet. It is only valid in the
542.B mangle
543table.
544.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000545.BI "--set-mark " "mark"
Marc Bouchere6869a82000-03-20 06:03:29 +0000546.SS REJECT
547This is used to send back an error packet in response to the matched
548packet: otherwise it is equivalent to
549.BR DROP .
550This target is only valid in the
551.BR INPUT ,
552.B FORWARD
553and
554.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000555chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000556chains. Several options control the nature of the error packet
557returned:
558.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000559.BI "--reject-with " "type"
Marc Bouchere6869a82000-03-20 06:03:29 +0000560The type given can be
561.BR icmp-net-unreachable ,
562.BR icmp-host-unreachable ,
Rusty Russell14f390f2000-07-30 01:10:04 +0000563.BR icmp-port-unreachable ,
564.BR icmp-proto-unreachable ,
565.BR icmp-net-prohibited or
566.BR icmp-host-prohibited ,
Rusty Russellddd5b3b2000-05-31 06:32:47 +0000567which return the appropriate ICMP error message (port-unreachable is
Rusty Russella1ce9f92000-03-24 08:39:16 +0000568the default). The option
Marc Bouchere6869a82000-03-20 06:03:29 +0000569.B echo-reply
Rusty Russella1ce9f92000-03-24 08:39:16 +0000570is also allowed; it can only be used for rules which specify an ICMP
Rusty Russell14f390f2000-07-30 01:10:04 +0000571ping packet, and generates a ping reply. Finally, the option
572.B tcp-reset
Rusty Russell363112d2000-08-11 13:49:26 +0000573can be used on rules which only match the TCP protocol: this causes a
574TCP RST packet to be sent back. This is mainly useful for blocking
575.I ident
576probes which frequently occur when sending mail to broken mail hosts
577(which won't accept your mail otherwise).
Marc Bouchere6869a82000-03-20 06:03:29 +0000578.SS TOS
579This is used to set the 8-bit Type of Service field in the IP header.
580It is only valid in the
581.B mangle
582table.
583.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000584.BI "--set-tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000585You can use a numeric TOS values, or use
586.br
587 iptables -j TOS -h
588.br
589to see the list of valid TOS names.
590.SS MIRROR
591This is an experimental demonstration target which inverts the source
592and destination fields in the IP header and retransmits the packet.
593It is only valid in the
594.BR INPUT ,
595.B FORWARD
596and
Rusty Russell363112d2000-08-11 13:49:26 +0000597.B PREROUTING
598chains, and user-defined chains which are only called from those
599chains. Note that the outgoing packets are
600.B NOT
601seen by any packet filtering chains, connection tracking or NAT, to
602avoid loops and other problems.
Marc Bouchere6869a82000-03-20 06:03:29 +0000603.SS SNAT
604This target is only valid in the
605.B nat
606table, in the
607.B POSTROUTING
608chain. It specifies that the source address of the packet should be
609modified (and all future packets in this connection will also be
610mangled), and rules should cease being examined. It takes one option:
611.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000612.BI "--to-source " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000613which can specify a single new source IP address, an inclusive range
614of IP addresses, and optionally, a port range (which is only valid if
615the rule also specifies
616.B "-p tcp"
617or
618.BR "-p udp" ).
619If no port range is specified, then source ports below 512 will be
620mapped to other ports below 512: those between 1024 will be mapped to
621ports below 1024, and other ports will be mapped to 1024 or above.
622Where possible, no port alteration will occur.
623.SS DNAT
624This target is only valid in the
625.B nat
626table, in the
627.B PREROUTING
628and
629.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000630chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000631chains. It specifies that the destination address of the packet
632should be modified (and all future packets in this connection will
633also be mangled), and rules should cease being examined. It takes one
634option:
635.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000636.BI "--to-destination " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000637which can specify a single new destination IP address, an inclusive
638range of IP addresses, and optionally, a port range (which is only
639valid if the rule also specifies
640.B "-p tcp"
641or
642.BR "-p udp" ).
643If no port range is specified, then the destination port will never be
644modified.
645.SS MASQUERADE
646This target is only valid in the
647.B nat
648table, in the
649.B POSTROUTING
650chain. It should only be used with dynamically assigned IP (dialup)
651connections: if you have a static IP address, you should use the SNAT
652target. Masquerading is equivalent to specifying a mapping to the IP
653address of the interface the packet is going out, but also has the
654effect that connections are
655.I forgotten
Marc Boucherf127a192000-03-20 08:32:15 +0000656when the interface goes down. This is the correct behavior when the
Marc Bouchere6869a82000-03-20 06:03:29 +0000657next dialup is unlikely to have the same interface address (and hence
658any established connections are lost anyway). It takes one option:
659.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000660.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000661This specifies a range of source ports to use, overriding the default
662.B SNAT
663source port-selection heuristics (see above). This is only valid with
664if the rule also specifies
665.B "-p tcp"
666or
667.BR "-p udp" ).
668.SS REDIRECT
669This target is only valid in the
670.B nat
671table, in the
672.B PREROUTING
673and
674.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000675chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000676chains. It alters the destination IP address to send the packet to
677the machine itself (locally-generated packets are mapped to the
Rusty Russell9cadb432000-05-10 00:18:06 +0000678127.0.0.1 address). It takes one option:
Marc Bouchere6869a82000-03-20 06:03:29 +0000679.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000680.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000681This specifies a destination port or range or ports to use: without
682this, the destination port is never altered. This is only valid with
683if the rule also specifies
684.B "-p tcp"
685or
686.BR "-p udp" ).
Rusty Russell86573e52000-10-11 06:01:13 +0000687.SH EXTRA EXTENSIONS
688The following extensions are not included by default in the standard
689distribution.
690.SS ttl
691This module matches the time to live field in the IP header.
692.TP
693.BI "--ttl " "ttl"
694Matches the given TTL value.
695.SS TTL
696This target is used to modify the time to live field in the IP header.
697It is only valid in the
698.B mangle
699table.
700.TP
701.BI "--ttl-set " "ttl"
702Set the TTL to the given value.
703.TP
704.BI "--ttl-dec " "ttl"
705Decrement the TTL by the given value.
706.TP
707.BI "--ttl-inc " "ttl"
708Increment the TTL by the given value.
Rusty Russell52451822000-08-27 07:47:46 +0000709.SS ULOG
Rusty Russell86573e52000-10-11 06:01:13 +0000710This target provides userspace logging of matching packets. When this
711target is set for a rule, the Linux kernel will multicast this packet
712through a
Rusty Russell52451822000-08-27 07:47:46 +0000713.IR netlink
Rusty Russell86573e52000-10-11 06:01:13 +0000714socket. One or more userspace processes may then subscribe to various
Rusty Russell52451822000-08-27 07:47:46 +0000715multicast groups and receive the packets.
716.TP
717.BI "--ulog-nlgroup" "<nlgroup>"
718This specifies the netlink group (1-32) to which the packet is sent.
719.TP
720.BI "--ulog-prefix" "<prefix>"
721Prefix log messages with the specified prefix; up to 32 characters
722long, and useful fro distinguishing messages in the logs.
723.TP
724.BI "--ulog-cprange" "<size>"
Rusty Russell86573e52000-10-11 06:01:13 +0000725Number of bytes to be copied to userspace. A value of 0 always copies
Rusty Russell52451822000-08-27 07:47:46 +0000726the entire packet, regardless of its size.
Rusty Russell86573e52000-10-11 06:01:13 +0000727.SH DIAGNOSTICS
728Various error messages are printed to standard error. The exit code
729is 0 for correct functioning. Errors which appear to be caused by
730invalid or abused command line parameters cause an exit code of 2, and
731other errors cause an exit code of 1.
Marc Bouchere6869a82000-03-20 06:03:29 +0000732.SH BUGS
733Check is not implemented (yet).
734.SH COMPATIBILITY WITH IPCHAINS
735This
736.B iptables
737is very similar to ipchains by Rusty Russell. The main difference is
738that the chains
739.B INPUT
740and
741.B OUTPUT
742are only traversed for packets coming into the local host and
743originating from the local host respectively. Hence every packet only
744passes through one of the three chains; previously a forwarded packet
745would pass through all three.
746.PP
747The other main difference is that
748.B -i
749refers to the input interface;
750.B -o
751refers to the output interface, and both are available for packets
752entering the
753.B FORWARD
754chain.
755.PP The various forms of NAT have been separated out;
756.B iptables
757is a pure packet filter when using the default `filter' table, with
758optional extension modules. This should simplify much of the previous
759confusion over the combination of IP masquerading and packet filtering
760seen previously. So the following options are handled differently:
761.br
762 -j MASQ
763.br
764 -M -S
765.br
766 -M -L
767.br
768There are several other changes in iptables.
769.SH SEE ALSO
Rusty Russell363112d2000-08-11 13:49:26 +0000770The iptables-HOWTO, which details more iptables usage, the NAT-HOWTO,
771which details NAT, and the netfilter-hacking-HOWTO which details the
772internals.
Marc Boucherf127a192000-03-20 08:32:15 +0000773.SH AUTHORS
Marc Bouchere6869a82000-03-20 06:03:29 +0000774Rusty Russell wrote iptables, in early consultation with Michael
775Neuling.
776.PP
Marc Boucherf127a192000-03-20 08:32:15 +0000777Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
778selection framework in iptables, then wrote the mangle table, the owner match,
779the mark stuff, and ran around doing cool stuff everywhere.
Marc Bouchere6869a82000-03-20 06:03:29 +0000780.PP
781James Morris wrote the TOS target, and tos match.
782.PP
783Jozsef Kadlecsik wrote the REJECT target.
784.PP
Rusty Russell86573e52000-10-11 06:01:13 +0000785Harald Welte wrote the ULOG target, TTL match+target and libipulog.
Rusty Russell52451822000-08-27 07:47:46 +0000786.PP
Rusty Russellf61bb5f2000-10-13 07:11:24 +0000787The Netfilter Core Team is: Marc Boucher, James Morris, Harald Welte
788and Rusty Russell.
Marc Bouchere6869a82000-03-20 06:03:29 +0000789.\" .. and did I mention that we are incredibly cool people?
Rusty Russell363112d2000-08-11 13:49:26 +0000790.\" .. sexy, too ..
Rusty Russell86573e52000-10-11 06:01:13 +0000791.\" .. witty, charming, powerful ..
James Morris060ae4c2000-10-29 01:29:57 +0000792.\" .. and most of all, modest ..