<?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: Multi Subnets in a Macro in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51460#M12435</link>
    <description>&lt;P&gt;lguinn:  You are right, I want to run a search and determine which events had IPs that matched a list of subnets. Where am I uploading this file? Thanks,&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2013 19:02:03 GMT</pubDate>
    <dc:creator>albyva</dc:creator>
    <dc:date>2013-08-29T19:02:03Z</dc:date>
    <item>
      <title>Multi Subnets in a Macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51458#M12433</link>
      <description>&lt;P&gt;How would you structure a macro to list dozens of IP Subnets?&lt;/P&gt;

&lt;P&gt;For example: If you want a macro to list the following, what is the correct macro syntax?&lt;/P&gt;

&lt;P&gt;10.0.0.0/8&lt;BR /&gt;
172.16.0.0/12&lt;BR /&gt;
192.168.0.0/16&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 18:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51458#M12433</guid>
      <dc:creator>albyva</dc:creator>
      <dc:date>2013-08-29T18:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Subnets in a Macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51459#M12434</link>
      <description>&lt;P&gt;I am not sure why you want to use a macro. It would help if we had more context.&lt;/P&gt;

&lt;P&gt;However, if I were going to run a search that needed to determine which events had IPs that matched a list of subnets, I would use a lookup.&lt;/P&gt;

&lt;P&gt;I would create a file &lt;CODE&gt;subnet.csv&lt;/CODE&gt; that contained&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ip,subnetName
10.0.0.0/8,internal group 1
172.16.0.0/12,internal group 2
192.168.0.0/16,internal group 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc., and upload it to splunk as a lookup table.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetypehere]
LOOKUP-lsubnet = subnet_lookup ip OUTPUT subnetName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[subnet_lookup]
filename = subnet.csv
match_type = CIDR
min_matches = 1
max_matches = 1
default_match = unmatched
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you could use this search to identify events from one of the subnets:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere | where subnetName != "unmatched"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or this might be interesting&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere | stats count by subnetName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.4/Tutorial/Usefieldlookups"&gt;Splunk Lookups Tutorial&lt;/A&gt;, if you need more info. One of the nice things about this solution is that you can edit and reload the csv file with new subnets as needed, and all of the searches that use the lookup will automatically use the latest list.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 18:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51459#M12434</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-08-29T18:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Subnets in a Macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51460#M12435</link>
      <description>&lt;P&gt;lguinn:  You are right, I want to run a search and determine which events had IPs that matched a list of subnets. Where am I uploading this file? Thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51460#M12435</guid>
      <dc:creator>albyva</dc:creator>
      <dc:date>2013-08-29T19:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Subnets in a Macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51461#M12436</link>
      <description>&lt;P&gt;When you are logged into Splunk, go to the app and then to  &lt;STRONG&gt;Manager &amp;gt; Lookups&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Under &lt;STRONG&gt;Actions&lt;/STRONG&gt; for Lookup table files, click &lt;STRONG&gt;Add New&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;This will upload the file to &lt;CODE&gt;$SPLUNK_HOME/etc/apps/appname/lookups&lt;/CODE&gt; or you can move the file there directly via the OS.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2013 23:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multi-Subnets-in-a-Macro/m-p/51461#M12436</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-08-29T23:35:13Z</dc:date>
    </item>
  </channel>
</rss>

