{"id":4539,"date":"2022-12-20T18:08:59","date_gmt":"2022-12-20T21:08:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/shorewallsecmarks-man5\/"},"modified":"2022-12-20T18:08:59","modified_gmt":"2022-12-20T21:08:59","slug":"shorewallsecmarks-man5","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/shorewallsecmarks-man5\/","title":{"rendered":"SHOREWALL&minus;SECMARKS (man5)"},"content":{"rendered":"<h1 align=\"center\">SHOREWALL\u2212SECMARKS<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#FILES\">FILES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">secmarks \u2212 Shorewall file<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\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=\"40%\">\n<p style=\"margin-top: 1em\"><b>\/etc\/shorewall[6]\/secmarks<\/b><\/p>\n<\/td>\n<td width=\"49%\"> <\/td>\n<\/tr>\n<\/table>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:17%; margin-top: 1em\"><b><big>Important<\/big><\/b> <br \/> Unlike rules in the <b><font color=\"#0000FF\">shorewall\u2212rules<\/font><\/b> <small><font color=\"#000000\">[1]<\/font><\/small> <font color=\"#000000\">(5) file, evaluation of rules in this file will continue after a match. So the final secmark for each packet will be the one assigned by the LAST rule that matches.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">The secmarks file is used to associate an SELinux context with packets. It was added in Shorewall version 4.4.13.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">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).<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>SECMARK \u2212 {SAVE|RESTORE|<\/b><i>context<\/i><b>|?COMMENT<\/b> <i>comment<\/i><b>}<\/b><\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><b>SAVE<\/b><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">If an SELinux context is associated with the packet, the context is saved in the connection. Normally, the remaining columns should be left blank.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><b>RESTORE<\/b><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">If an SELinux context is not currently associated with the packet, then the saved context (if any) is associated with the packet. Normally, the remaining columns should be left blank.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><i>context<\/i><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">An SELinux context.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">?COMMENT<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">The remainder of the line is treated as a comment which is attached to subsequent rules until another ?COMMENT line is found or until the end of the file is reached. To stop adding comments to rules, use a line with only the word ?COMMENT.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>CHAIN \u2212 {P|I|F|O|T}[:{N|I|U|IU|NI|NU|NIU|NUI:E|ER}]<\/b><\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">This column determines the CHAIN where the SELinux context is to be applied:<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">P \u2212 PREROUTING <br \/> I \u2212 INPUT <br \/> F \u2212 FORWARD <br \/> O \u2212 OUTPUT <br \/> T \u2212 POSTROUTING<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">It may be optionally followed by a colon and an indication of the Netfilter connection state(s) at which the context is to be applied:<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">:N \u2212 NEW connection <br \/> :I \u2212 INVALID connection <br \/> :NI \u2212 NEW or INVALID connection <br \/> :E \u2212 ESTABLISHED connection <br \/> :ER \u2212 ESTABLISHED or RELATED connection<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Beginning with Shorewall 4.5.10, the following additional options are available<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">:U \u2212 UNTRACKED connection <br \/> :IU \u2212 INVALID or UNTRACKED connection <br \/> :NU \u2212 NEW or UNTRACKED connection <br \/> :NIU \u2212 NEW, INVALID or UNTRACKED connection.<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">This column was formerly labelled CHAIN:STATE.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>SOURCE<\/b> \u2212 {<b>\u2212<\/b><i>interface<\/i>|[<i>interface<\/i>:]<i>address\u2212or\u2212range<\/i>[<b>,<\/b><i>address\u2212or\u2212range<\/i>]&#8230;}[<i>exclusion<\/i>]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">May be:<\/font><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><font color=\"#000000\">1. An interface name \u2212 matches traffic entering the firewall on the specified interface. May not be used in classify rules or in rules using the T in the CHAIN column.<\/font><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><font color=\"#000000\">2. A comma\u2212separated list of host or network IP addresses or MAC addresses.<\/font><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><font color=\"#000000\">3. An interface name followed by a colon (&#8220;:&#8221;) followed by a comma\u2212separated list of host or network IP addresses or MAC addresses.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">MAC addresses must be prefixed with &#8220;~&#8221; and use &#8220;\u2212&#8221; as a separator.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Example: ~00\u2212A0\u2212C9\u221215\u221239\u221278<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">You may exclude certain hosts from the set already defined through use of an <i>exclusion<\/i> (see<\/font> <b><font color=\"#0000FF\">shorewall\u2212exclusion<\/font><\/b> <small><font color=\"#000000\">[2]<\/font><\/small> <font color=\"#000000\">(5)).<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Addresses may be specified using an ipset name preceded by &#8216;+&#8217;.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>DEST<\/b> \u2212 {<b>\u2212<\/b>|{<i>interface<\/i>|[<i>interface<\/i>:]<i>address\u2212or\u2212range<\/i>[<b>,<\/b><i>address\u2212or\u2212range<\/i>]&#8230;}[<i>exclusion<\/i>]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">May be:<\/font><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><font color=\"#000000\">1. An interface name. May not be used in the PREROUTING or INPUT chains. The interface name may be optionally followed by a colon (&#8220;:&#8221;) and an IP address list.<\/font><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><font color=\"#000000\">2. A comma\u2212separated list of host or network IP addresses. The list may include ip address ranges if your kernel and iptables include iprange support.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">You may exclude certain hosts from the set already defined through use of an <i>exclusion<\/i> (see<\/font> <b><font color=\"#0000FF\">shorewall\u2212exclusion<\/font><\/b> <small><font color=\"#000000\">[2]<\/font><\/small> <font color=\"#000000\">(5)).<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Addresses may be specified using an ipset name preceded by &#8216;+&#8217;.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>PROTO<\/b> \u2212 {<b>\u2212<\/b>|<b>tcp:syn<\/b>|<b>ipp2p<\/b>|<b>ipp2p:udp<\/b>|<b>ipp2p:all<\/b>|<i>protocol\u2212number<\/i>|<i>protocol\u2212name<\/i>|<b>all}[,&#8230;]<\/b><\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">See<\/font> <b><font color=\"#0000FF\">shorewall\u2212rules(5)<\/font><\/b> <small><font color=\"#000000\">[1]<\/font><\/small> <font color=\"#000000\">for details.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Beginning with Shorewall 4.5.12, this column can accept a comma\u2212separated list of protocols.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>DPORT<\/b> \u2212 [<b>\u2212<\/b>|<i>port\u2212name\u2212number\u2212or\u2212range<\/i>[<b>,<\/b><i>port\u2212name\u2212number\u2212or\u2212range<\/i>]&#8230;]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Optional destination Ports. A comma\u2212separated list of Port names (from services(5)), <i>port number<\/i>s or <i>port range<\/i>s; if the protocol is <b>icmp<\/b>, this column is interpreted as the destination icmp\u2212type(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<\/font> <b><font color=\"#0000FF\">https:\/\/shorewall.org\/configuration_file_basics.htm#ICMP<\/font><\/b> <small><font color=\"#000000\">[3]<\/font><\/small> <font color=\"#000000\">.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">If the protocol is <b>ipp2p<\/b>, this column is interpreted as an ipp2p option without the leading &#8220;\u2212\u2212&#8221; (example <b>bit<\/b> for bit\u2212torrent). If no PORT is given, <b>ipp2p<\/b> is assumed.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">This column is ignored if PROTOCOL = all but must be entered if any of the following field is supplied. In that case, it is suggested that this field contain &#8220;\u2212&#8221;<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">This column was formerly labelled DEST PORT(S).<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>SPORT<\/b> \u2212 [<b>\u2212<\/b>|<i>port\u2212name\u2212number\u2212or\u2212range<\/i>[<b>,<\/b><i>port\u2212name\u2212number\u2212or\u2212range<\/i>]&#8230;]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Optional source port(s). If omitted, any source port is acceptable. Specified as a comma\u2212separated list of port names, port numbers or port ranges.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">This column was formerly labelled SOURCE PORT(S).<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>USER<\/b> \u2212 [<b>!<\/b>][<i>user\u2212name\u2212or\u2212number<\/i>][<b>:<\/b><i>group\u2212name\u2212or\u2212number<\/i>]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">This optional column may only be non\u2212empty if the SOURCE is the firewall itself.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">When this column is non\u2212empty, the rule applies only if the program generating the output is running under the effective <i>user<\/i> and\/or <i>group<\/i> specified (or is NOT running under that id if &#8220;!&#8221; is given).<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Examples:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">joe<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">program must be run by joe<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">:kids<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">program must be run by a member of the &#8216;kids&#8217; group<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">!:kids<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">program must not be run by a member of the &#8216;kids&#8217; group<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>MARK<\/b> \u2212 [<b>!<\/b>]<i>value<\/i>[\/<i>mask<\/i>][<b>:C<\/b>]<\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Defines a test on the existing packet or connection mark. The rule will match only if the test returns true.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">If you don&#8217;t want to define a test but need to specify anything in the following columns, place a &#8220;\u2212&#8221; in this field.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">!<\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">Inverts the test (not equal)<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><i>value<\/i><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">Value of the packet or connection mark.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><i>mask<\/i><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">A mask to be applied to the mark before testing.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"><b>:C<\/b><\/font><\/p>\n<p style=\"margin-left:23%;\"><font color=\"#000000\">Designates a connection mark. If omitted, the packet mark&#8217;s value is tested.<\/font><\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">Mark the first incoming packet of a connection on the loopback interface and destined for address 127.0.0.1 and tcp port 3306 with context system_u:object_r:mysqld_t:s0 and save that context in the conntrack table. On subsequent input packets in the connection, set the context from the conntrack table.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">\/etc\/shorewall\/interfaces:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">#ZONE INTERFACE BROADCAST OPTIONS <br \/> \u2212 lo \u2212 ignore<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">\/etc\/shorewall\/secmarks:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">#SECMARK CHAIN SOURCE DEST PROTO DPORT SPORT USER MARK <br \/> system_u:object_r:mysqld_packet_t:s0 I:N lo 127.0.0.1 tcp 3306 <br \/> SAVE I:N lo 127.0.0.1 tcp 3306 <br \/> RESTORE I:ER<\/font><\/p>\n<h2>FILES <a name=\"FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">\/etc\/shorewall\/secmarks<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">\/etc\/shorewall6\/secmarks<\/font><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><font color=\"#0000FF\">http:\/\/james\u2212morris.livejournal.com\/11010.html<\/font><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><font color=\"#0000FF\">https:\/\/shorewall.org\/configuration_file_basics.htm#Pairs<\/font><\/b> <small><font color=\"#000000\">[4]<\/font><\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">shorewall(8)<\/font><\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">1.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"23%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">shorewall-rules<\/font><\/p>\n<\/td>\n<td width=\"60%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/shorewall.org\/manpages\/shorewall-rules.html<\/font><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">2.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"29%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">shorewall-exclusion<\/font><\/p>\n<\/td>\n<td width=\"54%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/shorewall.org\/manpages\/shorewall-exclusion.html<\/font><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">3.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">https:\/\/shorewall.org\/configuration_file_basics.htm#ICMP<\/font><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/shorewall.org\/configuration_file_basics.htm#ICMP<\/font><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">4.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">https:\/\/shorewall.org\/configuration_file_basics.htm#Pairs<\/font><\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/shorewall.org\/configuration_file_basics.htm#Pairs<\/font><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  secmarks \u2212 Shorewall file <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[959],"tags":[961,1291,1499],"class_list":["post-4539","post","type-post","status-publish","format-standard","hentry","category-5-formatos-de-ficheros","tag-961","tag-man5","tag-shorewall-secmarks"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4539","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=4539"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4539\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}