<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to best determine IP range membership? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9411#M116</link>
    <description>&lt;P&gt;We also allow the CIDR syntax in a search field comparison, so you could enter something simple like this in the search bar:&lt;/P&gt;

&lt;P&gt;Src_Zone=172.16.0.0/16&lt;/P&gt;

&lt;P&gt;This works for '=' and '!=', and you can still use the search boolean operators.&lt;/P&gt;</description>
    <pubDate>Sat, 23 Jan 2010 05:57:31 GMT</pubDate>
    <dc:creator>Marklar</dc:creator>
    <dc:date>2010-01-23T05:57:31Z</dc:date>
    <item>
      <title>How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9408#M113</link>
      <description>&lt;P&gt;Use Case: Find Juniper firewall events where the source/destination IP (&lt;CODE&gt;Src_Zone/Dst_Zone&lt;/CODE&gt;) does or does not belong in the private zone.&lt;/P&gt;

&lt;P&gt;The private zone includes IP ranges defined by RFC1918 plus others:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;CODE&gt;169.254.0.0 to 169.254.255.255&lt;/CODE&gt; (RFC1918)&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;10.0.0.0 to 10.255.255.255&lt;/CODE&gt; (RFC1918)&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;192.168.0.0 to 192.168.255.255&lt;/CODE&gt; (RFC1918)&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;172.16.0.0 to 172.31.255.255&lt;/CODE&gt; (LinkLocal)&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Proposed Splunk search macro for Src_Zone membership in the private zone:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;Src_Zone=169.254.*.* OR Src_Zone=10.*.*.* OR Src_Zone=192.168.*.* OR Src_Zone=172.16.*.* OR Src_Zone=172.17.*.* OR Src_Zone=172.18.*.* OR Src_Zone=172.19.*.* OR Src_Zone=172.20.*.* OR Src_Zone=172.21.*.* OR Src_Zone=172.22.*.* OR Src_Zone=172.23.*.* OR Src_Zone=172.24.*.* OR Src_Zone=172.25.*.* OR Src_Zone=172.26.*.* OR Src_Zone=172.27.*.* OR Src_Zone=172.28.*.* OR Src_Zone=172.29.*.* OR Src_Zone=172.30.*.* OR Src_Zone=172.31.*.*&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This approach is super unwieldy even as a macro, and is likely not efficient.  There must be a better way to express membership in the last IP range defined by the private zone &lt;CODE&gt;172.16.0.0-172.31.255.255&lt;/CODE&gt; without having to expand it.  I tried incorporating the regex command (&lt;CODE&gt;... | regex Src_Zone="172\.(1[6-9]|2\d|3[0-1])\.&lt;/CODE&gt;) but can't figure out how to use it in a boolean OR context.&lt;/P&gt;

&lt;P&gt;This gets even hairier when trying to express membership where&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;Src_Zone!=&amp;lt;in the private zone&amp;gt; AND Dst_Zone=&amp;lt;in the private zone&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Any suggestions on how to not brute force this?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2010 05:11:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9408#M113</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2010-01-22T05:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9409#M114</link>
      <description>&lt;P&gt;Take a look at &lt;CODE&gt;cidrmatch&lt;/CODE&gt;, in &lt;A href="http://www.splunk.com/base/Documentation/4.0.8/SearchReference/CommonEvalFunctions" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/4.0.8/SearchReference/CommonEvalFunctions&lt;/A&gt;.  You can use it with &lt;CODE&gt;WHERE&lt;/CODE&gt;, that should simplify things.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2010 06:20:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9409#M114</guid>
      <dc:creator>V_at_Splunk</dc:creator>
      <dc:date>2010-01-22T06:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9410#M115</link>
      <description>&lt;P&gt;Many thanks, V!&lt;/P&gt;

&lt;P&gt;For the scenario above, this is how your answer was applied:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;... | where cidrmatch("10.0.0.0/8",Src_Addr) OR cidrmatch("172.16.0.0/12",Src_Addr) OR cidrmatch("192.168.0.0/16",Src_Addr) OR cidrmatch("169.254.0.0/16",Src_Addr)&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Who knew the Splunk search language is so powerful.  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;  This is much simpler!&lt;/P&gt;

&lt;P&gt;For the curious, here is further supporting information:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://en.wikipedia.org/wiki/Private_network" rel="nofollow"&gt;http://en.wikipedia.org/wiki/Private_network&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/Where" rel="nofollow"&gt;http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/Where&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/Eval" rel="nofollow"&gt;http://docs.splunk.com/Documentation/Splunk/5.0/SearchReference/Eval&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;It is especially helpful to know the &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt; commands support booleans.  For example, to solve the more difficult case of&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;Src_Zone!=&amp;lt;in the private zone&amp;gt; AND Dst_Zone=&amp;lt;in the private zone&amp;gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;simply apply the NOT and AND boolean operators:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;&lt;CODE&gt;... | where&lt;/CODE&gt; &lt;STRONG&gt;&lt;CODE&gt;NOT&lt;/CODE&gt;&lt;/STRONG&gt; &lt;CODE&gt;( cidrmatch("10.0.0.0/8",Src_Addr) OR cidrmatch("172.16.0.0/12",Src_Addr) OR cidrmatch("192.168.0.0/16",Src_Addr) OR cidrmatch("169.254.0.0/16",Src_Addr) )&lt;/CODE&gt; &lt;STRONG&gt;&lt;CODE&gt;AND&lt;/CODE&gt;&lt;/STRONG&gt; &lt;BR /&gt;
  &lt;CODE&gt;( cidrmatch("10.0.0.0/8",Dst_Addr) OR cidrmatch("172.16.0.0/12",Dst_Addr) OR cidrmatch("192.168.0.0/16",Dst_Addr) OR cidrmatch("169.254.0.0/16",Dst_Addr) )&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 22 Jan 2010 09:52:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9410#M115</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2010-01-22T09:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9411#M116</link>
      <description>&lt;P&gt;We also allow the CIDR syntax in a search field comparison, so you could enter something simple like this in the search bar:&lt;/P&gt;

&lt;P&gt;Src_Zone=172.16.0.0/16&lt;/P&gt;

&lt;P&gt;This works for '=' and '!=', and you can still use the search boolean operators.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2010 05:57:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9411#M116</guid>
      <dc:creator>Marklar</dc:creator>
      <dc:date>2010-01-23T05:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9412#M117</link>
      <description>&lt;P&gt;That's pretty sweet.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jan 2010 06:51:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9412#M117</guid>
      <dc:creator>Johnvey</dc:creator>
      <dc:date>2010-01-23T06:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to best determine IP range membership?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9413#M118</link>
      <description>&lt;P&gt;It is very sweet.  Thank you, Marklar!  So my IP range searches now are even shorter.  I've even defined macros so my searches are super short, too:&lt;/P&gt;

&lt;P&gt;For outbound traffic:&lt;/P&gt;

&lt;P&gt;( Src_Addr=10.0.0.0/8 OR Src_Addr=172.16.0.0/12 OR Src_Addr=192.168.0.0/16 OR Src_Addr=169.254.0.0/16 ) AND ( Dst_Addr!=10.0.0.0/8 AND Dst_Addr!=172.16.0.0/12 AND Dst_Addr!=192.168.0.0/16 AND Dst_Addr!=169.254.0.0/16 AND Dst_Addr!=65.194.243.* AND Dst_Addr!=216.52.215.* )&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-best-determine-IP-range-membership/m-p/9413#M118</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2020-09-28T09:10:55Z</dc:date>
    </item>
  </channel>
</rss>

