<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Expert Opinion (Posts about protocol)</title><link>http://findlay.space/</link><description></description><atom:link href="http://findlay.space/categories/protocol.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2020 &lt;a href="mailto:justin@findlay.space"&gt;jmoney&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-NC-SA"
style="border-width:0; margin-bottom:12px;"
src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Fri, 11 Sep 2020 20:35:47 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>iptables: -p vs --proto vs --protocol</title><link>http://findlay.space/posts/iptables-p-vs-proto-vs-protocol/</link><dc:creator>jmoney</dc:creator><description>&lt;div&gt;&lt;p&gt;Observe the following three iptables commands:&lt;/p&gt;
&lt;pre class="code bash"&gt;&lt;a name="rest_code_dff2252adf5547e3b7f0cc96e8241d71-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# iptables -A INPUT -s 10.20.0.0/24 -d 10.10.0.0/24 -i eth0 -m policy -p esp --dir in --pol ipsec --reqid 1 -j ACCEPT&lt;/span&gt;
&lt;a name="rest_code_dff2252adf5547e3b7f0cc96e8241d71-2"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# iptables -A INPUT -s 10.20.0.0/24 -d 10.10.0.0/24 -i eth0 -m policy --proto esp --dir in --pol ipsec --reqid 1 -j ACCEPT&lt;/span&gt;
&lt;a name="rest_code_dff2252adf5547e3b7f0cc96e8241d71-3"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# iptables -A INPUT -s 10.20.0.0/24 -d 10.10.0.0/24 -i eth0 -m policy --protocol esp --dir in --pol ipsec --reqid 1 -j ACCEPT&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;Whereas &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto&lt;/span&gt;&lt;/code&gt; is a valid synonym for &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--protocol&lt;/span&gt;&lt;/code&gt; (as are &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;-p&lt;/span&gt;&lt;/code&gt;,
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto[c[o[l]]]&lt;/span&gt;&lt;/code&gt;), if it, namely the exact token &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto&lt;/span&gt;&lt;/code&gt;, appears in
the rule after &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;-m&lt;/span&gt; policy&lt;/code&gt;, it will be appropriated by the policy extension
of iptables.  Indeed, the resulting rules as reported by &lt;code class="docutils literal"&gt;iptables &lt;span class="pre"&gt;-vL&lt;/span&gt;&lt;/code&gt; are:&lt;/p&gt;
&lt;pre class="code bash"&gt;&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-1"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# iptables -vL&lt;/span&gt;
&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-2"&gt;&lt;/a&gt;Chain INPUT &lt;span class="o"&gt;(&lt;/span&gt;policy ACCEPT &lt;span class="m"&gt;0&lt;/span&gt; packets, &lt;span class="m"&gt;0&lt;/span&gt; bytes&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-3"&gt;&lt;/a&gt; pkts bytes target     prot opt in     out     &lt;span class="nb"&gt;source&lt;/span&gt;               destination
&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-4"&gt;&lt;/a&gt;    &lt;span class="m"&gt;0&lt;/span&gt;     &lt;span class="m"&gt;0&lt;/span&gt; ACCEPT     esp  --  eth0   any     &lt;span class="m"&gt;10&lt;/span&gt;.20.0.0/24         &lt;span class="m"&gt;10&lt;/span&gt;.10.0.0/24         policy match dir in pol ipsec reqid &lt;span class="m"&gt;1&lt;/span&gt;
&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-5"&gt;&lt;/a&gt;    &lt;span class="m"&gt;0&lt;/span&gt;     &lt;span class="m"&gt;0&lt;/span&gt; ACCEPT     all  --  eth0   any     &lt;span class="m"&gt;10&lt;/span&gt;.20.0.0/24         &lt;span class="m"&gt;10&lt;/span&gt;.10.0.0/24         policy match dir in pol ipsec reqid &lt;span class="m"&gt;1&lt;/span&gt; proto esp
&lt;a name="rest_code_1a7c5b1bc9414eac82bdedd45ac283a5-6"&gt;&lt;/a&gt;    &lt;span class="m"&gt;0&lt;/span&gt;     &lt;span class="m"&gt;0&lt;/span&gt; ACCEPT     esp  --  eth0   any     &lt;span class="m"&gt;10&lt;/span&gt;.20.0.0/24         &lt;span class="m"&gt;10&lt;/span&gt;.10.0.0/24         policy match dir in pol ipsec reqid &lt;span class="m"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;This token overloading is an unfortunate design conflict, and such subtlety
&lt;a class="reference external" href="https://github.com/saltstack/salt/pull/47113"&gt;confounded SaltStack's iptables state module&lt;/a&gt;, though not its execution
module.  It's also really confusing unless you know that &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto&lt;/span&gt;&lt;/code&gt; can be
used in two distinct ways in two distinct places.&lt;/p&gt;
&lt;p&gt;So, according to the &lt;a class="reference external" href="http://man7.org/linux/man-pages/man8/iptables.8.html"&gt;iptables(8)&lt;/a&gt; and
&lt;a class="reference external" href="http://man7.org/linux/man-pages/man8/iptables-extensions.8.html"&gt;iptables-extensions(8)&lt;/a&gt; man pages,
&lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;-p&lt;/span&gt;&lt;/code&gt;, &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto[c[o[l]]]&lt;/span&gt;&lt;/code&gt; specify "The protocol of the rule or of the packet
to check." and &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;--proto&lt;/span&gt;&lt;/code&gt; as used by the IPSec policy extension matches the
encapsulation protocol.  Evidently the encapsulation protocol is different from
&lt;em&gt;the&lt;/em&gt; protocol used for IPSec traffic.  I still have more to learn about this,
otherwise I would be more helpful here.&lt;/p&gt;&lt;/div&gt;</description><category>IPSec</category><category>iptables</category><category>linux</category><category>networking</category><category>protocol</category><guid>http://findlay.space/posts/iptables-p-vs-proto-vs-protocol/</guid><pubDate>Thu, 12 Apr 2018 23:43:40 GMT</pubDate></item></channel></rss>