|
Packit Service |
3880ab |
.TH "ct action in tc" 8 "14 May 2020" "iproute2" "Linux"
|
|
Packit Service |
3880ab |
.SH NAME
|
|
Packit Service |
3880ab |
ct \- tc connection tracking action
|
|
Packit Service |
3880ab |
.SH SYNOPSIS
|
|
Packit Service |
3880ab |
.in +8
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.BR "tc ... action ct commit [ force ] [ zone "
|
|
Packit Service |
3880ab |
.IR ZONE
|
|
Packit Service |
3880ab |
.BR "] [ mark "
|
|
Packit Service |
3880ab |
.IR MASKED_MARK
|
|
Packit Service |
3880ab |
.BR "] [ label "
|
|
Packit Service |
3880ab |
.IR MASKED_LABEL
|
|
Packit Service |
3880ab |
.BR "] [ nat "
|
|
Packit Service |
3880ab |
.IR NAT_SPEC
|
|
Packit Service |
3880ab |
.BR "]"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.BR "tc ... action ct [ nat ] [ zone "
|
|
Packit Service |
3880ab |
.IR ZONE
|
|
Packit Service |
3880ab |
.BR "]"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.BR "tc ... action ct clear"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.SH DESCRIPTION
|
|
Packit Service |
3880ab |
The ct action is a tc action for sending packets and interacting with the netfilter conntrack module.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
It can (as shown in the synopsis, in order):
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Send the packet to conntrack, and commit the connection, while configuring
|
|
Packit Service |
3880ab |
a 32bit mark, 128bit label, and src/dst nat.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Send the packet to conntrack, which will mark the packet with the connection's state and
|
|
Packit Service |
3880ab |
configured metadata (mark/label), and execute previous configured nat.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Clear the packet's of previous connection tracking state.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.SH OPTIONS
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI zone " ZONE"
|
|
Packit Service |
3880ab |
Specify a conntrack zone number on which to send the packet to conntrack.
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI mark " MASKED_MARK"
|
|
Packit Service |
3880ab |
Specify a masked 32bit mark to set for the connection (only valid with commit).
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI label " MASKED_LABEL"
|
|
Packit Service |
3880ab |
Specify a masked 128bit label to set for the connection (only valid with commit).
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI nat " NAT_SPEC"
|
|
Packit Service |
3880ab |
.BI Where " NAT_SPEC " ":= {src|dst} addr" " addr1" "[-" "addr2" "] [port " "port1" "[-" "port2" "]]"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Specify src/dst and range of nat to configure for the connection (only valid with commit).
|
|
Packit Service |
3880ab |
.RS
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
src/dst - configure src or dst nat
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI "" "addr1" "/" "addr2" " - IPv4/IPv6 addresses"
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI "" "port1" "/" "port2" " - Port numbers"
|
|
Packit Service |
3880ab |
.RE
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI nat
|
|
Packit Service |
3880ab |
Restore any previous configured nat.
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI clear
|
|
Packit Service |
3880ab |
Remove any conntrack state and metadata (mark/label) from the packet (must only option specified).
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.BI force
|
|
Packit Service |
3880ab |
Forces conntrack direction for a previously commited connections, so that current direction will become the original direction (only valid with commit).
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.SH EXAMPLES
|
|
Packit Service |
3880ab |
Example showing natted firewall in conntrack zone 2, and conntrack mark usage:
|
|
Packit Service |
3880ab |
.EX
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
#Add ingress qdisc on eth0 and eth1 interfaces
|
|
Packit Service |
3880ab |
.nf
|
|
Packit Service |
3880ab |
$ tc qdisc add dev eth0 handle ingress
|
|
Packit Service |
3880ab |
$ tc qdisc add dev eth1 handle ingress
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
#Setup filters on eth0, allowing opening new connections in zone 2, and doing src nat + mark for each new connection
|
|
Packit Service |
3880ab |
$ tc filter add dev eth0 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk \\
|
|
Packit Service |
3880ab |
action ct zone 2 pipe action goto chain 2
|
|
Packit Service |
3880ab |
$ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_state +trk+new \\
|
|
Packit Service |
3880ab |
action ct zone 2 commit mark 0xbb nat src addr 5.5.5.7 pipe action mirred egress redirect dev eth1
|
|
Packit Service |
3880ab |
$ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \\
|
|
Packit Service |
3880ab |
action ct nat pipe action mirred egress redirect dev eth1
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
#Setup filters on eth1, allowing only established connections of zone 2 through, and reverse nat (dst nat in this case)
|
|
Packit Service |
3880ab |
$ tc filter add dev eth1 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk \\
|
|
Packit Service |
3880ab |
action ct zone 2 pipe action goto chain 1
|
|
Packit Service |
3880ab |
$ tc filter add dev eth1 ingress prio 1 chain 1 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \\
|
|
Packit Service |
3880ab |
action ct nat pipe action mirred egress redirect dev eth0
|
|
Packit Service |
3880ab |
.fi
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.EE
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.RE
|
|
Packit Service |
3880ab |
.SH SEE ALSO
|
|
Packit Service |
3880ab |
.BR tc (8),
|
|
Packit Service |
3880ab |
.BR tc-flower (8)
|
|
Packit Service |
3880ab |
.BR tc-mirred (8)
|
|
Packit Service |
3880ab |
.SH AUTHORS
|
|
Packit Service |
3880ab |
Paul Blakey <paulb@mellanox.com>
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Yossi Kuperman <yossiku@mellanox.com>
|