<?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: match an IP with a CIDR mask into a CSV file in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63195#M12682</link>
    <description>&lt;P&gt;Suggested correction: should use &lt;CODE&gt;fields_list = subnet, building&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2014 15:27:28 GMT</pubDate>
    <dc:creator>slierninja</dc:creator>
    <dc:date>2014-01-16T15:27:28Z</dc:date>
    <item>
      <title>match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63186#M12673</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I want to make match my IP in my logs with subnets specified into a CSV file.&lt;/P&gt;

&lt;P&gt;Here's is my CSV file &lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;subnet,building&lt;BR /&gt;
10.1.0.0/16,Building 1&lt;BR /&gt;
10.3.0.0/16,Building 2&lt;BR /&gt;
10.4.0.0/16,Building 3&lt;BR /&gt;
10.5.0.0/16,Building 4&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;I think my issue comes from the tranforms.conf file where i added the following lines&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;[dshq]&lt;BR /&gt;
filename = dshq.csv&lt;BR /&gt;
match_type = CIDR(host)&lt;BR /&gt;
fileds_list = subnet, building&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;I want to count the number of hosts grouped by buildings using the IP range&lt;/P&gt;

&lt;P&gt;And here is my search &lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;sourcetype=nessus N_cvss&amp;gt;9 N_dnt=0 | rex "(?i)^[^\t]*\t(?P&lt;SUBNET&gt;[^\t]+)" | lookup dshq subnet as subnet OUTPUT building as building | sort - count | chart count over building by subnet&lt;/SUBNET&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;I have no building field generated, could you please tell me why ?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;EDIT : The regex (subnet) is my search refers to the host IP in my logs&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63186#M12673</guid>
      <dc:creator>rbw78</dc:creator>
      <dc:date>2020-09-28T10:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63187#M12674</link>
      <description>&lt;P&gt;We're gonna buy your product, some help would be appreciate &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2012 15:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63187#M12674</guid>
      <dc:creator>rbw78</dc:creator>
      <dc:date>2012-02-02T15:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63188#M12675</link>
      <description>&lt;P&gt;There is a spelling issue with your transforms.conf... "fileds_list" should be "fields_list". And also, not sure if it is because you haven't defined a full file path to the lookup (I know this shouldn't matter... I find it helps though).&lt;/P&gt;

&lt;P&gt;When troubleshooting csv lookups... I always start with a command like "&lt;CODE&gt;|inputlookup &amp;lt;csvfile&amp;gt;&lt;/CODE&gt;" to make sure the is appearing as expected (sanity check)&lt;/P&gt;

&lt;P&gt;Also have you checked your regex works correctly... could you not include the following to be a little more exact "&lt;CODE&gt;(?P&amp;lt;ip&amp;gt;\d+\.\d+\.\d+\.\d+)&lt;/CODE&gt;" (or even replace the "&lt;CODE&gt;+&lt;/CODE&gt;" in the regex with "&lt;CODE&gt;{1,3}&lt;/CODE&gt;" as an ip would only have between one and three digits).&lt;/P&gt;

&lt;P&gt;The way I normally do something like this would be to use the search syntax a little more than the conf files. But my setup would be like this..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[&amp;lt;csv_file_without_".csv"_extension&amp;gt;]
filename = $SPLUNK_HOME/etc/apps/&amp;lt;app_dir&amp;gt;/lookups/&amp;lt;csvfile&amp;gt;.csv
max_matches = 1000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[dshq]
filename = $SPLUNK_HOME/&amp;lt;full_path_to_csv&amp;gt;/dshq.csv
max_matches = 1000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then if I need to do a cidr match, I would use "&lt;CODE&gt;where cidrmatch(&amp;lt;field1&amp;gt;, &amp;lt;field2&amp;gt;)&lt;/CODE&gt;", to match only those with a match CIDR Block.&lt;/P&gt;

&lt;P&gt;Also in your lookup command, as part of your search syntax,you do not need to rename fields if the fieldnames match up... i.e. you have named your CSV fields to match those in Splunk... so you simply need to change the lookup part from ...&lt;/P&gt;

