<?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 convert an IP Range to an enumerated list of IP Addresses? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434686#M169124</link>
    <description>&lt;P&gt;@DalJeanis you have an extra &lt;CODE&gt;(&lt;/CODE&gt; in your rex command after &lt;CODE&gt;?&amp;lt;IP1A&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=myfield "\b(?&amp;lt;IP1A&amp;gt;(\d{1,3}\.\d{1,3}\.\d{1,3}\.)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should actually be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=myfield "\b(?&amp;lt;IP1A&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I feel the question was to generate multivalue IP Addresses from the IP Address range in the log.&lt;/P&gt;</description>
    <pubDate>Sun, 03 Jun 2018 08:12:02 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-06-03T08:12:02Z</dc:date>
    <item>
      <title>How to convert an IP Range to an enumerated list of IP Addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434683#M169121</link>
      <description>&lt;P&gt;I am receiving a field that contains IP Addresses that look like this:  192.168.1.1-192.168.1.4.  In order to make use of this information, I need to be able to create a multivalue field that lists out all the IP addresses individually (I can't use CIDR format because the list of IPs may not necessarily take up a complete CIDR range).  Any ideas on how to do this via SPL, or am I better off writing a python script to handle this?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jun 2018 00:55:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434683#M169121</guid>
      <dc:creator>arappeport</dc:creator>
      <dc:date>2018-06-03T00:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP Range to an enumerated list of IP Addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434684#M169122</link>
      <description>&lt;P&gt;1) I'd probably go with python as more manageable.  However, IF, and only if, the last node is the only one that will have a range of numbers, then a simple SPL routine would do it.&lt;/P&gt;

&lt;P&gt;This is run-anywhere aircode.  Something like this should work.  You CAN do code for if the third node could be different, but it would be a little more complex than I'd like to code without an instance to verify the logic on.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval myfield= "192.168.1.1-192.168.1.4 192.169.1.1-192.170.1.4" 
| rex field=myfield "\b(?&amp;lt;IP1A&amp;gt;(\d{1,3}\.\d{1,3}\.\d{1,3}\.)(?&amp;lt;IP1B&amp;gt;\d{1,3})-(?&amp;lt;IP2A&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.)(?&amp;lt;IP2B&amp;gt;\d{1,3})\b"
| makemv delim=" " myfield
| mvexpand myfield
| rename COMMENT as "The above creates test data"


| eval endIP=IP2B+1
| eval myflag=case(IP1A=IP2A,"OK", 
       true(),"ERROR")
| eval myfan=case(IP1A=IP2A,mvrange(IP1B,endIP), 
       true(),"ERROR")
| mvexpand myfan
| eval IPout = IP1A.".".myfan
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Jun 2018 02:34:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434684#M169122</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-03T02:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP Range to an enumerated list of IP Addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434685#M169123</link>
      <description>&lt;P&gt;@arappeport, try the following run anywhere search. Commands from &lt;CODE&gt;makeresults&lt;/CODE&gt; to &lt;CODE&gt;mvexpand&lt;/CODE&gt; generate two sample IP Address ranges i.e. &lt;CODE&gt;192.168.1.1-192.168.1.15;&lt;/CODE&gt; and &lt;CODE&gt;192.169.1.30-192.170.1.35&lt;/CODE&gt;. The rex Regular Expression is used to extract the common IP Address Prefix (in the example it is &lt;CODE&gt;192.168.1.&lt;/CODE&gt;), and the start IP and end IP i.e. &lt;CODE&gt;1, 15&lt;/CODE&gt; for &lt;CODE&gt;example 1&lt;/CODE&gt; and &lt;CODE&gt;30, 35&lt;/CODE&gt; for &lt;CODE&gt;example 2&lt;/CODE&gt; respectively. The &lt;CODE&gt;mvrange()&lt;/CODE&gt;eval function is used to generate multivalues between start and end IP. Then IP Address prefix is added to all the IPs from start to end to generate the &lt;CODE&gt;ipAddress&lt;/CODE&gt; multivalue field as requested:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval myfield= "192.168.1.1-192.168.1.15;192.169.1.30-192.170.1.35"
| makemv myfield delim=";"
| mvexpand myfield
| rex field=myfield "^(?&amp;lt;prefixIP&amp;gt;.*\.)(?&amp;lt;startIP&amp;gt;[^-]+)\-.*\.(?&amp;lt;endIP&amp;gt;[^$]+)$"
| makemv delim=" " myfield 
| mvexpand myfield
| eval endIPIndex=endIP+1
| eval ipRange=mvrange(startIP,endIPIndex,1)
| nomv ipRange
| eval ipAddress=prefixIP.replace(ipRange,"\s"," ".prefixIP)
| makemv ipAddress delim=" "
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jun 2018 08:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434685#M169123</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-03T08:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP Range to an enumerated list of IP Addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434686#M169124</link>
      <description>&lt;P&gt;@DalJeanis you have an extra &lt;CODE&gt;(&lt;/CODE&gt; in your rex command after &lt;CODE&gt;?&amp;lt;IP1A&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=myfield "\b(?&amp;lt;IP1A&amp;gt;(\d{1,3}\.\d{1,3}\.\d{1,3}\.)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should actually be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=myfield "\b(?&amp;lt;IP1A&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I feel the question was to generate multivalue IP Addresses from the IP Address range in the log.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jun 2018 08:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434686#M169124</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-03T08:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP Range to an enumerated list of IP Addresses?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434687#M169125</link>
      <description>&lt;P&gt;Works like a charm.  Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jun 2018 11:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-Range-to-an-enumerated-list-of-IP-Addresses/m-p/434687#M169125</guid>
      <dc:creator>arappeport</dc:creator>
      <dc:date>2018-06-04T11:38:44Z</dc:date>
    </item>
  </channel>
</rss>

