| 1 |
.TH "Firewall mark classifier in tc" 8 "21 Oct 2015" "iproute2" "Linux" |
| 2 |
|
| 3 |
.SH NAME |
| 4 |
fw \- fwmark traffic control filter |
| 5 |
.SH SYNOPSIS |
| 6 |
.in +8 |
| 7 |
.ti -8 |
| 8 |
.BR tc " " filter " ... " fw " [ " classid |
| 9 |
.IR CLASSID " ] [ " |
| 10 |
.B action |
| 11 |
.IR ACTION_SPEC " ]" |
| 12 |
.SH DESCRIPTION |
| 13 |
the |
| 14 |
.B fw |
| 15 |
filter allows one to classify packets based on a previously set |
| 16 |
.BR fwmark " by " iptables . |
| 17 |
If the masked value of the |
| 18 |
.B fwmark |
| 19 |
matches the filter's masked |
| 20 |
.BR handle , |
| 21 |
the filter matches. By default, all 32 bits of the |
| 22 |
.B handle |
| 23 |
and the |
| 24 |
.B fwmark |
| 25 |
are masked. |
| 26 |
.B iptables |
| 27 |
allows one to mark single packets with the |
| 28 |
.B MARK |
| 29 |
target, or whole connections using |
| 30 |
.BR CONNMARK . |
| 31 |
The benefit of using this filter instead of doing the |
| 32 |
heavy-lifting with |
| 33 |
.B tc |
| 34 |
itself is that on one hand it might be convenient to keep packet filtering and |
| 35 |
classification in one place, possibly having to match a packet just once, and on |
| 36 |
the other users familiar with |
| 37 |
.BR iptables " but not " tc |
| 38 |
will have a less hard time adding QoS to their setups. |
| 39 |
.SH OPTIONS |
| 40 |
.TP |
| 41 |
.BI classid " CLASSID" |
| 42 |
Push matching packets to the class identified by |
| 43 |
.IR CLASSID . |
| 44 |
.TP |
| 45 |
.BI action " ACTION_SPEC" |
| 46 |
Apply an action from the generic actions framework on matching packets. |
| 47 |
.SH EXAMPLES |
| 48 |
Take e.g. the following tc filter statement: |
| 49 |
|
| 50 |
.RS |
| 51 |
.EX |
| 52 |
tc filter add ... handle 6 fw classid 1:1 |
| 53 |
.EE |
| 54 |
.RE |
| 55 |
|
| 56 |
will match if the packet's |
| 57 |
.B fwmark |
| 58 |
value is |
| 59 |
.BR 6 . |
| 60 |
This is a sample |
| 61 |
.B iptables |
| 62 |
statement marking packets coming in on eth0: |
| 63 |
|
| 64 |
.RS |
| 65 |
.EX |
| 66 |
iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 6 |
| 67 |
.EE |
| 68 |
.RE |
| 69 |
|
| 70 |
Specific bits of the packet's |
| 71 |
.B fwmark |
| 72 |
can be set using the |
| 73 |
.B skbedit |
| 74 |
action. For example, to only set one bit of the |
| 75 |
.B fwmark |
| 76 |
without changing any other bit: |
| 77 |
|
| 78 |
.RS |
| 79 |
.EX |
| 80 |
tc filter add ... action skbedit mark 0x8/0x8 |
| 81 |
.EE |
| 82 |
.RE |
| 83 |
|
| 84 |
The |
| 85 |
.B fw |
| 86 |
filter can then be used to match on this bit by masking the |
| 87 |
.B handle: |
| 88 |
|
| 89 |
.RS |
| 90 |
.EX |
| 91 |
tc filter add ... handle 0x8/0x8 fw action drop |
| 92 |
.EE |
| 93 |
.RE |
| 94 |
|
| 95 |
This is useful when different bits of the |
| 96 |
.B fwmark |
| 97 |
are assigned different meanings. |
| 98 |
.EE |
| 99 |
.RE |
| 100 |
.SH SEE ALSO |
| 101 |
.BR tc (8), |
| 102 |
.BR iptables (8), |
| 103 |
.BR iptables-extensions (8), |
| 104 |
.BR tc-skbedit (8) |