<?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: Filter private ip from src AND dest in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582479#M202876</link>
    <description>&lt;P&gt;The solution given by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;&amp;nbsp;does not work if the values of src and dest are actually in CIDR notation e.g. "10.0.0.0/8" (as seemed to be implied by the question), however, it does work if these fields actually contain ip addresses e.g. anything in the range 10.x.x.x, which, to be fair, is possibly/probably the case, although since no example events were included, I, for one, have no idea.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The point I was making was more to do with how the logic of using not equals inverts the use of OR and AND.&amp;nbsp; This applies to other logical expressions, not just ip address and/or cidr notation, which is why I used a simple example to explain the point.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jan 2022 06:35:43 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-01-26T06:35:43Z</dc:date>
    <item>
      <title>Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582452#M202861</link>
      <description>&lt;P&gt;New to the community so all help is appreciated!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Requirement&lt;/STRONG&gt;&lt;BR /&gt;We have a requirement to filter some network data in a correlation search to return any data which has a public ip in the "src" or "dest" field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Solution&lt;BR /&gt;&lt;/STRONG&gt;I tried several variants of this:&lt;BR /&gt;... | search (src!="10.0.0.0/8" OR src!="192.168.0.0/16" OR src!="172.16.0.0/12") AND (dest!="10.0.0.0/8" OR&amp;nbsp; dest!="192.168.0.0/16" OR dest!="172.16.0.0/12")&lt;BR /&gt;&lt;BR /&gt;I boiled it down to this, which also does not work:&lt;BR /&gt;... | search src!="10.0.0.0/8" AND dest!="10.0.0.0/8"&lt;BR /&gt;&lt;BR /&gt;It appears that my query is evaluating the first "OR" individually, meaning that no matter what I set the dest!= filter to it does not return results.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My Request&lt;BR /&gt;&lt;/STRONG&gt;Clearly I don't understand the logic being used for OR/AND operators and a better understanding of that would be appreciated. Ultimately though, I'm not stuck on this logic, so if there is a better way to only return results which has a public ip in the src OR dest fields I'm happy to learn the best way to do that as well!&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 22:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582452#M202861</guid>
      <dc:creator>thin_air</dc:creator>
      <dc:date>2022-01-25T22:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582454#M202863</link>
      <description>&lt;P&gt;Your logic has been inverted by the use of !=&lt;/P&gt;&lt;P&gt;Consider this simple case&lt;/P&gt;&lt;P&gt;X="A"&lt;/P&gt;&lt;P&gt;if (X != "A" OR X != "B")&lt;/P&gt;&lt;P&gt;Since X = "A" it fails the first condition but is true for the second condition&lt;/P&gt;&lt;P&gt;What you should have is&lt;/P&gt;&lt;P&gt;if (X != "A" AND X != "B")&lt;/P&gt;&lt;P&gt;So, in your case it should be more like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | search (src!="10.0.0.0/8" AND src!="192.168.0.0/16" AND src!="172.16.0.0/12") OR (dest!="10.0.0.0/8" AND dest!="192.168.0.0/16" AND dest!="172.16.0.0/12")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jan 2022 23:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582454#M202863</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-01-25T23:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582463#M202868</link>
      <description>&lt;P&gt;The solution provided by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;works.&lt;/P&gt;&lt;P&gt;Another solution which works significantly faster (3x) in my testing is to use cidrmatch.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search...
| eval src_net=IF(cidrmatch("10.0.0.0/8", src) OR cidrmatch("172.16.0.0/12", src) OR cidrmatch("192.168.0.0/16", src), "private", "public")
| eval dest_net=IF(cidrmatch("10.0.0.0/8", dest) OR cidrmatch("172.16.0.0/12", dest) OR cidrmatch("192.168.0.0/16", dest), "private", "public")
| search src_net="public" OR dest_net="public"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Keep in mind that the eval to determine the network type is not necessary, but gives you some flexibility&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 02:15:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582463#M202868</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-26T02:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582479#M202876</link>
      <description>&lt;P&gt;The solution given by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;&amp;nbsp;does not work if the values of src and dest are actually in CIDR notation e.g. "10.0.0.0/8" (as seemed to be implied by the question), however, it does work if these fields actually contain ip addresses e.g. anything in the range 10.x.x.x, which, to be fair, is possibly/probably the case, although since no example events were included, I, for one, have no idea.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The point I was making was more to do with how the logic of using not equals inverts the use of OR and AND.&amp;nbsp; This applies to other logical expressions, not just ip address and/or cidr notation, which is why I used a simple example to explain the point.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 06:35:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582479#M202876</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-01-26T06:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582480#M202877</link>
      <description>&lt;P&gt;Excuses. I did acknowlege that your solution works and gave your a karma. What more do you want?&lt;/P&gt;&lt;P&gt;In all seriousness, traffic logs are usually huge datasources and it's worth the effort to optimize. Some of my major pain points has been this.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 06:55:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582480#M202877</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-26T06:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Filter private ip from src AND dest</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582552#M202900</link>
      <description>&lt;P&gt;Appreciate both responses and I understand more about why my original attempts failed.&lt;/P&gt;&lt;P&gt;I went with &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190794"&gt;@johnhuang&lt;/a&gt;&amp;nbsp;solution because it offers more flexibility but the solution by&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168" target="_blank"&gt;@ITWhisperer&lt;/A&gt;&amp;nbsp;is a wonderful demonstration of why my attempts failed and I learned a lot from it.&lt;/P&gt;&lt;P&gt;Thank you both!! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 15:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-private-ip-from-src-AND-dest/m-p/582552#M202900</guid>
      <dc:creator>thin_air</dc:creator>
      <dc:date>2022-01-26T15:02:39Z</dc:date>
    </item>
  </channel>
</rss>