&lt;P&gt;"&lt;CODE&gt;lookup dshq subnet as subnet OUTPUT building as building&lt;/CODE&gt;"&lt;/P&gt;

&lt;P&gt;to...&lt;/P&gt;

&lt;P&gt;"&lt;CODE&gt;lookup dshq subnet OUTPUT building&lt;/CODE&gt;"&lt;/P&gt;

&lt;P&gt;Not really much difference just less search syntax &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps. I know it's not an answer as such, just some tips (which may be rubbish) &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; .&lt;/P&gt;

&lt;P&gt;MHibbin&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63188#M12675</guid>
      <dc:creator>MHibbin</dc:creator>
      <dc:date>2020-09-28T10:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63189#M12676</link>
      <description>&lt;P&gt;Thanks for the answer MHibbin &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;in fact, I don't want to use the cidrmtach function in the search because i have too much subnets.&lt;BR /&gt;
I made an exemple with 4 subnets but i need to register about 50, that's why i prefer using a CSV file for  cidr matching.&lt;BR /&gt;
Is possible to do it that way ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2012 09:22:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63189#M12676</guid>
      <dc:creator>rbw78</dc:creator>
      <dc:date>2012-02-03T09:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63190#M12677</link>
      <description>&lt;P&gt;someone could help ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2012 14:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63190#M12677</guid>
      <dc:creator>rbw78</dc:creator>
      <dc:date>2012-02-03T14:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63191#M12678</link>
      <description>&lt;P&gt;Hello rbw78,&lt;/P&gt;

&lt;P&gt;I had this same problem and here's what I found on splunk-base.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answer_link/5938/"&gt;http://splunk-base.splunk.com/answer_link/5938/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Will&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2012 17:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63191#M12678</guid>
      <dc:creator>wfroning</dc:creator>
      <dc:date>2012-02-04T17:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63192#M12679</link>
      <description>&lt;P&gt;Hello Will&lt;/P&gt;

&lt;P&gt;Thanks for the answer.&lt;BR /&gt;
I tried the python script to do my cidr matching but it doesn't work.&lt;BR /&gt;
It seems my csv file column are well recognized by splunk but when i do my search and specified in output the subnet_name i only have the orginal logs.&lt;/P&gt;

&lt;P&gt;Something must be wrong ...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2012 10:03:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63192#M12679</guid>
      <dc:creator>rbw78</dc:creator>
      <dc:date>2012-02-07T10:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63193#M12680</link>
      <description>&lt;P&gt;@rbw78, Did you reformat your csv file to be the same as the example? What happens when "it doesn't work"?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2012 11:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63193#M12680</guid>
      <dc:creator>wfroning</dc:creator>
      <dc:date>2012-02-07T11:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63194#M12681</link>
      <description>&lt;P&gt;it failed because the match_type has to apply on the field in the lookup table.&lt;BR /&gt;
use match_type = CIDR(subnet) instead.&lt;/P&gt;

&lt;P&gt;Here's is my CSV file &lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
subnet,building&lt;BR /&gt;
10.1.0.0/16,Building 1&lt;BR /&gt;
10.3.0.0/16,Building 2&lt;BR /&gt;
10.4.0.0/16,Building 3&lt;BR /&gt;
10.5.0.0/16,Building 4&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Transforms.conf&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[dshq]&lt;BR /&gt;
filename = dshq.csv&lt;BR /&gt;
match_type = CIDR(subnet)&lt;BR /&gt;
fileds_list = subnet, building&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;search example with a field IP&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;*  | lookup dshq subnet as IP OUTPUT building&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63194#M12681</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2020-09-28T13:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: match an IP with a CIDR mask into a CSV file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63195#M12682</link>
      <description>&lt;P&gt;Suggested correction: should use &lt;CODE&gt;fields_list = subnet, building&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2014 15:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/match-an-IP-with-a-CIDR-mask-into-a-CSV-file/m-p/63195#M12682</guid>
      <dc:creator>slierninja</dc:creator>
      <dc:date>2014-01-16T15:27:28Z</dc:date>
    </item>
  </channel>
</rss>

