blob: 7a16118bbc53a33603caf8256fbe06a72d591869 [file] [log] [blame]
Jan Engelhardtfea74bf2009-01-12 04:53:18 +01001These extensions can be used if `\-\-protocol tcp' is specified. It
Henrik Nordstromc2794132004-01-22 15:04:24 +00002provides the following options:
3.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +01004[\fB!\fP] \fB\-\-source\-port\fP,\fB\-\-sport\fP \fIport\fP[\fB:\fP\fIport\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +00005Source port or port range specification. This can either be a service
6name or a port number. An inclusive range can also be specified,
Ian Bruceae737f02009-06-06 06:04:24 +02007using the format \fIfirst\fP\fB:\fP\fIlast\fP.
Henrik Nordstromc2794132004-01-22 15:04:24 +00008If the first port is omitted, "0" is assumed; if the last is omitted,
9"65535" is assumed.
Ian Bruceae737f02009-06-06 06:04:24 +020010If the first port is greater than the second one they will be swapped.
Henrik Nordstromc2794132004-01-22 15:04:24 +000011The flag
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010012\fB\-\-sport\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000013is a convenient alias for this option.
14.TP
Frank Tobin156f5862009-05-21 05:09:00 +020015[\fB!\fP] \fB\-\-destination\-port\fP,\fB\-\-dport\fP \fIport\fP[\fB:\fP\fIport\fP]
Henrik Nordstromc2794132004-01-22 15:04:24 +000016Destination port or port range specification. The flag
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010017\fB\-\-dport\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000018is a convenient alias for this option.
19.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010020[\fB!\fP] \fB\-\-tcp\-flags\fP \fImask\fP \fIcomp\fP
Patrick McHardy510aef92008-06-02 12:48:48 +020021Match when the TCP flags are as specified. The first argument \fImask\fP is the
Henrik Nordstromc2794132004-01-22 15:04:24 +000022flags which we should examine, written as a comma-separated list, and
Patrick McHardy510aef92008-06-02 12:48:48 +020023the second argument \fIcomp\fP is a comma-separated list of flags which must be
Henrik Nordstromc2794132004-01-22 15:04:24 +000024set. Flags are:
25.BR "SYN ACK FIN RST URG PSH ALL NONE" .
26Hence the command
27.nf
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010028 iptables \-A FORWARD \-p tcp \-\-tcp\-flags SYN,ACK,FIN,RST SYN
Henrik Nordstromc2794132004-01-22 15:04:24 +000029.fi
30will only match packets with the SYN flag set, and the ACK, FIN and
31RST flags unset.
32.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010033[\fB!\fP] \fB\-\-syn\fP
Harald Welte38ed4212005-05-04 07:34:37 +000034Only match TCP packets with the SYN bit set and the ACK,RST and FIN bits
Henrik Nordstromc2794132004-01-22 15:04:24 +000035cleared. Such packets are used to request TCP connection initiation;
36for example, blocking such packets coming in an interface will prevent
37incoming TCP connections, but outgoing TCP connections will be
38unaffected.
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010039It is equivalent to \fB\-\-tcp\-flags SYN,RST,ACK,FIN SYN\fP.
40If the "!" flag precedes the "\-\-syn", the sense of the
Henrik Nordstromc2794132004-01-22 15:04:24 +000041option is inverted.
42.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010043[\fB!\fP] \fB\-\-tcp\-option\fP \fInumber\fP
Henrik Nordstromc2794132004-01-22 15:04:24 +000044Match if TCP option set.