blob: 3e899afbd398622abd7346363ba8f1f24e6b353c [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001.TH IPTABLES 8 "Mar 20, 2000" "" ""
2.\"
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
69means to pass the packet to userspace.
70.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
78There are current three tables (which tables are present at any time
79depends on the kernel configuration options and which modules are
80present).
81.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
164will attempt to delete every non-builtin chain.
165.TP
166.B "-P, --policy"
167Set the policy for the chain to the given target. See the section
168.TP
169.B "-E, --rename-chain"
170Rename the user specified chain to the user supplied name; this is
171cosmetic, and has no effect on the structure of the table.
172.B TARGETS
173for the legal targets. Only non-userdefined chains can have policies,
174and neither built-in nor user-defined chains can be policy targets.
175.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
192different one. Also a protocol name from /etc/protocols is allowed.
193A "!" 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.
200.I All
201may not be used in in combination with the check command.
202.TP
203.BR "-s, --source " "[!] \fIaddress\fP[/\fImask\fP]"
204Source specification.
205.I Address
206can be either a hostname, a network name, or a plain IP address.
207The
208.I mask
209can be either a network mask or a plain number,
210specifying the number of 1's at the left side of the network mask.
211Thus, a mask of
212.I 24
213is equivalent to
214.IR 255.255.255.0 .
215A "!" argument before the address specification inverts the sense of
216the address. The flag
217.B --src
218is a convenient alias for this option.
219.TP
220.BR "-d, --destination " "[!] \fIaddress\fP[/\fImask\fP]"
221Destination specification.
222See the description of the
223.B -s
224(source) flag for a detailed description of the syntax. The flag
225.B --dst
226is an alias for this option.
227.TP
228.BI "-j, --jump " "target"
229This specifies the target of the rule; ie. what to do if the packet
230matches it. The target can be a user-defined chain (not the one this
231rule is in), one of the special builtin targets which decide the fate
232of the packet immediately, or an extension (see
233.B EXTENSIONS
234below). If this
235option is omitted in a rule, then matching the rule will have no
236effect on the packet's fate, but the counters on the rule will be
237incremented.
238.TP
239.BR "-i, --in-interface " "[!] [\fIname\fP]"
240Optional name of an interface via which a packet is received (for
241packets entering the
242.BR INPUT ,
243.B FORWARD
244and
245.B PREROUTING
246chains). When the "!" argument is used before the interface name, the
247sense is inverted. If the interface name ends in a "+", then any
248interface which begins with this name will match. If this option is
249omitted, the string "+" is assumed, which will match with any
250interface name.
251.TP
252.BR "-o, --out-interface " "[!] [\fIname\fP]"
253Optional name of an interface via which a packet is going to
254be sent (for packets entering the
255.BR FORWARD ,
256.B OUTPUT
257and
258.B POSTROUTING
259chains). When the "!" argument is used before the interface name,
260the sense is inverted. If the interface name ends in a "+", then any
261interface which begins with this name will match. If this option is
262omitted, the string "+" is assumed, which will match with any
263interface name.
264.TP
265.B "[!] " "-f, --fragment"
266This means that the rule only refers to second and further fragments
267of fragmented packets. Since there is no way to tell the source or
268destination ports of such a packet (or ICMP type), such a packet will
269not match any rules which specify them. When the "!" argument
270precedes the "-f" flag, the sense is inverted.
271.SS "OTHER OPTIONS"
272The following additional options can be specified:
273.TP
274.B "-v, --verbose"
275Verbose output. This option makes the list command show the interface
276address, the rule options (if any), and the TOS masks. The packet and
277byte counters are also listed, with the suffix 'K', 'M' or 'G' for
2781000, 1,000,000 and 1,000,000,000 multipliers respectively (but see
279the
280.B -x
281flag to change this).
282For appending, insertion, deletion and replacement, this causes
283detailed information on the rule or rules to be printed.
284.TP
285.B "-n, --numeric"
286Numeric output.
287IP addresses and port numbers will be printed in numeric format.
288By default, the program will try to display them as host names,
289network names, or services (whenever applicable).
290.TP
291.B "-x, --exact"
292Expand numbers.
293Display the exact value of the packet and byte counters,
294instead of only the rounded number in K's (multiples of 1000)
295M's (multiples of 1000K) or G's (multiples of 1000M). This option is
Marc Boucherf127a192000-03-20 08:32:15 +0000296only relevant for the
Marc Bouchere6869a82000-03-20 06:03:29 +0000297.B -L
298command.
299.TP
300.B "--line-numbers"
301When listing rules, add line numbers to the beginning of each rule,
302corresponding to that rule's position in the chain.
303.SH MATCH EXTENSIONS
304iptables can use extended packet matching modules. The following are
Marc Boucherf127a192000-03-20 08:32:15 +0000305included in the base package, and most of these can be preceded by a
Marc Bouchere6869a82000-03-20 06:03:29 +0000306.B !
307to invert the sense of the match.
308.SS tcp
309These extensions are loaded if `--protocol tcp' is specified, and no
310other match is specified. It provides the following options:
311.TP
James Morris59e90fd2000-06-23 16:44:47 +0000312.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000313Source port or port range specification. This can either be a service
314name or a port number. An inclusive range can also be specified,
315using the format
James Morris59e90fd2000-06-23 16:44:47 +0000316.IR port : port .
Marc Bouchere6869a82000-03-20 06:03:29 +0000317If the first port is omitted, "0" is assumed; if the last is omitted,
318"65535" is assumed.
319If the second port greater then the first they will be swapped.
320The flag
321.B --sport
322is an alias for this option.
323.TP
James Morris59e90fd2000-06-23 16:44:47 +0000324.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000325Destination port or port range specification. The flag
326.B --dport
327is an alias for this option.
328.TP
329.BR "--tcp-flags " "[!] \fImask\fP \fIcomp\fP"
330Match when the TCP flags are as specified. The first argument is the
331flags which we should examine, written as a comma-separated list, and
332the second argument is a comma-separated list of flags which must be
333set. Flags are:
334.BR "SYN ACK FIN RST URG PSH ALL NONE" .
335Hence the command
336.br
Marc Boucherf127a192000-03-20 08:32:15 +0000337 iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST SYN
Marc Bouchere6869a82000-03-20 06:03:29 +0000338.br
339will only match packets with the SYN flag set, and the ACK, FIN and
340RST flags unset.
341.TP
342.B "[!] --syn"
343Only match TCP packets with the SYN bit set and the ACK and FIN bits
344cleared. Such packets are used to request TCP connection initiation;
345for example, blocking such packets coming in an interface will prevent
346incoming TCP connections, but outgoing TCP connections will be
347unaffected.
348It is equivalent to \fB--tcp-flags SYN,RST,ACK SYN\fP.
349If the "!" flag precedes the "--syn", the sense of the
350option is inverted.
351.TP
352.BR "--tcp-option " "[!] \fInumber\fP"
353Match if TCP option set.
354.SS udp
355These extensions are loaded if `--protocol udp' is specified, and no
356other match is specified. It provides the following options:
357.TP
James Morris59e90fd2000-06-23 16:44:47 +0000358.BR "--source-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000359Source port or port range specification.
360See the description of the
361.B --source-port
362option of the TCP extension for details.
363.TP
James Morris59e90fd2000-06-23 16:44:47 +0000364.BR "--destination-port " "[!] [\fIport[:port]\fP]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000365Destination port or port range specification.
366See the description of the
367.B --destination-port
368option of the TCP extension for details.
369.SS icmp
370This extension is loaded if `--protocol icmp' is specified, and no
371other match is specified. It provides the following option:
372.TP
373.BR "--icmp-type " "[!] \fItypename\fP"
374This allows specification of the ICMP type, which can be a numeric
375ICMP type, or one of the ICMP type names shown by the command
376.br
377 iptables -p icmp -h
378.br
379.SS mac
380.TP
381.BR "--mac-source " "[!] \fIaddress\fP"
382Match source MAC address. It must be of the form XX:XX:XX:XX:XX:XX.
383Note that this only makes sense for packets entering the
384.BR PREROUTING ,
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000385.B FORWARD
Marc Bouchere6869a82000-03-20 06:03:29 +0000386or
387.B INPUT
Rusty Russell4b3c03d2000-07-03 10:11:55 +0000388chains for packets coming from an ethernet device.
Marc Bouchere6869a82000-03-20 06:03:29 +0000389.SS limit
390This module matches at a limited rate using a token bucket filter: it
391can be used in combination with the LOG target to give limited
392logging. A rule using this extension will match until this limit is
393reached (unless the `!' flag is used).
394.TP
395.BI "--limit " "rate"
396Maximum average matching rate: specified as a number, with an optional
397`/second', `/minute', `/hour', or `/day' suffix; the default is
3983/hour.
399.TP
400.BI "--limit-burst " "number"
401The maximum initial number of packets to match: this number gets
402recharged by one every time the limit specified above is not reached,
403up to this number; the default is 5.
404.SS multiport
405This module matches a set of source or destination ports. Up to 15
406ports can be specified. It can only be used in conjunction with
407.B "-p tcp"
408or
409.BR "-p udp" .
410.TP
411.BR "--source-port" " [\fIport[,port]\fP]"
412Match if the source port is one of the given ports.
413.TP
414.BR "--destination-port" " [\fIport[,port]\fP]"
415Match if the destination port is one of the given ports.
416.TP
417.BR "--port" " [\fIport[,port]\fP]"
418Match if the both the source and destination ports are equal to each
419other and to one of the given ports.
420.SS mark
421This module matches the netfilter mark field associated with a packet
422(which can be set using the
423.B MARK
424target below).
425.TP
426.BI "--mark " "value[/mask]"
427Matches packets with the given unsigned mark value (if a mask is
428specified, this is logically ANDed with the mark before the
429comparison).
430.SS owner
431This module attempts to match various characteristics of the packet
432creator, for locally-generated packets. It is only valid in the
433OUTPUT chain, and even this some packets (such as ICMP ping responses)
434may have no owner, and hence never match.
435.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000436.BI "--uid-owner " "userid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000437Matches if the packet was created by a process with the given
438effective user id.
439.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000440.BI "--gid-owner " "groupid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000441Matches if the packet was created by a process with the given
442effective group id.
443.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000444.BI "--pid-owner " "processid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000445Matches if the packet was created by a process with the given
446process id.
447.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000448.BI "--sid-owner " "sessionid"
Marc Bouchere6869a82000-03-20 06:03:29 +0000449Matches if the packet was created by a process in the given session
450group.
451.SS state
452This module, when combined with connection tracking, allows access to
453the connection tracking state for this packet.
454.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000455.BI "--state " "state"
Marc Bouchere6869a82000-03-20 06:03:29 +0000456Where state is a comma separated list of the connection states to
457match. Possible states are
458.B INVALID
459meaning that the packet is associated with no known connection,
460.B ESTABLISHED
461meaning that the packet is associated with a connection which has seen
462packets in both directions,
463.B NEW
464meaning that the packet has started a new connection, or otherwise
465associated with a connection which has not seen packets in both
466directions, and
467.B RELATED
468meaning that the packet is starting a new connection, but is
469associated with an existing connection, such as an FTP data transfer,
470or an ICMP error.
471.SS unclean
472This module takes no options, but attempts to match packets which seem
473malformed or unusual. This is regarded as experimental.
474.SS tos
475This module matches the 8 bits of Type of Service field in the IP
476header (ie. including the precedence bits).
477.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000478.BI "--tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000479The argument is either a standard name, (use
480.br
481 iptables -m tos -h
482.br
483to see the list), or a numeric value to match.
484.SH TARGET EXTENSIONS
485iptables can use extended target modules: the following are included
486in the standard distribution.
487.SS LOG
488Turn on kernel logging of matching packets. When this option is set
489for a rule, the Linux kernel will print some information on all
490matching packets (like most IP header fields) via
491.IR printk ().
492.TP
493.BI "--log-level " "level"
494Level of logging (numeric or see \fIsyslog.conf\fP(5)).
495.TP
496.BI "--log-prefix " "prefix"
497Prefix log messages with the specified prefix; up to 14 letters long,
498and useful for distinguishing messages in the logs.
499.TP
500.B --log-tcp-sequence
501Log TCP sequence numbers. This is a security risk if the log is
502readable by users.
503.TP
504.B --log-tcp-options
505Log options from the TCP packet header.
506.TP
507.B --log-ip-options
508Log options from the IP packet header.
509.SS MARK
510This is used to set the netfilter mark value associated with the
511packet. It is only valid in the
512.B mangle
513table.
514.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000515.BI "--set-mark " "mark"
Marc Bouchere6869a82000-03-20 06:03:29 +0000516.SS REJECT
517This is used to send back an error packet in response to the matched
518packet: otherwise it is equivalent to
519.BR DROP .
520This target is only valid in the
521.BR INPUT ,
522.B FORWARD
523and
524.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000525chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000526chains. Several options control the nature of the error packet
527returned:
528.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000529.BI "--reject-with " "type"
Marc Bouchere6869a82000-03-20 06:03:29 +0000530The type given can be
531.BR icmp-net-unreachable ,
532.BR icmp-host-unreachable ,
Rusty Russell14f390f2000-07-30 01:10:04 +0000533.BR icmp-port-unreachable ,
534.BR icmp-proto-unreachable ,
535.BR icmp-net-prohibited or
536.BR icmp-host-prohibited ,
Rusty Russellddd5b3b2000-05-31 06:32:47 +0000537which return the appropriate ICMP error message (port-unreachable is
Rusty Russella1ce9f92000-03-24 08:39:16 +0000538the default). The option
Marc Bouchere6869a82000-03-20 06:03:29 +0000539.B echo-reply
Rusty Russella1ce9f92000-03-24 08:39:16 +0000540is also allowed; it can only be used for rules which specify an ICMP
Rusty Russell14f390f2000-07-30 01:10:04 +0000541ping packet, and generates a ping reply. Finally, the option
542.B tcp-reset
543can be used on rules in (or called from) the
544.B INPUT
545chain which only match the TCP protocol: this causes a TCP RST packet
546to be sent back.
Marc Bouchere6869a82000-03-20 06:03:29 +0000547.SS TOS
548This is used to set the 8-bit Type of Service field in the IP header.
549It is only valid in the
550.B mangle
551table.
552.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000553.BI "--set-tos " "tos"
Marc Bouchere6869a82000-03-20 06:03:29 +0000554You can use a numeric TOS values, or use
555.br
556 iptables -j TOS -h
557.br
558to see the list of valid TOS names.
559.SS MIRROR
560This is an experimental demonstration target which inverts the source
561and destination fields in the IP header and retransmits the packet.
562It is only valid in the
563.BR INPUT ,
564.B FORWARD
565and
566.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000567chains, and user-defined chains which are only called from those chains.
Marc Bouchere6869a82000-03-20 06:03:29 +0000568.SS SNAT
569This target is only valid in the
570.B nat
571table, in the
572.B POSTROUTING
573chain. It specifies that the source address of the packet should be
574modified (and all future packets in this connection will also be
575mangled), and rules should cease being examined. It takes one option:
576.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000577.BI "--to-source " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000578which can specify a single new source IP address, an inclusive range
579of IP addresses, and optionally, a port range (which is only valid if
580the rule also specifies
581.B "-p tcp"
582or
583.BR "-p udp" ).
584If no port range is specified, then source ports below 512 will be
585mapped to other ports below 512: those between 1024 will be mapped to
586ports below 1024, and other ports will be mapped to 1024 or above.
587Where possible, no port alteration will occur.
588.SS DNAT
589This target is only valid in the
590.B nat
591table, in the
592.B PREROUTING
593and
594.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000595chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000596chains. It specifies that the destination address of the packet
597should be modified (and all future packets in this connection will
598also be mangled), and rules should cease being examined. It takes one
599option:
600.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000601.BI "--to-destination " "<ipaddr>[-<ipaddr>][:port-port]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000602which can specify a single new destination IP address, an inclusive
603range of IP addresses, and optionally, a port range (which is only
604valid if the rule also specifies
605.B "-p tcp"
606or
607.BR "-p udp" ).
608If no port range is specified, then the destination port will never be
609modified.
610.SS MASQUERADE
611This target is only valid in the
612.B nat
613table, in the
614.B POSTROUTING
615chain. It should only be used with dynamically assigned IP (dialup)
616connections: if you have a static IP address, you should use the SNAT
617target. Masquerading is equivalent to specifying a mapping to the IP
618address of the interface the packet is going out, but also has the
619effect that connections are
620.I forgotten
Marc Boucherf127a192000-03-20 08:32:15 +0000621when the interface goes down. This is the correct behavior when the
Marc Bouchere6869a82000-03-20 06:03:29 +0000622next dialup is unlikely to have the same interface address (and hence
623any established connections are lost anyway). It takes one option:
624.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000625.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000626This specifies a range of source ports to use, overriding the default
627.B SNAT
628source port-selection heuristics (see above). This is only valid with
629if the rule also specifies
630.B "-p tcp"
631or
632.BR "-p udp" ).
633.SS REDIRECT
634This target is only valid in the
635.B nat
636table, in the
637.B PREROUTING
638and
639.B OUTPUT
Rusty Russell9cadb432000-05-10 00:18:06 +0000640chains, and user-defined chains which are only called from those
Marc Bouchere6869a82000-03-20 06:03:29 +0000641chains. It alters the destination IP address to send the packet to
642the machine itself (locally-generated packets are mapped to the
Rusty Russell9cadb432000-05-10 00:18:06 +0000643127.0.0.1 address). It takes one option:
Marc Bouchere6869a82000-03-20 06:03:29 +0000644.TP
Bert Hubert20ecf7a2000-03-24 01:56:37 +0000645.BI "--to-ports " "<port>[-<port>]"
Marc Bouchere6869a82000-03-20 06:03:29 +0000646This specifies a destination port or range or ports to use: without
647this, the destination port is never altered. This is only valid with
648if the rule also specifies
649.B "-p tcp"
650or
651.BR "-p udp" ).
652.TP
653.SH DIAGNOSTICS
654Various error messages are printed to standard error. The exit code
655is 0 for correct functioning. Errors which appear to be caused by
656invalid or abused command line parameters cause an exit code of 2, and
657other errors cause an exit code of 1.
658.SH BUGS
659Check is not implemented (yet).
660.SH COMPATIBILITY WITH IPCHAINS
661This
662.B iptables
663is very similar to ipchains by Rusty Russell. The main difference is
664that the chains
665.B INPUT
666and
667.B OUTPUT
668are only traversed for packets coming into the local host and
669originating from the local host respectively. Hence every packet only
670passes through one of the three chains; previously a forwarded packet
671would pass through all three.
672.PP
673The other main difference is that
674.B -i
675refers to the input interface;
676.B -o
677refers to the output interface, and both are available for packets
678entering the
679.B FORWARD
680chain.
681.PP The various forms of NAT have been separated out;
682.B iptables
683is a pure packet filter when using the default `filter' table, with
684optional extension modules. This should simplify much of the previous
685confusion over the combination of IP masquerading and packet filtering
686seen previously. So the following options are handled differently:
687.br
688 -j MASQ
689.br
690 -M -S
691.br
692 -M -L
693.br
694There are several other changes in iptables.
695.SH SEE ALSO
696The iptables-HOWTO, which details more iptables usage, and the
697netfilter-hacking-HOWTO which details the internals.
Marc Boucherf127a192000-03-20 08:32:15 +0000698.SH AUTHORS
Marc Bouchere6869a82000-03-20 06:03:29 +0000699Rusty Russell wrote iptables, in early consultation with Michael
700Neuling.
701.PP
Marc Boucherf127a192000-03-20 08:32:15 +0000702Marc Boucher made Rusty abandon ipnatctl by lobbying for a generic packet
703selection framework in iptables, then wrote the mangle table, the owner match,
704the mark stuff, and ran around doing cool stuff everywhere.
Marc Bouchere6869a82000-03-20 06:03:29 +0000705.PP
706James Morris wrote the TOS target, and tos match.
707.PP
708Jozsef Kadlecsik wrote the REJECT target.
709.PP
710The Netfilter Core Team is: Marc Boucher, Rusty Russell.
711.\" .. and did I mention that we are incredibly cool people?