| 1 |
.TH "ct action in tc" 8 "14 May 2020" "iproute2" "Linux" |
| 2 |
.SH NAME |
| 3 |
ct \- tc connection tracking action |
| 4 |
.SH SYNOPSIS |
| 5 |
.in +8 |
| 6 |
.ti -8 |
| 7 |
.BR "tc ... action ct commit [ force ] [ zone " |
| 8 |
.IR ZONE |
| 9 |
.BR "] [ mark " |
| 10 |
.IR MASKED_MARK |
| 11 |
.BR "] [ label " |
| 12 |
.IR MASKED_LABEL |
| 13 |
.BR "] [ nat " |
| 14 |
.IR NAT_SPEC |
| 15 |
.BR "]" |
| 16 |
|
| 17 |
.ti -8 |
| 18 |
.BR "tc ... action ct [ nat ] [ zone " |
| 19 |
.IR ZONE |
| 20 |
.BR "]" |
| 21 |
|
| 22 |
.ti -8 |
| 23 |
.BR "tc ... action ct clear" |
| 24 |
|
| 25 |
.SH DESCRIPTION |
| 26 |
The ct action is a tc action for sending packets and interacting with the netfilter conntrack module. |
| 27 |
|
| 28 |
It can (as shown in the synopsis, in order): |
| 29 |
|
| 30 |
Send the packet to conntrack, and commit the connection, while configuring |
| 31 |
a 32bit mark, 128bit label, and src/dst nat. |
| 32 |
|
| 33 |
Send the packet to conntrack, which will mark the packet with the connection's state and |
| 34 |
configured metadata (mark/label), and execute previous configured nat. |
| 35 |
|
| 36 |
Clear the packet's of previous connection tracking state. |
| 37 |
|
| 38 |
.SH OPTIONS |
| 39 |
.TP |
| 40 |
.BI zone " ZONE" |
| 41 |
Specify a conntrack zone number on which to send the packet to conntrack. |
| 42 |
.TP |
| 43 |
.BI mark " MASKED_MARK" |
| 44 |
Specify a masked 32bit mark to set for the connection (only valid with commit). |
| 45 |
.TP |
| 46 |
.BI label " MASKED_LABEL" |
| 47 |
Specify a masked 128bit label to set for the connection (only valid with commit). |
| 48 |
.TP |
| 49 |
.BI nat " NAT_SPEC" |
| 50 |
.BI Where " NAT_SPEC " ":= {src|dst} addr" " addr1" "[-" "addr2" "] [port " "port1" "[-" "port2" "]]" |
| 51 |
|
| 52 |
Specify src/dst and range of nat to configure for the connection (only valid with commit). |
| 53 |
.RS |
| 54 |
.TP |
| 55 |
src/dst - configure src or dst nat |
| 56 |
.TP |
| 57 |
.BI "" "addr1" "/" "addr2" " - IPv4/IPv6 addresses" |
| 58 |
.TP |
| 59 |
.BI "" "port1" "/" "port2" " - Port numbers" |
| 60 |
.RE |
| 61 |
.TP |
| 62 |
.BI nat |
| 63 |
Restore any previous configured nat. |
| 64 |
.TP |
| 65 |
.BI clear |
| 66 |
Remove any conntrack state and metadata (mark/label) from the packet (must only option specified). |
| 67 |
.TP |
| 68 |
.BI force |
| 69 |
Forces conntrack direction for a previously committed connections, so that current direction will become the original direction (only valid with commit). |
| 70 |
|
| 71 |
.SH EXAMPLES |
| 72 |
Example showing natted firewall in conntrack zone 2, and conntrack mark usage: |
| 73 |
.EX |
| 74 |
|
| 75 |
#Add ingress qdisc on eth0 and eth1 interfaces |
| 76 |
.nf |
| 77 |
$ tc qdisc add dev eth0 ingress |
| 78 |
$ tc qdisc add dev eth1 ingress |
| 79 |
|
| 80 |
#Setup filters on eth0, allowing opening new connections in zone 2, and doing src nat + mark for each new connection |
| 81 |
$ tc filter add dev eth0 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk \\ |
| 82 |
action ct zone 2 pipe action goto chain 2 |
| 83 |
$ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_state +trk+new \\ |
| 84 |
action ct zone 2 commit mark 0xbb nat src addr 5.5.5.7 pipe action mirred egress redirect dev eth1 |
| 85 |
$ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \\ |
| 86 |
action ct nat pipe action mirred egress redirect dev eth1 |
| 87 |
|
| 88 |
#Setup filters on eth1, allowing only established connections of zone 2 through, and reverse nat (dst nat in this case) |
| 89 |
$ tc filter add dev eth1 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk \\ |
| 90 |
action ct zone 2 pipe action goto chain 1 |
| 91 |
$ tc filter add dev eth1 ingress prio 1 chain 1 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \\ |
| 92 |
action ct nat pipe action mirred egress redirect dev eth0 |
| 93 |
.fi |
| 94 |
|
| 95 |
.EE |
| 96 |
|
| 97 |
.RE |
| 98 |
.SH SEE ALSO |
| 99 |
.BR tc (8), |
| 100 |
.BR tc-flower (8) |
| 101 |
.BR tc-mirred (8) |
| 102 |
.SH AUTHORS |
| 103 |
Paul Blakey <[email protected]> |
| 104 |
|
| 105 |
Marcelo Ricardo Leitner <[email protected]> |
| 106 |
|
| 107 |
Yossi Kuperman <[email protected]> |