'\" t .\" Title: shorewall-tcrules .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.75.2 .\" Date: 06/28/2012 .\" Manual: [FIXME: manual] .\" Source: [FIXME: source] .\" Language: English .\" .TH "SHOREWALL\-TCRULES" "5" "06/28/2012" "[FIXME: source]" "[FIXME: manual]" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" tcrules \- Shorewall Packet Marking rules file .SH "SYNOPSIS" .HP \w'\fB/etc/shorewall/tcrules\fR\ 'u \fB/etc/shorewall/tcrules\fR .SH "DESCRIPTION" .PP Entries in this file cause packets to be marked as a means of classifying them for traffic control or policy routing\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBImportant\fR .ps -1 .br .PP Unlike rules in the \m[blue]\fBshorewall\-rules\fR\m[]\&\s-2\u[1]\d\s+2(5) file, evaluation of rules in this file will continue after a match\&. So the final mark for each packet will be the one assigned by the LAST tcrule that matches\&. .PP If you use multiple internet providers with the \*(Aqtrack\*(Aq option, in /etc/shorewall/providers be sure to read the restrictions at \m[blue]\fBhttp://shorewall\&.net/MultiISP\&.html\fR\m[]\&. .sp .5v .RE .PP Beginning with Shorewall 4\&.5\&.4, the tcrules file supports two different formats: .PP FORMAT 1 (default \- deprecated) .RS 4 The older limited\-function version of TPROXY is supported\&. .RE .PP FORMAT 2 .RS 4 The newer version of TPROXY is supported\&. .RE .PP The format is specified by a line as follows: .PP \fBFORMAT {1|2}\fR .PP The columns in the file are as follows (where the column name is followed by a different name in parentheses, the different name is used in the alternate specification syntax)\&. .PP \fBACTION\fR (mark) \- \fImark\fR .RS 4 Where \fImark\fR may assume one of the following values\&. .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} A mark \fIvalue\fR which is an integer in the range 1\-255\&. .sp Normally will set the mark value\&. If preceded by a vertical bar ("|"), the mark value will be logically ORed with the current mark value to produce a new mark value\&. If preceded by an ampersand ("&"), will be logically ANDed with the current mark value to produce a new mark value\&. .sp Both "|" and "&" require Extended MARK Target support in your kernel and iptables; neither may be used with connection marks (see below)\&. .sp May optionally be followed by \fB:P\fR, \fB:F\fR,\fB:T\fR or \fB:I\fR where\fB :P\fR indicates that marking should occur in the PREROUTING chain, \fB:F\fR indicates that marking should occur in the FORWARD chain, \fB:I \fRindicates that marking should occur in the INPUT chain (added in Shorewall 4\&.4\&.13), and \fB:T\fR indicates that marking should occur in the POSTROUTING chain\&. If neither \fB:P\fR, \fB:F\fR nor \fB:T\fR follow the mark value then the chain is determined as follows: .sp \- If the SOURCE is \fB$FW\fR[\fB:\fR\fIaddress\-or\-range\fR[,\fIaddress\-or\-range\fR]\&.\&.\&.], then the rule is inserted into the OUTPUT chain\&. When HIGH_ROUTE_MARKS=Yes, only high mark values may be assigned there\&. Packet marking rules for traffic shaping of packets originating on the firewall must be coded in the POSTROUTING chain (see below)\&. .sp \- Otherwise, the chain is determined by the setting of MARK_IN_FORWARD_CHAIN in \m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[2]\d\s+2(5)\&. .sp Please note that \fB:I\fR is included for completeness and affects neither traffic shaping nor policy routing\&. .sp If your kernel and iptables include CONNMARK support then you can also mark the connection rather than the packet\&. .sp The mark value may be optionally followed by "/" and a mask value (used to determine those bits of the connection mark to actually be set)\&. The mark and optional mask are then followed by one of: .PP \fBC\fR .RS 4 Mark the connection in the chain determined by the setting of MARK_IN_FORWARD_CHAIN .RE .PP \fBCF\fR .RS 4 Mark the connection in the FORWARD chain .RE .PP \fBCP\fR .RS 4 Mark the connection in the PREROUTING chain\&. .RE .PP CT .RS 4 Mark the connecdtion in the POSTROUTING chain .RE .PP CI .RS 4 Mark the connection in the INPUT chain\&. This option is included for completeness and has no applicability to traffic shaping or policy routing\&. .RE .sp \fBSpecial considerations for If HIGH_ROUTE_MARKS=Yes in \fR\fB\m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[2]\d\s+2\fR\fB(5\fR)\&. .sp If HIGH_ROUTE_MARKS=Yes, then you may also specify a value in the range 0x0100\-0xFF00 with the low\-order byte being zero\&. Such values may only be used in the PREROUTING chain (value followed by \fB:P\fR or you have set MARK_IN_FORWARD_CHAIN=No in \m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[2]\d\s+2(5) and have not followed the value with \fB:F\fR) or the OUTPUT chain (SOURCE is \fB$FW\fR)\&. With HIGH_ROUTE_MARKS=Yes, non\-zero mark values less that 256 are not permitted\&. Shorewall prohibits non\-zero mark values less that 256 in the OUTPUT chain when HIGH_ROUTE_MARKS=Yes\&. While earlier versions allow such values in the OUTPUT chain, it is strongly recommended that with HIGH_ROUTE_MARKS=Yes, you use the POSTROUTING chain to apply traffic shaping marks/classification\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} A classification Id (classid) of the form \fImajor\fR:\fIminor\fR where \fImajor\fR and \fIminor\fR are integers\&. Corresponds to the \*(Aqclass\*(Aq specification in these traffic shaping modules: .sp .if n \{\ .RS 4 .\} .nf atm cbq dsmark pfifo_fast htb prio .fi .if n \{\ .RE .\} .sp Classification occurs in the POSTROUTING chain except when the \fBSOURCE\fR is \fB$FW\fR[:\fIaddress\fR] in which case classification occurs in the OUTPUT chain\&. .sp When using Shorewall\*(Aqs built\-in traffic shaping tool, the \fImajor\fR class is the device number (the first device in \m[blue]\fBshorewall\-tcdevices\fR\m[]\&\s-2\u[3]\d\s+2(5) is major class 1, the second device is major class 2, and so on) and the \fIminor\fR class is the class\*(Aqs MARK value in \m[blue]\fBshorewall\-tcclasses\fR\m[]\&\s-2\u[4]\d\s+2(5) preceded by the number 1 (MARK 1 corresponds to minor class 11, MARK 5 corresponds to minor class 15, MARK 22 corresponds to minor class 122, etc\&.)\&. .sp Beginning with Shorewall 4\&.4\&.27, the classid may be optionally followed by \*(Aq:\*(Aq and a capital letter designating the chain where classification is to occur\&. .PP F .RS 4 FORWARD chain\&. .RE .PP T .RS 4 POSTROUTING chain (default)\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} \fBRESTORE\fR[/\fImask\fR] \-\- restore the packet\*(Aqs mark from the connection\*(Aqs mark using the supplied mask if any\&. Your kernel and iptables must include CONNMARK support\&. .sp As in 1) above, may be followed by \fB:P\fR or \fB:F\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} \fBSAVE\fR[/\fImask\fR] \-\- save the packet\*(Aqs mark to the connection\*(Aqs mark using the supplied mask if any\&. Your kernel and iptables must include CONNMARK support\&. .sp As in 1) above, may be followed by \fB:P\fR or \fB:F\fR .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} \fBCONTINUE\fR Don\*(Aqt process any more marking rules \(enin the table\&. .sp As in 1) above, may be followed by \fB:P\fR or \fB:F\fR\&. Currently, CONTINUE may not be used with \fIexclusion\fR (see the SOURCE and DEST columns below); that restriction will be removed when iptables/Netfilter provides the necessary support\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} \fBSAME\fR Some websites run applications that require multiple connections from a client browser\&. Where multiple \*(Aqbalanced\*(Aq providers are configured, this can lead to problems when some of the connections are routed through one provider and some through another\&. The SAME target allows you to work around that problem\&. SAME may be used in the PREROUTING and OUTPUT chains\&. When used in PREROUTING, it causes matching connections from an individual local system to all use the same provider\&. For example: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST PROTO DEST # PORT(S) SAME:P 192\&.168\&.1\&.0/24 0\&.0\&.0\&.0/0 tcp 80,443 .fi .if n \{\ .RE .\} .sp If a host in 192\&.168\&.1\&.0/24 attempts a connection on TCP port 80 or 443 and it has sent a packet on either of those ports in the last five minutes then the new connection will use the same provider as the connection over which that last packet was sent\&. .sp When used in the OUTPUT chain, it causes all matching connections to an individual remote system to all use the same provider\&. For example: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST PROTO DEST # PORT(S) SAME $FW 0\&.0\&.0\&.0/0 tcp 80,443 .fi .if n \{\ .RE .\} .sp If the firewall attempts a connection on TCP port 80 or 443 and it has sent a packet on either of those ports in the last five minutes to the same remote system then the new connection will use the same provider as the connection over which that last packet was sent\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} \fBCOMMENT\fR \-\- the rest of the line will be attached as a comment to the Netfilter rule(s) generated by the following entries\&. The comment will appear delimited by "/* \&.\&.\&. */" in the output of \fBshorewall show mangle\fR .sp To stop the comment from being attached to further rules, simply include COMMENT on a line by itself\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 8.\h'+01'\c .\} .el \{\ .sp -1 .IP " 8." 4.2 .\} \fBIPMARK\fR \(en Assigns a mark to each matching packet based on the either the source or destination IP address\&. By default, it assigns a mark value equal to the low\-order 8 bits of the source address\&. Default values are: .RS 4 src .RE .RS 4 \fImask1\fR = 0xFF .RE .RS 4 \fImask2\fR = 0x00 .RE .RS 4 \fIshift\fR = 0 .RE \*(Aqsrc\*(Aq and \*(Aqdst\*(Aq specify whether the mark is to be based on the source or destination address respectively\&. The selected address is first shifted to the right by \fIshift\fR bits\&. The result is then LANDed with \fImask1\fR then LORed with \fIma\fR\fI\fIs\fR\fR\fIk2\fR\&. .sp In a sense, the IPMARK target is more like an IPCLASSIFY target in that the mark value is later interpreted as a class ID\&. A packet mark is 32 bits wide; so is a class ID\&. The class occupies the high\-order 16 bits and the class occupies the low\-order 16 bits\&. So the class ID 1:4ff (remember that class IDs are always in hex) is equivalent to a mark value of 0x104ff\&. Remember that Shorewall uses the interface number as the number where the first interface in tcdevices has number 1, the second has number 2, and so on\&. .sp The IPMARK target assigns a mark to each matching packet based on the either the source or destination IP address\&. By default, it assigns a mark value equal to the low\-order 8 bits of the source address\&. The syntax is as follows: \fBIPMARK\fR[([{\fBsrc\fR|\fBdst\fR}][,[\fImask1\fR][,[\fImask2\fR][,[\fIshift\fR]]]])] Default values are: .RS 4 \fBsrc\fR .RE .RS 4 \fImask1\fR = 0xFF .RE .RS 4 \fImask2\fR = 0x00 .RE .RS 4 \fIshift\fR = 0 .RE \fBsrc\fR and \fBdst\fR specify whether the mark is to be based on the source or destination address respectively\&. The selected address is first shifted right by \fIshift\fR, then LANDed with \fImask1\fR and then LORed with \fImask2\fR\&. The \fIshift\fR argument is intended to be used primarily with IPv6 addresses\&. .sp Example: IPMARK(src,0xff,0x10100) .RS 4 Suppose that the source IP address is 192\&.168\&.4\&.3 = 0xc0a80403; then .RE .RS 4 0xc0a80403 >> 0 = 0xc0a80403 .RE .RS 4 0xc0a80403 LAND 0xFF = 0x03 .RE .RS 4 0x03 LOR 0x0x10100 = 0x10103 or class ID 1:103 .RE It is important to realize that, while class IDs are composed of a \fImajor\fR and a \fIminor\fR value, the set of values must be unique\&. That is, the same numeric value cannot be used as both a \fImajor\fR and a \fIminor\fR number for the same interface unless class nesting occurs (which is not currently possible with Shorewall)\&. You should keep this in mind when deciding how to map IP addresses to class IDs\&. .sp For example, suppose that your internal network is 192\&.168\&.1\&.0/29 (host IP addresses 192\&.168\&.1\&.1 \- 192\&.168\&.1\&.6)\&. Your first notion might be to use IPMARK(src,0xFF,0x10000) so as to produce class IDs 1:1 through 1:6\&. But 1:1 is an invalid class ID since the \fImajor\fR and \fIminor\fR classes are equal\&. So you might chose instent to use IPMARK(src,0xFF,0x10100) as in the example above so that all of your \fIminor\fR classes will have a value > 256\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 9.\h'+01'\c .\} .el \{\ .sp -1 .IP " 9." 4.2 .\} \fBDIVERT\fR .sp Added in Shorewall 4\&.5\&.4 and only available when FORMAT is 2\&. Two DIVERT rule should preceed the TPROXY rule and should select DEST PORT tcp 80 and SOURCE PORT tcp 80 respectively (assuming that tcp port 80 is being proxied)\&. DIVERT avoids sending packets to the TPROXY target once a socket connection to Squid3 has been established by TPROXY\&. DIVERT marks the packet with a unique mark and exempts it from any rules that follow\&. .RE .sp .RS 4 .ie n \{\ \h'-04'10.\h'+01'\c .\} .el \{\ .sp -1 .IP "10." 4.2 .\} \fBTPROXY\fR(\fImark\fR[,[\fIport\fR][,[\fIaddress\fR]]]) \-\- FORMAT 1 .sp Transparently redirects a packet without altering the IP header\&. Requires a local provider to be defined in \m[blue]\fBshorewall\-providers\fR\m[]\&\s-2\u[5]\d\s+2(5)\&. .sp There are three parameters to TPROXY \- only the first (mark) is required: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fImark\fR \- the MARK value corresponding to the local provider in \m[blue]\fBshorewall\-providers\fR\m[]\&\s-2\u[5]\d\s+2(5)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIport\fR \- the port on which the proxy server is listening\&. If omitted, the original destination port\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIaddress\fR \- a local (to the firewall) IP address on which the proxy server is listening\&. If omitted, the IP address of the interface on which the request arrives\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'11.\h'+01'\c .\} .el \{\ .sp -1 .IP "11." 4.2 .\} \fBTPROXY\fR([\fIport\fR][,\fIaddress\fR]) \-\- FORMAT 2 .sp Transparently redirects a packet without altering the IP header\&. Requires a tproxy provider to be defined in \m[blue]\fBshorewall\-providers\fR\m[]\&\s-2\u[5]\d\s+2(5)\&. .sp There are three parameters to TPROXY \- neither is required: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIport\fR \- the port on which the proxy server is listening\&. If omitted, the original destination port\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} \fIaddress\fR \- a local (to the firewall) IP address on which the proxy server is listening\&. If omitted, the IP address of the interface on which the request arrives\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'12.\h'+01'\c .\} .el \{\ .sp -1 .IP "12." 4.2 .\} \fBTTL\fR([\fB\-\fR|\fB+\fR]\fInumber\fR) .sp Added in Shorewall 4\&.4\&.24\&. May be option followed by \fB:F\fR but the resulting rule is always added to the FORWARD chain\&. If \fB+\fR is included, packets matching the rule will have their TTL incremented by \fInumber\fR\&. Similarly, if \fB\-\fR is included, matching packets have their TTL decremented by \fInumber\fR\&. If neither \fB+\fR nor \fB\-\fR is given, the TTL of matching packets is set to \fInumber\fR\&. The valid range of values for \fInumber\fR is 1\-255\&. .RE .sp .RS 4 .ie n \{\ \h'-04'13.\h'+01'\c .\} .el \{\ .sp -1 .IP "13." 4.2 .\} \fBIMQ\fR(\fInumber\fR) .sp Added in Shorewall 4\&.5\&.1\&. Specifies that the packet should be passed to the IMQ identified by \fInumber\fR\&. Requires IMQ Target support in your kernel and iptables\&. .RE .sp .RS 4 .ie n \{\ \h'-04'14.\h'+01'\c .\} .el \{\ .sp -1 .IP "14." 4.2 .\} \fBDSCP\fR(\fIdscp\fR) .sp Added in Shorewall 4\&.5\&.1\&. Sets the Differentiated Services Code Point field in the IP header\&. The \fIdscp\fR value may be given as an even number (hex or decimal) or as the name of a DSCP class\&. Valid class names and their associated hex numeric values are: .sp .if n \{\ .RS 4 .\} .nf CS0 => 0x00 CS1 => 0x08 CS2 => 0x10 CS3 => 0x18 CS4 => 0x20 CS5 => 0x28 CS6 => 0x30 CS7 => 0x38 BE => 0x00 AF11 => 0x0a AF12 => 0x0c AF13 => 0x0e AF21 => 0x12 AF22 => 0x14 AF23 => 0x16 AF31 => 0x1a AF32 => 0x1c AF33 => 0x1e AF41 => 0x22 AF42 => 0x24 AF43 => 0x26 EF => 0x2e .fi .if n \{\ .RE .\} .sp May be optionally followed by \*(Aq:\*(Aq and a capital letter designating the chain where classification is to occur\&. .PP F .RS 4 FORWARD chain\&. .RE .PP T .RS 4 POSTROUTING chain (default)\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'15.\h'+01'\c .\} .el \{\ .sp -1 .IP "15." 4.2 .\} \fBTOS\fR(\fItos\fR[/\fImask\fR]) .sp Added in Shorewall 4\&.5\&.1\&. Sets the Type of Service field in the IP header\&. The \fItos\fR value may be given as an number (hex or decimal) or as the name of a TOS type\&. Valid type names and their associated hex numeric values are: .sp .if n \{\ .RS 4 .\} .nf Minimize\-Delay => 0x10, Maximize\-Throughput => 0x08, Maximize\-Reliability => 0x04, Minimize\-Cost => 0x02, Normal\-Service => 0x00 .fi .if n \{\ .RE .\} .sp When \fItos\fR is given as a number, it may be optionally followed by \*(Aq/\*(Aq and a \fImask\fR\&. When no \fImask\fR is given, the value 0xff is assumed\&. When \fItos\fR is given as a type name, the \fImask\fR 0x3f is assumed\&. .sp The action performed is to zero out the bits specified by the \fImask\fR, then set the bits specified by \fItos\fR\&. .sp May be optionally followed by \*(Aq:\*(Aq and a capital letter designating the chain where classification is to occur\&. .PP F .RS 4 FORWARD chain\&. .RE .PP T .RS 4 POSTROUTING chain\&. .RE .RE .RE .PP \fBSOURCE\fR \- {\fB\-\fR|{\fIinterface\fR|\fB$FW\fR}|[{\fIinterface\fR|\fB$FW\fR}:]\fIaddress\-or\-range\fR[\fB,\fR\fIaddress\-or\-range\fR]\&.\&.\&.}[\fIexclusion\fR] .RS 4 May be: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} An interface name \- matches traffic entering the firewall on the specified interface\&. May not be used in classify rules or in rules using the :T chain qualifier\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} A comma\-separated list of host or network IP addresses or MAC addresses\&. \fBThis form will not match traffic that originates on the firewall itself unless either or the :T chain qualifier is used in the ACTION column\&.\fR .sp Examples:.RS 4 0\&.0\&.0\&.0/0 .RE .sp .RS 4 192\&.168\&.1\&.0/24, 172\&.20\&.4\&.0/24 .RE .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} An interface name followed by a colon (":") followed by a comma\-separated list of host or network IP addresses or MAC addresses\&. May not be used in classify rules or in rules using the :T chain qualifier\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} $FW optionally followed by a colon (":") and a comma\-separated list of host or network IP addresses\&. Matches packets originating on the firewall\&. May not be used with a chain qualifier (:P, :F, etc\&.) in the ACTION column\&. .RE .sp MAC addresses must be prefixed with "~" and use "\-" as a separator\&. .sp Example: ~00\-A0\-C9\-15\-39\-78 .sp You may exclude certain hosts from the set already defined through use of an \fIexclusion\fR (see \m[blue]\fBshorewall\-exclusion\fR\m[]\&\s-2\u[6]\d\s+2(5))\&. .RE .PP \fBDEST\fR \- {\fB\-\fR|{\fIinterface\fR|$FW}|[\fI{interface\fR|$FW}:]\fIaddress\-or\-range\fR[\fB,\fR\fIaddress\-or\-range\fR]\&.\&.\&.}[\fIexclusion\fR] .RS 4 May be: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} An interface name\&. May not be used in the PREROUTING chain (:P in the mark column or no chain qualifier and MARK_IN_FORWARD_CHAIN=No in \m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[7]\d\s+2 (5))\&. The interface name may be optionally followed by a colon (":") and an IP address list\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} A comma\-separated list of host or network IP addresses\&. The list may include ip address ranges if your kernel and iptables include iprange support\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 4.2 .\} Beginning with Shorewall 4\&.4\&.13, $FW may be specified by itself or qualified by an address list\&. This causes marking to occur in the INPUT chain\&. .RE .sp You may exclude certain hosts from the set already defined through use of an \fIexclusion\fR (see \m[blue]\fBshorewall\-exclusion\fR\m[]\&\s-2\u[6]\d\s+2(5))\&. .RE .PP \fBPROTO\fR \- {\fB\-\fR|\fBtcp:syn\fR|\fBipp2p\fR|\fBipp2p:udp\fR|\fBipp2p:all\fR|\fIprotocol\-number\fR|\fIprotocol\-name\fR|\fBall}\fR .RS 4 Protocol \- \fBipp2p\fR requires ipp2p match support in your kernel and iptables\&. .RE .PP \fBPORT(S)\fR (dport) \- [\fB\-\fR|\fIport\-name\-number\-or\-range\fR[\fB,\fR\fIport\-name\-number\-or\-range\fR]\&.\&.\&.] .RS 4 Optional destination Ports\&. A comma\-separated list of Port names (from services(5)), \fIport number\fRs or \fIport range\fRs; if the protocol is \fBicmp\fR, this column is interpreted as the destination icmp\-type(s)\&. ICMP types may be specified as a numeric type, a numberic type and code separated by a slash (e\&.g\&., 3/4), or a typename\&. See \m[blue]\fBhttp://www\&.shorewall\&.net/configuration_file_basics\&.htm#ICMP\fR\m[]\&. .sp If the protocol is \fBipp2p\fR, this column is interpreted as an ipp2p option without the leading "\-\-" (example \fBbit\fR for bit\-torrent)\&. If no PORT is given, \fBipp2p\fR is assumed\&. .sp An entry in this field requires that the PROTO column specify icmp (1), tcp (6), udp (17), sctp (132) or udplite (136)\&. Use \*(Aq\-\*(Aq if any of the following field is supplied\&. .RE .PP \fBSOURCE PORT(S)\fR (sport) \- [\fB\-\fR|\fIport\-name\-number\-or\-range\fR[\fB,\fR\fIport\-name\-number\-or\-range\fR]\&.\&.\&.] .RS 4 Optional source port(s)\&. If omitted, any source port is acceptable\&. Specified as a comma\-separated list of port names, port numbers or port ranges\&. .sp An entry in this field requires that the PROTO column specify tcp (6), udp (17), sctp (132) or udplite (136)\&. Use \*(Aq\-\*(Aq if any of the following fields is supplied\&. .RE .PP \fBUSER\fR \- [\fB!\fR][\fIuser\-name\-or\-number\fR][\fB:\fR\fIgroup\-name\-or\-number\fR][\fB+\fR\fIprogram\-name\fR] .RS 4 This optional column may only be non\-empty if the SOURCE is the firewall itself\&. .sp When this column is non\-empty, the rule applies only if the program generating the output is running under the effective \fIuser\fR and/or \fIgroup\fR specified (or is NOT running under that id if "!" is given)\&. .sp Examples: .PP joe .RS 4 program must be run by joe .RE .PP :kids .RS 4 program must be run by a member of the \*(Aqkids\*(Aq group .RE .PP !:kids .RS 4 program must not be run by a member of the \*(Aqkids\*(Aq group .RE .PP +upnpd .RS 4 #program named upnpd .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBImportant\fR .ps -1 .br The ability to specify a program name was removed from Netfilter in kernel version 2\&.6\&.14\&. .sp .5v .RE .RE .RE .PP \fBTEST\fR \- [\fB!\fR]\fIvalue\fR[/\fImask\fR][\fB:C\fR] .RS 4 Optional \- Defines a test on the existing packet or connection mark\&. The rule will match only if the test returns true\&. .sp If you don\*(Aqt want to define a test but need to specify anything in the following columns, place a "\-" in this field\&. .PP ! .RS 4 Inverts the test (not equal) .RE .PP \fIvalue\fR .RS 4 Value of the packet or connection mark\&. .RE .PP \fImask\fR .RS 4 A mask to be applied to the mark before testing\&. .RE .PP \fB:C\fR .RS 4 Designates a connection mark\&. If omitted, the packet mark\*(Aqs value is tested\&. .RE .RE .PP \fBLENGTH\fR \- [\fIlength\fR|[\fImin\fR]\fB:\fR[\fImax\fR]] .RS 4 Optional \- packet Length\&. This field, if present allow you to match the length of a packet against a specific value or range of values\&. You must have iptables length support for this to work\&. A range is specified in the form \fImin\fR:\fImax\fR where either \fImin\fR or \fImax\fR (but not both) may be omitted\&. If \fImin\fR is omitted, then 0 is assumed; if \fImax\fR is omitted, than any packet that is \fImin\fR or longer will match\&. .RE .PP \fBTOS\fR \- \fItos\fR .RS 4 Type of service\&. Either a standard name, or a numeric value to match\&. .sp .if n \{\ .RS 4 .\} .nf \fBMinimize\-Delay\fR (16) \fBMaximize\-Throughput\fR (8) \fBMaximize\-Reliability\fR (4) \fBMinimize\-Cost\fR (2) \fBNormal\-Service\fR (0) .fi .if n \{\ .RE .\} .RE .PP \fBCONNBYTES\fR \- [!]\fImin\fR:[\fImax\fR[:{\fBO\fR|\fBR\fR|\fBB\fR}[:{\fBB\fR|\fBP\fR|\fBA\fR}]]] .RS 4 Optional connection Bytes; defines a byte or packet range that the connection must fall within in order for the rule to match\&. .sp A packet matches if the the packet/byte count is within the range defined by \fImin\fR and \fImax\fR (unless ! is given in which case, a packet matches if the packet/byte count is not within the range)\&. \fImin\fR is an integer which defines the beginning of the byte/packet range\&. \fImax\fR is an integer which defines the end of the byte/packet range; if omitted, only the beginning of the range is checked\&. The first letter gives the direction which the range refers to:\fBO\fR \- The original direction of the connection\&. .sp \- The opposite direction from the original connection\&. .sp \fBB\fR \- The total of both directions\&. .sp If omitted, \fBB\fR is assumed\&. .sp The second letter determines what the range refers to\&.\fBB\fR \- Bytes .sp \fBP\fR \- Packets .sp \fBA\fR \- Average packet size\&.If omitted, \fBB\fR is assumed\&. .RE .PP \fBHELPER \- \fR\fIhelper\fR .RS 4 Names a Netfiler protocol helper module such as \fBftp\fR, \fBsip\fR, \fBamanda\fR, etc\&. A packet will match if it was accepted by the named helper module\&. You can also append "\-" and a port number to the helper module name (e\&.g\&., \fBftp\-21\fR) to specify the port number that the original connection was made on\&. .sp Example: Mark all FTP data connections with mark 4: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST LENGTH TOS CONNBYTES HELPER # PORT(S) 4:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 TCP \- \- \- \- \- \- \- ftp .fi .if n \{\ .RE .\} .RE .PP \fBPROBABILITY\fR \- [\fIprobability\fR] .RS 4 Added in Shorewall 4\&.5\&.0\&. When non\-empty, requires the Statistics Match capability in your kernel and ip6tables and causes the rule to match randomly but with the given \fIprobability\fR\&. The \fIprobability\fR is a number 0 < \fIprobability\fR <= 1 and may be expressed at up to 8 decimal points of precision\&. .RE .PP \fBDSCP \-\fR [[!]\fIdscp\fR] .RS 4 Added in Shorewall 4\&.5\&.1\&. When non\-empty, match packets whose Differentiated Service Code Point field matches the supplied value (when \*(Aq!\*(Aq is given, the rule matches packets whose DSCP field does not match the supplied value)\&. The \fIdscp\fR value may be given as an even number (hex or decimal) or as the name of a DSCP class\&. Valid class names and their associated hex numeric values are: .sp .if n \{\ .RS 4 .\} .nf CS0 => 0x00 CS1 => 0x08 CS2 => 0x10 CS3 => 0x18 CS4 => 0x20 CS5 => 0x28 CS6 => 0x30 CS7 => 0x38 BE => 0x00 AF11 => 0x0a AF12 => 0x0c AF13 => 0x0e AF21 => 0x12 AF22 => 0x14 AF23 => 0x16 AF31 => 0x1a AF32 => 0x1c AF33 => 0x1e AF41 => 0x22 AF42 => 0x24 AF43 => 0x26 EF => 0x2e .fi .if n \{\ .RE .\} .RE .SH "EXAMPLE" .PP Example 1: .RS 4 Mark all ICMP echo traffic with packet mark 1\&. Mark all peer to peer traffic with packet mark 4\&. .sp This is a little more complex than otherwise expected\&. Since the ipp2p module is unable to determine all packets in a connection are P2P packets, we mark the entire connection as P2P if any of the packets are determined to match\&. .sp We assume packet/connection mark 0 means unclassified\&. .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST # PORT(S) 1:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 icmp echo\-request 1:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 icmp echo\-reply RESTORE:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 all \- \- \- 0 CONTINUE:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 all \- \- \- !0 4:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 ipp2p:all SAVE:T 0\&.0\&.0\&.0/0 0\&.0\&.0\&.0/0 all \- \- \- !0 .fi .if n \{\ .RE .\} .sp If a packet hasn\*(Aqt been classifed (packet mark is 0), copy the connection mark to the packet mark\&. If the packet mark is set, we\*(Aqre done\&. If the packet is P2P, set the packet mark to 4\&. If the packet mark has been set, save it to the connection mark\&. .RE .SH "FILES" .PP /etc/shorewall/tcrules .SH "SEE ALSO" .PP \m[blue]\fBhttp://shorewall\&.net/traffic_shaping\&.htm\fR\m[] .PP \m[blue]\fBhttp://shorewall\&.net/MultiISP\&.html\fR\m[] .PP \m[blue]\fBhttp://shorewall\&.net/PacketMarking\&.html\fR\m[] .PP \m[blue]\fBhttp://shorewall\&.net/configuration_file_basics\&.htm#Pairs\fR\m[] .PP shorewall(8), shorewall\-accounting(5), shorewall\-actions(5), shorewall\-blacklist(5), shorewall\-ecn(5), shorewall\-exclusion(5), shorewall\-hosts(5), shorewall_interfaces(5), shorewall\-ipsets(5), shorewall\-maclist(5), shorewall\-masq(5), shorewall\-nat(5), shorewall\-netmap(5), shorewall\-params(5), shorewall\-policy(5), shorewall\-providers(5), shorewall\-proxyarp(5), shorewall\-rtrules(5), shorewall\-routestopped(5), shorewall\-rules(5), shorewall\&.conf(5), shorewall\-secmarks(5), shorewall\-tcclasses(5), shorewall\-tcdevices(5), shorewall\-tos(5), shorewall\-tunnels(5), shorewall\-zones(5) .SH "NOTES" .IP " 1." 4 shorewall-rules .RS 4 \%http://www.shorewall.net/manpages/shorewall-rules.html .RE .IP " 2." 4 shorewall.conf .RS 4 \%http://www.shorewall.net/manpages/shorewall.conf.html .RE .IP " 3." 4 shorewall-tcdevices .RS 4 \%http://www.shorewall.net/manpages/shorewall-tcdevices.html .RE .IP " 4." 4 shorewall-tcclasses .RS 4 \%http://www.shorewall.net/manpages/shorewall-tcclasses.html .RE .IP " 5." 4 shorewall-providers .RS 4 \%http://www.shorewall.net/manpages/shorewall-providers.html .RE .IP " 6." 4 shorewall-exclusion .RS 4 \%http://www.shorewall.net/manpages/shorewall-exclusion.html .RE .IP " 7." 4 shorewall.conf .RS 4 \%http://www.shorewall.net/manpages/shorewall.conf .RE