<?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: cidrmatch between 2 csv files in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556253#M157955</link>
    <description>&lt;P&gt;sounds like a plan - Thx. Will give the wildcard suggestion a try. Otherwise, those who stumble upon this post can also try Excel Power Query to split a row into multiple rows&lt;/P&gt;&lt;P&gt;&lt;A href="https://sfmagazine.com/post-entry/november-2017-excel-split-delimited-data-into-new-rows/" target="_blank"&gt;Excel: Split Delimited Data into New Rows - Strategic Finance (sfmagazine.com)&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jun 2021 00:34:13 GMT</pubDate>
    <dc:creator>munisb</dc:creator>
    <dc:date>2021-06-18T00:34:13Z</dc:date>
    <item>
      <title>cidrmatch between 2 csv files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556058#M157890</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have two csv files where I am trying to cidrmatch between ip and subnet - but it doesn't appear to be working&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;test1.csv&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;host	ip
abc	192.168.1.1
def	192.168.2.2
xyz	192.168.3.3&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;test2.csv&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;zone	  subnet
dmz	        192.168.1.1
internet	192.168.2.0/24
management	192.168.1.0/24&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SPL (returns blank)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup test1.csv | lookup test2.csv subnet | where cidrmatch("192.168.1.0/24", ip) | table host ip subnet zone&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;whereas if I run the following - I get a match (the zone &amp;amp; subnet fields are blank)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup test1.csv | lookup test2.csv subnet | where cidrmatch("192.168.1.0/24", ip) | table host ip subnet zone&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;will appreciate some guidance. Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 22:20:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556058#M157890</guid>
      <dc:creator>munisb</dc:creator>
      <dc:date>2021-06-16T22:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: cidrmatch between 2 csv files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556060#M157892</link>
      <description>&lt;P&gt;OK...&lt;/P&gt;&lt;P&gt;Your first part of the search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup test1.csv | lookup test2.csv subnet&lt;/LI-CODE&gt;&lt;P&gt;You test1.csv has no field called subnet, so the lookup test2.csv will never match anything as the subnet field is always null. The field passed to lookup is the one in the data you - so the syntax would be 'subnet as ip'&lt;/P&gt;&lt;P&gt;If you run this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup test1.csv 
| lookup test2.csv subnet as ip output subnet zone&lt;/LI-CODE&gt;&lt;P&gt;you will see that ONLY abc will return the dmz zone - that is because a CSV file lookup requires an exact match on the data being searched, hence ip 192.168.1.1 will match the subnet of the same value.&lt;/P&gt;&lt;P&gt;If you want to use a CIDR match in the lookup, you can set up a lookup definition (call it test2) that sits on top of the test2.csv and you can use the advanced options to set the match type to&amp;nbsp;CIDR(subnet).&lt;/P&gt;&lt;P&gt;Then if you run this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup test1.csv 
| lookup test2 subnet as ip output subnet zone&lt;/LI-CODE&gt;&lt;P&gt;i.e. using the lookup definition test2 rather than the file test2.csv, you will see it returns management for abc and internet for def. It will not return dmz for abc, as the subnet is not CIDR qualified.&lt;/P&gt;&lt;P&gt;If you then edit your test2.csv and change the subnet for the dmz zone to be 192.168.1.1/32&lt;/P&gt;&lt;P&gt;then the above search will return both dmz and management for abc as that IP is in both CIDR ranges.&lt;/P&gt;&lt;P&gt;You can always then filter down the smallest CIDR range to get the closest CIDR match for the combination of zone/subnet needed from the multi-valued results you get back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 22:56:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556060#M157892</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-16T22:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: cidrmatch between 2 csv files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556248#M157952</link>
      <description>&lt;P&gt;That did the trick Thank you.&lt;/P&gt;&lt;P&gt;One follow up question&lt;/P&gt;&lt;P&gt;in my test1.csv some of the cells have multiple IP addresses if a host has multiple NICs. Example:&lt;/P&gt;&lt;P&gt;1.1.1.1, 2.2.2.2&lt;BR /&gt;3.3.3.3, 4.4.4.4, 5.5.5.5&lt;/P&gt;&lt;P&gt;I tried with "*IP*" and *IP* - however that doesn't return any results for zone.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 23:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556248#M157952</guid>
      <dc:creator>munisb</dc:creator>
      <dc:date>2021-06-17T23:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: cidrmatch between 2 csv files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556249#M157953</link>
      <description>&lt;P&gt;You can also make a field a wldcard field through the lookup definition, e.g. match type WILDCARD(subnet)&lt;/P&gt;&lt;P&gt;but not sure if you can do both wildcard and cidr for the same field, but in that case, you have to have the * characters in the lookup data.&lt;/P&gt;&lt;P&gt;The simplest way to do it would be to have one ip per host, so there are multiple rows for those hosts in your example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 23:17:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556249#M157953</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-06-17T23:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: cidrmatch between 2 csv files</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556253#M157955</link>
      <description>&lt;P&gt;sounds like a plan - Thx. Will give the wildcard suggestion a try. Otherwise, those who stumble upon this post can also try Excel Power Query to split a row into multiple rows&lt;/P&gt;&lt;P&gt;&lt;A href="https://sfmagazine.com/post-entry/november-2017-excel-split-delimited-data-into-new-rows/" target="_blank"&gt;Excel: Split Delimited Data into New Rows - Strategic Finance (sfmagazine.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 00:34:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cidrmatch-between-2-csv-files/m-p/556253#M157955</guid>
      <dc:creator>munisb</dc:creator>
      <dc:date>2021-06-18T00:34:13Z</dc:date>
    </item>
  </channel>
</rss>

