{"id":2816,"date":"2022-12-20T15:17:23","date_gmt":"2022-12-20T18:17:23","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/ct-action-in-tc-man8\/"},"modified":"2022-12-20T15:17:23","modified_gmt":"2022-12-20T18:17:23","slug":"ct-action-in-tc-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/ct-action-in-tc-man8\/","title":{"rendered":"ct action in tc (man8)"},"content":{"rendered":"<h1 align=\"center\">ct action in tc<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">ct \u2212 tc connection tracking action<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc &#8230; action ct commit [ force ] [ zone<\/b> <i>ZONE<\/i> <b>] [ mark<\/b> <i>MASKED_MARK<\/i> <b>] [ label<\/b> <i>MASKED_LABEL<\/i> <b>] [ nat<\/b> <i>NAT_SPEC<\/i> <b>]<\/b><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc &#8230; action ct [ nat ] [ zone<\/b> <i>ZONE<\/i> <b>]<\/b><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><b>tc &#8230; action ct clear<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The ct action is a tc action for sending packets and interacting with the netfilter conntrack module.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It can (as shown in the synopsis, in order):<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Send the packet to conntrack, and commit the connection, while configuring a 32bit mark, 128bit label, and src\/dst nat.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Send the packet to conntrack, which will mark the packet with the connection\u2019s state and configured metadata (mark\/label), and execute previous configured nat.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Clear the packet\u2019s of previous connection tracking state.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>zone<\/b> <i>ZONE<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify a conntrack zone number on which to send the packet to conntrack.<\/p>\n<p style=\"margin-left:11%;\"><b>mark<\/b> <i>MASKED_MARK<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify a masked 32bit mark to set for the connection (only valid with commit).<\/p>\n<p style=\"margin-left:11%;\"><b>label<\/b> <i>MASKED_LABEL<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify a masked 128bit label to set for the connection (only valid with commit).<\/p>\n<p style=\"margin-left:11%;\"><b>nat<\/b> <i>NAT_SPEC<\/i><\/p>\n<p style=\"margin-left:22%;\"><b>Where<\/b> <i>NAT_SPEC<\/i> <b>:= {src|dst} addr<\/b> <i>addr1<\/i><b>[-<\/b><i>addr2<\/i><b>] [port<\/b> <i>port1<\/i><b>[-<\/b><i>port2<\/i><b>]]<\/b><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Specify src\/dst and range of nat to configure for the connection (only valid with commit). <br \/> src\/dst &#8211; configure src or dst nat <i><br \/> addr1<\/i><b>\/<\/b><i>addr2<\/i> <b>&#8211; IPv4\/IPv6 addresses<\/b> <i><br \/> port1<\/i><b>\/<\/b><i>port2<\/i> <b>&#8211; Port numbers<\/b><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p><b>nat<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p>Restore any previous configured nat.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p><b>clear<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p>Remove any conntrack state and metadata (mark\/label) from the packet (must only option specified).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p><b>force<\/b><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"78%\">\n<p>Forces conntrack direction for a previously committed connections, so that current direction will become the original direction (only valid with commit).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Example showing natted firewall in conntrack zone 2, and conntrack mark usage:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">#Add ingress qdisc on eth0 and eth1 interfaces <br \/> $ tc qdisc add dev eth0 handle ingress <br \/> $ tc qdisc add dev eth1 handle ingress<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">#Setup filters on eth0, allowing opening new connections in zone 2, and doing src nat + mark for each new connection <br \/> $ tc filter add dev eth0 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk  <br \/> action ct zone 2 pipe action goto chain 2 <br \/> $ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_state +trk+new  <br \/> action ct zone 2 commit mark 0xbb nat src addr 5.5.5.7 pipe action mirred egress redirect dev eth1 <br \/> $ tc filter add dev eth0 ingress prio 1 chain 2 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est  <br \/> action ct nat pipe action mirred egress redirect dev eth1<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">#Setup filters on eth1, allowing only established connections of zone 2 through, and reverse nat (dst nat in this case) <br \/> $ tc filter add dev eth1 ingress prio 1 chain 0 proto ip flower ip_proto tcp ct_state -trk  <br \/> action ct zone 2 pipe action goto chain 1 <br \/> $ tc filter add dev eth1 ingress prio 1 chain 1 proto ip flower ct_zone 2 ct_mark 0xbb ct_state +trk+est  <br \/> action ct nat pipe action mirred egress redirect dev eth0<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tc<\/b>(8), <b>tc-flower<\/b>(8) <b>tc-mirred<\/b>(8)<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Paul Blakey <paulb@mellanox.com><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Marcelo Ricardo Leitner <marcelo.leitner@gmail.com><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Yossi Kuperman <yossiku@mellanox.com><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  ct \u2212 tc connection tracking action <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,168],"class_list":["post-2816","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-tc-ct"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=2816"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/2816\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=2816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=2816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=2816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}