'\" t .\" Title: shorewall6-tcrules .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.76.1 .\" Date: 10/19/2014 .\" Manual: Configuration Files .\" Source: Configuration Files .\" Language: English .\" .TH "SHOREWALL6\-TCRULES" "5" "10/19/2014" "Configuration Files" "Configuration Files" .\" ----------------------------------------------------------------- .\" * 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 \- Shorewall6 Packet Marking rules file .SH "SYNOPSIS" .HP \w'\fB/etc/shorewall6/tcrules\fR\ 'u \fB/etc/shorewall6/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]\fBshorewall6\-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/shorewall6/providers be sure to read the restrictions at \m[blue]\fBhttp://www\&.shorewall\&.net/MultiISP\&.html\fR\m[]\&\s-2\u[2]\d\s+2\&. .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 \fB[?]FORMAT {1|2}\fR .PP The optional \*(Aq?\*(Aq was introduced in Shorewall 4\&.5\&.11 and ?FORMAT is the preferred form; the form without the \*(Aq?\*(Aq is deprecated\&. .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 \- \fIaction\fR .RS 4 \fIaction\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 ip6tables; neither may be used with connection marks (see below)\&. .sp May optionally be followed by \fB:P\fR, \fB:F\fR or \fB:T\fR, \fB:I \fRwhere\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\&. The behavior changed in Shorewall6\-perl 4\&.1\&. Only high mark values may be assigned in this case\&. 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]\fBshorewall6\&.conf\fR\m[]\&\s-2\u[3]\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 ip6tables 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)\&. When a mask is specified, the result of logically ANDing the mark value with the mask must be the same as the mark value\&. .sp 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 connection 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 .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} A mark range which is a pair of integers separated by a dash ("\-")\&. Added in Shorewall 4\&.5\&.9\&. .sp May be optionally followed by a slash ("/") and a mask and requires the Statistics Match capability in iptables and kernel\&. Marks in the specified range are assigned to packets on a round\-robin fashion\&. .sp When a mask is specified, the result of logically ANDing each mark value with the mask must be the same as the mark value\&. The least significant bit in the mask is used as an increment\&. For example, if \*(Aq0x200\-0x400/0xff00\*(Aq is specified, then the assigned mark values are 0x200, 0x300 and 0x400 in equal proportions\&. If no mask is specified, then ( 2 ** MASK_BITS ) \- 1 is assumed (MASK_BITS is set in \m[blue]\fBshorewall6\&.conf\fR\m[]\&\s-2\u[3]\d\s+2(5))\&. .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]\fBshorewall6\&.conf\fR\m[]\&\s-2\u[3]\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 range may be optionally followed by "/" and a mask value (used to determine those bits of the connection mark to actually be set)\&. When a mask is specified, the result of logically ANDing the mark value with each of the masks must be the same as the mark value\&. .sp The mark range and optional mask may 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 connection 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 .RE .sp .RS 4 .ie n \{\ \h'-04' 3.\h'+01'\c .\} .el \{\ .sp -1 .IP " 3." 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 Shorewall6\*(Aqs built\-in traffic shaping tool, the \fImajor\fR class is the device number (the first device in \m[blue]\fBshorewall6\-tcdevices\fR\m[]\&\s-2\u[4]\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]\fBshorewall6\-tcclasses\fR\m[]\&\s-2\u[5]\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' 4.\h'+01'\c .\} .el \{\ .sp -1 .IP " 4." 4.2 .\} \fBCHECKSUM\fR .sp Added in Shorewall 4\&.5\&.9\&. Compute and fill in the checksum in a packet that lacks a checksum\&. This is particularly useful if you need to work around old applications, such as dhcp clients, that do not work well with checksum offloads, but you don\*(Aqt want to disable checksum offload in your device\&. .sp Requires \*(AqChecksum Target\*(Aq support in your kernel and ip6tables\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 5.\h'+01'\c .\} .el \{\ .sp -1 .IP " 5." 4.2 .\} \fB[?]COMMENT\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 \fBshorewall6 show mangle\fR .sp To stop the comment from being attached to further rules, simply include COMMENT on a line by itself\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBNote\fR .ps -1 .br Beginning with Shorewall 4\&.5\&.11, ?COMMENT is a synonym for COMMENT and is preferred\&. .sp .5v .RE .RE .sp .RS 4 .ie n \{\ \h'-04' 6.\h'+01'\c .\} .el \{\ .sp -1 .IP " 6." 4.2 .\} \fBCONTINUE\fR Don\*(Aqt process any more marking rules in 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 ip6tables/Netfilter provides the necessary support\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 7.\h'+01'\c .\} .el \{\ .sp -1 .IP " 7." 4.2 .\} \fBDIVERT\fR .sp Added in Shorewall 4\&.5\&.3\&. Two DIVERT rule should precede 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' 8.\h'+01'\c .\} .el \{\ .sp -1 .IP " 8." 4.2 .\} \fBDROP\fR .sp Added in Shorewall 4\&.5\&.21\&.4\&. Causes matching packets to be discarded\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 9.\h'+01'\c .\} .el \{\ .sp -1 .IP " 9." 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 To indicate more than one class, add their hex values together and specify the result\&. .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 .sp .RS 4 .ie n \{\ \h'-04'10.\h'+01'\c .\} .el \{\ .sp -1 .IP "10." 4.2 .\} \fBHL\fR([\fB\-\fR|\fB+\fR]\fInumber\fR) .sp Added in Shorewall 4\&.4\&.24\&. .sp Prior to Shorewall 4\&.5\&.7\&.2, may be optionally followed by \fB:F\fR but the resulting rule is always added to the FORWARD chain\&. Beginning with Shorewall 4\&.5\&.7\&.s, it may be optionally followed by \fB:P\fR, in which case the rule is added to the PREROUTING chain\&. .sp If \fB+\fR is included, packets matching the rule will have their HL (hop limit) incremented by \fInumber\fR\&. Similarly, if \fB\-\fR is included, matching packets have their HL decremented by \fInumber\fR\&. If neither \fB+\fR nor \fB\-\fR is given, the HL 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'11.\h'+01'\c .\} .el \{\ .sp -1 .IP "11." 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 ip6tables\&. .RE .sp .RS 4 .ie n \{\ \h'-04'12.\h'+01'\c .\} .el \{\ .sp -1 .IP "12." 4.2 .\} \fBINLINE\fR[(\fIaction\fR)] .sp Added in Shorewall 4\&.6\&.0\&. Allows you to place your own ip[6]tables matches at the end of the line following a semicolon (";")\&. If an \fIaction\fR is specified, the compiler procedes as if that \fIaction\fR had been specified in this column\&. If no action is specified, then you may include your own jump ("\-j \fItarget\fR [\fIoption\fR] \&.\&.\&.") after any matches specified at the end of the rule\&. If the target is not one known to Shorewall, then it must be defined as a builtin action in \m[blue]\fBshorewall6\-actions\fR\m[]\&\s-2\u[6]\d\s+2 (5)\&. .sp The following rules are equivalent: .sp .if n \{\ .RS 4 .\} .nf 2:P eth0 \- tcp 22 INLINE(2):P eth0 \- tcp 22 INLINE(2):P eth0 \- ; \-p tcp INLINE eth0 \- tcp 22 ; \-j MARK \-\-set\-mark 2 INLINE eth0 \- ; \-p tcp \-j MARK \-\-set\-mark 2 .fi .if n \{\ .RE .\} .sp If INLINE_MATCHES=Yes in \m[blue]\fBshorewall6\&.conf\fR\m[]\&\s-2\u[3]\d\s+2(5) then the third rule above can be specified as follows: .sp .if n \{\ .RS 4 .\} .nf 2:P eth0 \- ; \-p tcp .fi .if n \{\ .RE .\} .sp In other words, when only matches are given after the \*(Aq;\*(Aq, INLINE is unnecessary\&. .RE .sp .RS 4 .ie n \{\ \h'-04'13.\h'+01'\c .\} .el \{\ .sp -1 .IP "13." 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 ip6tables 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'14.\h'+01'\c .\} .el \{\ .sp -1 .IP "14." 4.2 .\} \fBSAME\fR (Added in Shorewall 4\&.3\&.5) \-\- 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'15.\h'+01'\c .\} .el \{\ .sp -1 .IP "15." 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 ip6tables 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'16.\h'+01'\c .\} .el \{\ .sp -1 .IP "16." 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 To indicate more than one class, add their hex values together and specify the result\&. .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 (default)\&. .RE .RE .sp .RS 4 .ie n \{\ \h'-04'17.\h'+01'\c .\} .el \{\ .sp -1 .IP "17." 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]\fBshorewall6\-providers\fR\m[]\&\s-2\u[7]\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]\fBshorewall6\-providers\fR\m[]\&\s-2\u[7]\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'18.\h'+01'\c .\} .el \{\ .sp -1 .IP "18." 4.2 .\} \fBTPROXY\fR([\fIport\fR][,[\fIaddress\fR]]]) \-\- FORMAT 2 .sp Transparently redirects a packet without altering the IP header\&. Requires a local provider to be defined in \m[blue]\fBshorewall6\-providers\fR\m[]\&\s-2\u[7]\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 .\} \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 .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 Source of the packet\&. A comma\-separated list of interface names, IP addresses, MAC addresses and/or subnets for packets being routed through a common path\&. List elements may also consist of an interface name followed by ":" and an address (e\&.g\&., eth1:<2002:ce7c:92b4::/48>)\&. For example, all packets for connections masqueraded to eth0 from other interfaces can be matched in a single rule with several alternative SOURCE criteria\&. However, a connection whose packets gets to eth0 in a different way, e\&.g\&., direct from the firewall itself, needs a different rule\&. .sp Accordingly, use $\fBFW\fR in its own separate rule for packets originating on the firewall\&. In such a rule, the ACTION column may NOT specify either \fB:P\fR or \fB:F\fR because marking for firewall\-originated packets always occurs in the OUTPUT chain\&. .sp MAC addresses must be prefixed with "~" and use "\-" as a separator\&. .sp Example: ~00\-A0\-C9\-15\-39\-78 .sp When an interface is not specified, the angled brackets (\*(Aq<\*(Aq and \*(Aq>\*(Aq) surrounding the address(es) may be omitted\&. .sp You may exclude certain hosts from the set already defined through use of an \fIexclusion\fR (see \m[blue]\fBshorewall6\-exclusion\fR\m[]\&\s-2\u[8]\d\s+2(5))\&. .RE .PP \fBDEST\fR \- {\fB\-\fR|{\fIinterface\fR|$FW}[{\fIinterface\fR|$FW}:]<\fIaddress\-or\-range\fR[\fB,\fR\fIaddress\-or\-range\fR]\&.\&.\&.}[\fIexclusion\fR]> .RS 4 Destination of the packet\&. Comma separated list of IP addresses and/or subnets\&. If your kernel and ip6tables include iprange match support, IP address ranges are also allowed\&. List elements may also consist of an interface name followed by ":" and an address (e\&.g\&., eth1:<2002:ce7c:92b4::/48>)\&. If the \fBACTION\fR column specifies a classification of the form \fImajor\fR:\fIminor\fR then this column may also contain an interface name\&. .sp When an interface is not specified, the angled brackets (\*(Aq<\*(Aq and \*(Aq>\*(Aq) surrounding the address(es) may be omitted\&. .sp Beginning with Shorewall 4\&.4\&.13, $FW may be given by itself or qualified by an address list\&. This causes marking to occur in the INPUT chain\&. .sp You may exclude certain hosts from the set already defined through use of an \fIexclusion\fR (see \m[blue]\fBshorewall6\-exclusion\fR\m[]\&\s-2\u[8]\d\s+2(5))\&. .RE .PP \fBPROTO\fR \- {\fB\-\fR|\fB{tcp: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 ip6tables\&. .sp Beginning with Shorewall 4\&.5\&.12, this column can accept a comma\-separated list of protocols\&. .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 \fBipv6\-icmp\fR, this column is interpreted as the destination icmp\-type(s)\&. ICMP types may be specified as a numeric type, a numeric 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[]\&\s-2\u[9]\d\s+2\&. .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 tcp (6), udp (17), ipv6\-icmp (58), 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\&. .sp Beginning with Shorewall 4\&.5\&.15, you may place \*(Aq=\*(Aq in this column, provided that the DEST PORT(S) column is non\-empty\&. This causes the rule to match when either the source port or the destination port in a packet matches one of the ports specified in DEST PORTS(S)\&. Use of \*(Aq=\*(Aq requires multi\-port match in your iptables and kernel\&. .RE .PP \fBUSER\fR \- [\fB!\fR][\fIuser\-name\-or\-number\fR][\fB:\fR\fIgroup\-name\-or\-number\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 .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 payload length\&. This field, if present allow you to match the length of a packet payload (Layer 4 data ) 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 (Optional) \- \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 \fBR\fR \- 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 Optional\&. Names a Netfilter 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\&. .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 ::/0 ::/0 TCP \- \- \- \- \- \- \- ftp .fi .if n \{\ .RE .\} .RE .PP \fBHEADERS \- [!][any:|exactly:]\fR\fIheader\-list \fR(Optional \- Added in Shorewall 4\&.4\&.15) .RS 4 The \fIheader\-list\fR consists of a comma\-separated list of headers from the following list\&. .PP \fBauth\fR, \fBah\fR, or \fB51\fR .RS 4 Authentication Headers extension header\&. .RE .PP \fBesp\fR, or \fB50\fR .RS 4 Encrypted Security Payload extension header\&. .RE .PP \fBhop\fR, \fBhop\-by\-hop\fR or \fB0\fR .RS 4 Hop\-by\-hop options extension header\&. .RE .PP \fBroute\fR, \fBipv6\-route\fR or \fB41\fR .RS 4 IPv6 Route extension header\&. .RE .PP \fBfrag\fR, \fBipv6\-frag\fR or \fB44\fR .RS 4 IPv6 fragmentation extension header\&. .RE .PP \fBnone\fR, \fBipv6\-nonxt\fR or \fB59\fR .RS 4 No next header .RE .PP \fBproto\fR, \fBprotocol\fR or \fB255\fR .RS 4 Any protocol header\&. .RE .sp If \fBany:\fR is specified, the rule will match if any of the listed headers are present\&. If \fBexactly:\fR is specified, the will match packets that exactly include all specified headers\&. If neither is given, \fBany:\fR is assumed\&. .sp If \fB!\fR is entered, the rule will match those packets which would not be matched when \fB!\fR is omitted\&. .RE .PP \fBPROBABILITY\fR \- [probability] .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 \fBSTATE\fR \-\- {\fBNEW\fR|\fBRELATED\fR|\fBESTABLISHED\fR|\fBINVALID\fR} [,\&.\&.\&.] .RS 4 Added in Shorewall 4\&.5\&.9\&. The rule will only match if the packet\*(Aqs connection is in one of the listed states\&. .RE .SH "EXAMPLE" .PP Example 1: .RS 4 Mark all forwarded ICMP echo traffic with packet mark 1\&. Mark all forwarded 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 ::/0 ::/0 icmp echo\-request 1 ::/0 ::/0 icmp echo\-reply RESTORE ::/0 ::/0 all \- \- \- 0 CONTINUE ::/0 ::/0 all \- \- \- !0 4 ::/0 ::/0 ipp2p:all SAVE ::/0 ::/0 all \- \- \- !0 .fi .if n \{\ .RE .\} .sp If a packet hasn\*(Aqt been classified (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/shorewall6/tcrules .SH "SEE ALSO" .PP \m[blue]\fBhttp://www\&.shorewall\&.net/traffic_shaping\&.htm\fR\m[]\&\s-2\u[10]\d\s+2 .PP \m[blue]\fBhttp://www\&.shorewall\&.net/MultiISP\&.html\fR\m[]\&\s-2\u[2]\d\s+2 .PP \m[blue]\fBhttp://www\&.shorewall\&.net/PacketMarking\&.html\fR\m[]\&\s-2\u[11]\d\s+2 .PP \m[blue]\fBhttp://www\&.shorewall\&.net/configuration_file_basics\&.htm#Pairs\fR\m[]\&\s-2\u[12]\d\s+2 .PP shorewall6(8), shorewall6\-accounting(5), shorewall6\-actions(5), shorewall6\-blacklist(5), shorewall6\-ecn(5), shorewall6\-exclusion(5), shorewall6\-hosts(5), shorewall6\-interfaces(5), shorewall6\-maclist(5), shorewall6\-netmap(5),shorewall6\-params(5), shorewall6\-policy(5), shorewall6\-providers(5), shorewall6\-rtrules(5), shorewall6\-routestopped(5), shorewall6\-rules(5), shorewall6\&.conf(5), shorewall6\-secmarks(5), shorewall6\-tcclasses(5), shorewall6\-tcdevices(5), shorewall6\-tos(5), shorewall6\-tunnels(5), shorewall6\-zones(5) .SH "NOTES" .IP " 1." 4 shorewall6-rules .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-rules.html .RE .IP " 2." 4 http://www.shorewall.net/MultiISP.html .RS 4 \%http://www.shorewall.net/MultiISP.html .RE .IP " 3." 4 shorewall6.conf .RS 4 \%http://www.shorewall.net/manpages6/shorewall6.conf.html .RE .IP " 4." 4 shorewall6-tcdevices .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-tcdevices.html .RE .IP " 5." 4 shorewall6-tcclasses .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-tcclasses.html .RE .IP " 6." 4 shorewall6-actions .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-actions.html .RE .IP " 7." 4 shorewall6-providers .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-providers.html .RE .IP " 8." 4 shorewall6-exclusion .RS 4 \%http://www.shorewall.net/manpages6/shorewall6-exclusion.html .RE .IP " 9." 4 http://www.shorewall.net/configuration_file_basics.htm#ICMP .RS 4 \%http://www.shorewall.net/configuration_file_basics.htm#ICMP .RE .IP "10." 4 http://www.shorewall.net/traffic_shaping.htm .RS 4 \%http://www.shorewall.net/traffic_shaping.htm .RE .IP "11." 4 http://www.shorewall.net/PacketMarking.html .RS 4 \%http://www.shorewall.net/PacketMarking.html .RE .IP "12." 4 http://www.shorewall.net/configuration_file_basics.htm#Pairs .RS 4 \%http://www.shorewall.net/configuration_file_basics.htm#Pairs .RE