<?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: How to search on IP range and not IP subnet? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244799#M72914</link>
    <description>&lt;P&gt;Assuming the ip field looks like this: &lt;BR /&gt;
"192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1"&lt;/P&gt;

&lt;P&gt;You can convert it to multivalue field, and then expand to rows:&lt;BR /&gt;
 |makemv delim="-" ip |mvexpand ip&lt;/P&gt;

&lt;P&gt;"192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1" -&amp;gt;&lt;BR /&gt;
ip&lt;BR /&gt;
192.168.1.1&lt;BR /&gt;
192.168.1.2&lt;BR /&gt;
192.168.1.3&lt;BR /&gt;
10.0.0.1&lt;/P&gt;

&lt;P&gt;Full example:&lt;BR /&gt;
 | makeresults count=1 |eval ip="192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1" |table ip&lt;BR /&gt;
 |makemv delim="-" ip |mvexpand ip&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2017 11:59:33 GMT</pubDate>
    <dc:creator>ehudb</dc:creator>
    <dc:date>2017-01-20T11:59:33Z</dc:date>
    <item>
      <title>How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244798#M72913</link>
      <description>&lt;P&gt;Hi we currently consuming threat intelligence data and want to correlate this in Splunk in a good way.&lt;BR /&gt;
The problem is that some of the feeds deliver IP addresses in the format of ip-ip and not ip/subnet.&lt;BR /&gt;
How can i make Splunk look at ip-ip as individual IP addresses to match against our firewall logs?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:59:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244798#M72913</guid>
      <dc:creator>honey4sec</dc:creator>
      <dc:date>2017-01-20T10:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244799#M72914</link>
      <description>&lt;P&gt;Assuming the ip field looks like this: &lt;BR /&gt;
"192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1"&lt;/P&gt;

&lt;P&gt;You can convert it to multivalue field, and then expand to rows:&lt;BR /&gt;
 |makemv delim="-" ip |mvexpand ip&lt;/P&gt;

&lt;P&gt;"192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1" -&amp;gt;&lt;BR /&gt;
ip&lt;BR /&gt;
192.168.1.1&lt;BR /&gt;
192.168.1.2&lt;BR /&gt;
192.168.1.3&lt;BR /&gt;
10.0.0.1&lt;/P&gt;

&lt;P&gt;Full example:&lt;BR /&gt;
 | makeresults count=1 |eval ip="192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1" |table ip&lt;BR /&gt;
 |makemv delim="-" ip |mvexpand ip&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 11:59:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244799#M72914</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-01-20T11:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244800#M72915</link>
      <description>&lt;P&gt;The ip Field looks like this&lt;BR /&gt;
192.168.3.35-192.168.3.47&lt;BR /&gt;
I don't think think the answer apply to this.&lt;BR /&gt;
But im not a splunk superman yet&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 12:37:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244800#M72915</guid>
      <dc:creator>honey4sec</dc:creator>
      <dc:date>2017-01-20T12:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244801#M72916</link>
      <description>&lt;P&gt;What's the different from your example:&lt;BR /&gt;
192.168.3.35-192.168.3.47&lt;/P&gt;

&lt;P&gt;To my example:&lt;BR /&gt;
192.168.1.1-192.168.1.2-192.168.1.3-10.0.0.1&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:06:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244801#M72916</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-01-20T18:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244802#M72917</link>
      <description>&lt;P&gt;Assuming your threat ip fields are ip range:&lt;BR /&gt;
 "192.168.1.1-192.168.1.100" means ALL IP addresses between the range: 192.168.1.1,2,3,...100&lt;/P&gt;

&lt;P&gt;You can use the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=firewall |table fwsrc
|append [index=threat |table threatip ]

|makemv threatip delim="-" |eval startip=mvindex(threatip,0) |eval endip=mvindex(threatip,1)
|table fwsrc startip  endip
|eventstats values(startip) as startip values(endip)  as endip
|stats count by fwsrc startip endip
|eval isThreat = if(fwsrc&amp;gt;=startip AND fwsrc&amp;lt;=endip,"T","F")
|stats values(isThreat) as isThreat by fwsrc |eval isThreat=if(isThreat=="T","T","F")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Explanation:&lt;BR /&gt;
|makemv threatip delim="-"  will convert the range to multivalue field with start and end&lt;BR /&gt;
mvindex will extract them to new fields&lt;BR /&gt;
eventstats will spread the threat ranges across the entire table&lt;BR /&gt;
(fwsrc&amp;gt;=startip) can decide if fwsrc is 'bigger' than startip, means all it's 4 parts are above or equal to the other ip.&lt;BR /&gt;
(fwsrc&amp;gt;=endtip) works the same in the opposite side&lt;BR /&gt;
|stats values and eval will finally show only the ip that detected as threat in one of the ranges.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Another working approach would be converting all the ranges to a where clause in subsearch:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=firewall |table fwsrc
|where
[index=threat |table threatip |makemv threatip delim="-" |eval startip=mvindex(threatip,0) |eval endip=mvindex(threatip,1) |table startip endip
|eval where="fwsrc&amp;gt;=\""+startip+"\" AND fwsrc&amp;lt;=\""+endip+"\""  |return 10000 $where]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch here assembles the table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;threatip
-----------
192.168.1.2-192.168.1.100
10.0.0.1-10.1.0.100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;into a single line where clause:&lt;BR /&gt;
(fwsrc&amp;gt;="192.168.1.2" AND fwsrc&amp;lt;="192.168.1.100") OR (fwsrc&amp;gt;="10.0.0.1" AND fwsrc&amp;lt;="10.0.0.100")&lt;/P&gt;

&lt;P&gt;Then, the |where command is using this string to filter the results.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 19:41:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244802#M72917</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-01-20T19:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to search on IP range and not IP subnet?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244803#M72918</link>
      <description>&lt;P&gt;Ok I understand the range is |fromip-toip"&lt;BR /&gt;
I will post new answer according to this&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 19:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-on-IP-range-and-not-IP-subnet/m-p/244803#M72918</guid>
      <dc:creator>ehudb</dc:creator>
      <dc:date>2017-01-20T19:42:06Z</dc:date>
    </item>
  </channel>
</rss>

