<?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 Convert CIDR Range into list of member IPs. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292901#M88423</link>
    <description>&lt;P&gt;Given a list of CIDR ranges ... 10.198.68.132/30, 10.244.18.150/31, 10.48.37.96/24&lt;/P&gt;

&lt;P&gt;Is there a search that could extract the IPs in each range?&lt;/P&gt;

&lt;P&gt;| table cidr_range&lt;BR /&gt;
| makemv delim="/" cidr_range&lt;BR /&gt;
| eval IP = mvindex(cidr_range,0)&lt;BR /&gt;
| eval MASK = mvindex(cidr_range, 1)&lt;BR /&gt;
| eval IP_SCOPE = case(MASK = 32, IP,&lt;BR /&gt;
                       MASK = 31, IP . ":" . IP,&lt;BR /&gt;
                       MASK = 30, IP . ":" . IP . ":" . IP . ":" . IP)&lt;BR /&gt;
                       | makemv delim=":" IP_SCOPE &lt;/P&gt;

&lt;P&gt;That's kind of the start, but I'm at a loss what to do next. ( and given a /24 .... that MASK assignment would look absolutely terrible. I'd need to take each multi-value field from IP_SCOPE, and increment by one the last octet, add 1 if it's not the first value then glue them back together. There must be an easier way. &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:44:10 GMT</pubDate>
    <dc:creator>pkeller</dc:creator>
    <dc:date>2020-09-29T14:44:10Z</dc:date>
    <item>
      <title>Convert CIDR Range into list of member IPs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292901#M88423</link>
      <description>&lt;P&gt;Given a list of CIDR ranges ... 10.198.68.132/30, 10.244.18.150/31, 10.48.37.96/24&lt;/P&gt;

&lt;P&gt;Is there a search that could extract the IPs in each range?&lt;/P&gt;

&lt;P&gt;| table cidr_range&lt;BR /&gt;
| makemv delim="/" cidr_range&lt;BR /&gt;
| eval IP = mvindex(cidr_range,0)&lt;BR /&gt;
| eval MASK = mvindex(cidr_range, 1)&lt;BR /&gt;
| eval IP_SCOPE = case(MASK = 32, IP,&lt;BR /&gt;
                       MASK = 31, IP . ":" . IP,&lt;BR /&gt;
                       MASK = 30, IP . ":" . IP . ":" . IP . ":" . IP)&lt;BR /&gt;
                       | makemv delim=":" IP_SCOPE &lt;/P&gt;

&lt;P&gt;That's kind of the start, but I'm at a loss what to do next. ( and given a /24 .... that MASK assignment would look absolutely terrible. I'd need to take each multi-value field from IP_SCOPE, and increment by one the last octet, add 1 if it's not the first value then glue them back together. There must be an easier way. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292901#M88423</guid>
      <dc:creator>pkeller</dc:creator>
      <dc:date>2020-09-29T14:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert CIDR Range into list of member IPs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292902#M88424</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;P&gt;[testcsv]&lt;BR /&gt;
default_match = OK&lt;BR /&gt;
filename = testcsv.csv&lt;BR /&gt;
max_matches = 1&lt;BR /&gt;
min_matches = 1&lt;BR /&gt;
match_type = CIDR(cidr_range)&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;P&gt;[sourcetypetest]&lt;BR /&gt;
LOOKUP-test = testcsv cidr_range AS IP OUTPUTNEW field1 field2 etc&lt;/P&gt;

&lt;P&gt;I hope this help.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:41:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292902#M88424</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2020-09-29T14:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert CIDR Range into list of member IPs.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292903#M88425</link>
      <description>&lt;P&gt;The following macro displays the wildcard string matches to a given CIDR:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=cidr "^(?&amp;lt;ip_base&amp;gt;[\d\.]{7,})\/(?&amp;lt;ip_block&amp;gt;\d{1,2})$"
| rex field=ip_base "(?&amp;lt;ip1&amp;gt;\d+)\.(?&amp;lt;ip2&amp;gt;\d+)\.(?&amp;lt;ip3&amp;gt;\d+)"
| eval ip2B=case(ip_block&amp;lt;=8,"*",ip_block=16,ip2,ip_block=15,mvrange(ip2,ip2+2),ip_block=14,mvrange(ip2,ip2+4),ip_block=13,mvrange(ip2,ip2+8),ip_block=12,mvrange(ip2,ip2+16),ip_block=11,mvrange(ip2,ip2+32),ip_block=10,mvrange(ip2,ip2+64),ip_block=9,mvrange(ip2,ip2+128),1=1,ip2)
| eval ip3B=case(ip_block&amp;lt;=16,"*",ip_block=16,ip3,ip_block=23,mvrange(ip3,ip3+2),ip_block=22,mvrange(ip3,ip    3+4),ip_block=21,mvrange(ip3,ip3+8),ip_block=20,mvrange(ip3,ip3+16),ip_block=19,mvrange(ip3,ip3+32),ip_block=18,mvrange(ip3,ip3+64),ip_block=17,mvrange(ip3,ip3+128),1=1,ip3)
| mvexpand ip2B
| mvexpand ip3B
| eval ip_wildcard=ip1.".".ip2B.".".ip3B.".*" 
| fields - ip1* ip2* ip3* cidr_wildcard
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Apr 2020 20:44:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Convert-CIDR-Range-into-list-of-member-IPs/m-p/292903#M88425</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2020-04-20T20:44:31Z</dc:date>
    </item>
  </channel>
</rss>

