<?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: Search for multiple IP ranges in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70432#M17626</link>
    <description>&lt;P&gt;If you can express what you're looking for in CIDR notation, Splunk is smart enough to do this pretty much itself using &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;cidrmatch&lt;/CODE&gt;.  See &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Where" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Where&lt;/A&gt; for more info.&lt;/P&gt;

&lt;P&gt;But, if you really want to do octet ranges, something like this should work as a more generalized rule:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype 
| rex field=ip "(?&amp;lt;ip_octet1&amp;gt;\d+)\.(?&amp;lt;ip_octet2&amp;gt;\d+)\.(?&amp;lt;ip_octet3&amp;gt;\d+)\.(?&amp;lt;ip_octet4&amp;gt;\d+)" 
| search ( ( ip_octet1 &amp;gt;= 204 ip_octet1 &amp;lt;=207 ip_octet3 &amp;gt;=70 ) OR ip_octet3=105 )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can perform arbitrarily complex boolean expressions of &lt;CODE&gt;AND&lt;/CODE&gt;, &lt;CODE&gt;OR&lt;/CODE&gt;, and &lt;CODE&gt;NOT&lt;/CODE&gt; to get your point across, as long as you properly wrap it with parentheses.&lt;/P&gt;

&lt;P&gt;But, hopefully, the CIDR approach is much more workable for  you.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2011 05:46:55 GMT</pubDate>
    <dc:creator>dwaddle</dc:creator>
    <dc:date>2011-03-30T05:46:55Z</dc:date>
    <item>
      <title>Search for multiple IP ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70431#M17625</link>
      <description>&lt;P&gt;I am looking for the best way to search multiple IP ranges.  Currently I am using rex as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype 1.*.*.* | rex field=ip "1.\d+.\d+.(?&amp;lt;oct&amp;gt;\d+): | search oct&amp;gt;=0 oct&amp;lt;=100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works as intended and will show every value where the last octet is &lt;CODE&gt;&amp;gt;=0&lt;/CODE&gt; or &lt;CODE&gt;&amp;lt;=100&lt;/CODE&gt;.  I have 2 quesitons:&lt;/P&gt;

&lt;P&gt;[1] How can I make so I could search many ranges? Something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype 1.*.*.* | rex field=ip "1.\d+.\d+.(?&amp;lt;oct&amp;gt;\d+): | search oct&amp;gt;=0 oct&amp;lt;=100
sourcetype=mysourcetype 2.*.*.* | rex field=ip "2.\d+.\d+.(?&amp;lt;oct&amp;gt;\d+): | search oct&amp;gt;=0 oct&amp;lt;=100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;[2].  Is there a way to make so its not this range?  &lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2011 05:15:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70431#M17625</guid>
      <dc:creator>bsteelz93</dc:creator>
      <dc:date>2011-03-30T05:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Search for multiple IP ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70432#M17626</link>
      <description>&lt;P&gt;If you can express what you're looking for in CIDR notation, Splunk is smart enough to do this pretty much itself using &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;cidrmatch&lt;/CODE&gt;.  See &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Where" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Where&lt;/A&gt; for more info.&lt;/P&gt;

&lt;P&gt;But, if you really want to do octet ranges, something like this should work as a more generalized rule:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype 
| rex field=ip "(?&amp;lt;ip_octet1&amp;gt;\d+)\.(?&amp;lt;ip_octet2&amp;gt;\d+)\.(?&amp;lt;ip_octet3&amp;gt;\d+)\.(?&amp;lt;ip_octet4&amp;gt;\d+)" 
| search ( ( ip_octet1 &amp;gt;= 204 ip_octet1 &amp;lt;=207 ip_octet3 &amp;gt;=70 ) OR ip_octet3=105 )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can perform arbitrarily complex boolean expressions of &lt;CODE&gt;AND&lt;/CODE&gt;, &lt;CODE&gt;OR&lt;/CODE&gt;, and &lt;CODE&gt;NOT&lt;/CODE&gt; to get your point across, as long as you properly wrap it with parentheses.&lt;/P&gt;

&lt;P&gt;But, hopefully, the CIDR approach is much more workable for  you.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2011 05:46:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70432#M17626</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2011-03-30T05:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Search for multiple IP ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70433#M17627</link>
      <description>&lt;P&gt;CIDR matching as dwaddle suggests is the simplest if you can get it down to CIDR blocks.&lt;/P&gt;

&lt;P&gt;Another option would be to break out your range definitions into eventtypes, or to build a lookup table and search on the output -- look here:
&lt;BR /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;A href="http://answers.splunk.com/questions/5916/using-cidr-in-a-lookup-table" rel="nofollow"&gt;http://answers.splunk.com/questions/5916/using-cidr-in-a-lookup-table&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2011 07:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70433#M17627</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2011-03-30T07:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Search for multiple IP ranges</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70434#M17628</link>
      <description>&lt;P&gt;great.  I am just wondering from if from a performance perspective whats best.  If I do cidr then I could do src=1.1.1.1/8.  So my questions is would it be best to do cidrmatch(src, 1.1.1.1/8) or src=1.1.1.1/8?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2011 00:46:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-for-multiple-IP-ranges/m-p/70434#M17628</guid>
      <dc:creator>bsteelz93</dc:creator>
      <dc:date>2011-04-01T00:46:05Z</dc:date>
    </item>
  </channel>
</rss>

