<?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 Subnet collection in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123246#M33264</link>
    <description>&lt;P&gt;I want to be able to find the most vulnerable subnet. I know how to verify if an ip is in a subnet by using the cirdmatch function, but I want to collect subnets into a transaction (or just a collection) and then be able to do a search on these subnets to find which one contains the most number of vulnerabilities.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 08 Apr 2014 05:31:17 GMT</pubDate>
    <dc:creator>splunkinmcsplun</dc:creator>
    <dc:date>2014-04-08T05:31:17Z</dc:date>
    <item>
      <title>Subnet collection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123246#M33264</link>
      <description>&lt;P&gt;I want to be able to find the most vulnerable subnet. I know how to verify if an ip is in a subnet by using the cirdmatch function, but I want to collect subnets into a transaction (or just a collection) and then be able to do a search on these subnets to find which one contains the most number of vulnerabilities.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 05:31:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123246#M33264</guid>
      <dc:creator>splunkinmcsplun</dc:creator>
      <dc:date>2014-04-08T05:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Subnet collection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123247#M33265</link>
      <description>&lt;P&gt;First of all you need to be able to define what a subnet is...&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 08:04:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123247#M33265</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-04-08T08:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Subnet collection</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123248#M33266</link>
      <description>&lt;P&gt;If you have a small number of subnets, you could use a technique like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Vulnerability search&amp;gt; ... | eval subnet=case(cidrmatch("10.0.0.0/24", ip), "Subnet 10.0.0.x",  cidrmatch("10.0.0.1/24", ip), "Subnet 10.0.1.x",  0==0, "Unknown subnet") | stats count by subnet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As long as &lt;CODE&gt;&amp;lt;Vulnerability search&amp;gt;&lt;/CODE&gt; returns events with an &lt;CODE&gt;ip&lt;/CODE&gt; field, this simple technique should work.  As far as I know, there's no simple way to automatically group IPs into subnets without actually defining what size of each individual network.&lt;/P&gt;

&lt;P&gt;If all of your networks are "/24"s, then you could do something trivial like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Vulnerability search&amp;gt; ... | eval subnet=replace(ip, "^(\d+\.\d+\.\d+\).\d+$", "\1.x") | stats count by subnet
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that's about as far as regex tricks will take you. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;BTW, if you have a large range of subnets, or want an approach that more generally reusable, then I'd recommend using lookups.  See the answer &lt;A href="http://answers.splunk.com/answers/5916/using-cidr-in-a-lookup-table"&gt;Using CIDR in a lookup table&lt;/A&gt; for the specifics on how to set this up in a lookup file.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Apr 2014 20:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subnet-collection/m-p/123248#M33266</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2014-04-16T20:53:49Z</dc:date>
    </item>
  </channel>
</rss>

