<?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: Providing IPAddress and Subnet Mask and getting corresponding Network Address in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250967#M48321</link>
    <description>&lt;P&gt;Look at the cidrmatch functionality. The cidrmatch function for eval can be found here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.8/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.8/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jul 2016 01:33:32 GMT</pubDate>
    <dc:creator>cpetterborg</dc:creator>
    <dc:date>2016-07-11T01:33:32Z</dc:date>
    <item>
      <title>Do we have a function or way to determine network address provided we have ip address and subnet mask?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250966#M48320</link>
      <description>&lt;P&gt;Do we have a function or way to determine network address provided we have ip address and subnet mask?&lt;/P&gt;
&lt;P&gt;For instance 10.3.3.28/24 ==&amp;gt; 10.3.3.0/24 as a simple example.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 20:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250966#M48320</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2023-08-03T20:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250967#M48321</link>
      <description>&lt;P&gt;Look at the cidrmatch functionality. The cidrmatch function for eval can be found here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.8/SearchReference/CommonEvalFunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.8/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 01:33:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250967#M48321</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2016-07-11T01:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250968#M48322</link>
      <description>&lt;P&gt;Thanks. Well the problem is that:&lt;BR /&gt;
We have two subnets in our lookup file.&lt;BR /&gt;
10.2.2.0/24&lt;BR /&gt;
10.2.0.0/16&lt;/P&gt;

&lt;P&gt;Now if we don't provide subnetmask 10.2.2.25 can match to any of these. I need a Splunk function that is given 10.2.2.25/24 and returns 10.2.2.0/24 &lt;BR /&gt;
or&lt;BR /&gt;
10.2.2.25/16 to reply with 10.2.0.0/16&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2016 02:21:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250968#M48322</guid>
      <dc:creator>nabeel652</dc:creator>
      <dc:date>2016-07-11T02:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250969#M48323</link>
      <description>&lt;P&gt;Hi, not found any built-in function, so back to network theory and maths..sorry it's ugly !&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;NET_id&lt;/STRONG&gt; contains the IP&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;NET_mask&lt;/STRONG&gt; contains the network mask&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;NET_net&lt;/STRONG&gt; is the network deducted from IP &amp;amp; Netmask&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;*&lt;EM&gt;**NET_id&lt;/EM&gt;*                    &lt;STRONG&gt;NET_mask&lt;/STRONG&gt;            =&amp;gt; &lt;STRONG&gt;NET_net&lt;/STRONG&gt;**&lt;BR /&gt;
10.140.229.2    255.255.255.0   =&amp;gt; 10.140.229.0&lt;BR /&gt;
10.140.85.10        255.255.252.0   =&amp;gt; 10.140.84.0&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;[.. Search ...]&lt;BR /&gt;
 | stats values(VLAN_name) as VLAN_name values(NET_id) as NET_id values(NET_mask) as NET_mask by ansible_host VLAN_id | eval octet = split(NET_id, ".")&lt;BR /&gt;
 | eval rank = split("1,2,3,4", ",")&lt;BR /&gt;
 | eval octet_rank = mvzip(rank, octet)&lt;BR /&gt;
 | mvexpand octet_rank&lt;BR /&gt;
 | eval octet_rank_split = split(octet_rank, ",")&lt;BR /&gt;
 | eval rank = mvindex(octet_rank_split, 0)&lt;BR /&gt;
 | eval octet = mvindex(octet_rank_split, 1)&lt;BR /&gt;
 | eval power = mvrange(0,8)&lt;BR /&gt;
 | mvexpand power&lt;BR /&gt;
 | eval base2 = pow(2, power)&lt;BR /&gt;
 | eval mydiv = floor(octet / base2) &lt;BR /&gt;
 | eval octet_bin = mydiv % 2 &lt;BR /&gt;
 | stats list(octet_bin) as octet_bin by ansible_host VLAN_id, VLAN_name, NET_id, NET_mask, rank, octet &lt;BR /&gt;
 | eval octet_bin = mvjoin(octet_bin, "") &lt;BR /&gt;
 | sort limit=0 NET_id, rank &lt;BR /&gt;
 | stats list(octet_bin) as octet_bin_ip by ansible_host VLAN_id, VLAN_name, NET_mask, NET_id &lt;BR /&gt;
 | eval octet_bin_ip = mvjoin(octet_bin_ip, "") &lt;BR /&gt;
 | eval octet = split(NET_mask, ".")&lt;BR /&gt;
 | eval rank = split("1,2,3,4", ",")&lt;BR /&gt;
 | eval octet_rank = mvzip(rank, octet)&lt;BR /&gt;
 | mvexpand octet_rank&lt;BR /&gt;
 | eval octet_rank_split = split(octet_rank, ",")&lt;BR /&gt;
 | eval rank = mvindex(octet_rank_split, 0)&lt;BR /&gt;
 | eval octet = mvindex(octet_rank_split, 1)&lt;BR /&gt;
 | eval power = mvrange(0,8)&lt;BR /&gt;
 | mvexpand power&lt;BR /&gt;
 | eval base2 = pow(2, power)&lt;BR /&gt;
 | eval mydiv = floor(octet / base2) &lt;BR /&gt;
 | eval octet_bin = mydiv % 2 &lt;BR /&gt;
 | stats list(octet_bin) as octet_bin by ansible_host VLAN_id, VLAN_name, NET_mask, NET_id, octet_bin_ip, rank, octet &lt;BR /&gt;
 | eval octet_bin = mvjoin(octet_bin, "") &lt;BR /&gt;
 | sort limit=0 NET_id, rank &lt;BR /&gt;
 | stats list(octet_bin) as octet_bin_mask by ansible_host VLAN_id, VLAN_name, NET_id,octet_bin_ip, NET_mask &lt;BR /&gt;
 | eval octet_bin_mask = mvjoin(octet_bin_mask, "")&lt;BR /&gt;&lt;BR /&gt;
 | eval rank = split("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32 ", ",") &lt;BR /&gt;
 | eval octet_bit_ip = split(octet_bin_ip, "") | eval octet_bit_mask = split(octet_bin_mask, "") &lt;BR /&gt;
 | eval bit_rank = mvzip(rank, octet_bit_ip) &lt;BR /&gt;
 | eval bit_rank = mvzip(bit_rank, octet_bit_mask) &lt;BR /&gt;
 | mvexpand bit_rank&lt;BR /&gt;&lt;BR /&gt;
 | eval bit_rank_split = split(bit_rank, ",")&lt;BR /&gt;
 | eval rank = mvindex(bit_rank_split, 0)&lt;BR /&gt;
 | eval bit_ip = mvindex(bit_rank_split, 1)&lt;BR /&gt;&lt;BR /&gt;
 | eval bit_mask = mvindex(bit_rank_split, 2) &lt;BR /&gt;
 | eval bit_net=if(bit_mask == 1, bit_ip, bit_mask) &lt;BR /&gt;
 | fields + ansible_host VLAN_id VLAN_name NET_id NET_mask bit_net rank &lt;BR /&gt;
 | eval rank=rank-1| eval rank_oct=(rank)/8 &lt;BR /&gt;
 | eval rank_oct2=rank-floor(rank_oct%8)*8 &lt;BR /&gt;
 | eval oct_dec=pow(2,rank_oct2)*bit_net &lt;BR /&gt;
 | eval rank_oct=floor(rank_oct)+1 &lt;BR /&gt;
 | stats sum(oct_dec) as oct_dec by ansible_host VLAN_id, VLAN_name, NET_id, NET_mask, rank_oct &lt;BR /&gt;
 | stats list(oct_dec) as oct_dec by ansible_host VLAN_id, VLAN_name, NET_id, NET_mask &lt;BR /&gt;
 | eval NET_net=mvjoin(oct_dec, ".") &lt;BR /&gt;
 | fields - oct_dec&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/250969#M48323</guid>
      <dc:creator>mcantaloube</dc:creator>
      <dc:date>2020-09-29T21:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513189#M87029</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;I have same query like is it possible that I can get the subnet mask and gateway for any IP address in splunksearch?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Aug 2020 06:37:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513189#M87029</guid>
      <dc:creator>Raghubansh</dc:creator>
      <dc:date>2020-08-09T06:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513202#M87033</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;as there is no mandatory address for gw in subnet that information, You couldn't get it without that it's stored to your events.&lt;/P&gt;&lt;P&gt;Quite often GW's address is first or last usable ip on subnet, but that's mostly a best practises not mandatory.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Sun, 09 Aug 2020 13:22:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513202#M87033</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-08-09T13:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513219#M87038</link>
      <description>&lt;P&gt;Can you verify question once.&lt;/P&gt;&lt;P&gt;Are you trying to get subnet/subnet mask for range of ips ( when you input first and last ip)?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Netmasks (or &lt;/SPAN&gt;&lt;STRONG&gt;subnet masks&lt;/STRONG&gt;&lt;SPAN&gt;) are a shorthand for referring to ranges of consecutive &lt;/SPAN&gt;&lt;STRONG&gt;IP&lt;/STRONG&gt;&lt;SPAN&gt; addresses in the Internet Protocol.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Aug 2020 16:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513219#M87038</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-08-09T16:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513220#M87039</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/48579"&gt;@nabeel652&lt;/a&gt;&amp;nbsp;You can do this with SPL easily.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Aug 2020 16:59:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/513220#M87039</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-08-09T16:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/533458#M89600</link>
      <description>&lt;P&gt;I had this same issue and eventually used a lookup table for decimal (0-255) to Binary conversion. I called my lookup table Decimal_To_Binary with fields Decimal/Binary. I used MyIPNet to hold the static IPv4/netmask you want to convert. In general, this will be your input field.&lt;/P&gt;&lt;P&gt;&amp;lt;main search&amp;gt;&lt;/P&gt;&lt;P&gt;| eval MyIPNet="10.162.241.94/28"&lt;BR /&gt;| eval MyIP=mvindex(split(MyIPNet,"/"),0)&lt;BR /&gt;| eval MyNetMask=mvindex(split(MyIPNet,"/"),1)&lt;BR /&gt;| eval MyIPSplit=split(MyIP,".")&lt;BR /&gt;| eval IPPadding="00000000000000000000000000000000"&lt;BR /&gt;| eval Octet1=mvindex(MyIPSplit,0), Octet2=mvindex(MyIPSplit,1),Octet3=mvindex(MyIPSplit,2),Octet4=mvindex(MyIPSplit,3)&lt;BR /&gt;| lookup Decimal_To_Binary Decimal AS Octet1 OUTPUT Binary AS OutOctet1&lt;BR /&gt;| lookup Decimal_To_Binary Decimal AS Octet2 OUTPUT Binary AS OutOctet2&lt;BR /&gt;| lookup Decimal_To_Binary Decimal AS Octet3 OUTPUT Binary AS OutOctet3&lt;BR /&gt;| lookup Decimal_To_Binary Decimal AS Octet4 OUTPUT Binary AS OutOctet4&lt;BR /&gt;| eval BinaryIP=printf("%08d",OutOctet1)+printf("%08d",OutOctet2)+printf("%08d",OutOctet3)+printf("%08d",OutOctet4)&lt;BR /&gt;| eval SubnetBinary=substr(substr(BinaryIP, 1, MyNetMask).IPPadding, 1, 32)&lt;BR /&gt;| eval IPSubNet=tonumber(substr(SubnetBinary,1,8),2).".".tonumber(substr(SubnetBinary,9,8),2).".".tonumber(substr(SubnetBinary,17,8),2).".".tonumber(substr(SubnetBinary,25,8),2)."/".MyNetMask&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:07:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/533458#M89600</guid>
      <dc:creator>gntani1981</dc:creator>
      <dc:date>2020-12-17T15:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Providing IPAddress and Subnet Mask and getting corresponding Network Address</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/653105#M110806</link>
      <description>&lt;DIV class=""&gt;For converting to network address from ip address/mask or prefix,&lt;BR /&gt;I added the following external command lookup to the App below.&lt;/DIV&gt;&lt;DIV class=""&gt;Usage:&lt;/DIV&gt;&lt;PRE&gt;| makeresults
| eval ip="&lt;SPAN&gt;10.3.3.28/24&lt;/SPAN&gt;"
| lookup local=t ipcalclookup Address as ip OUTPUT Network Prefix
| eval netaddr=Network."/".Prefix&lt;/PRE&gt;&lt;DIV class=""&gt;Input Address can also be in the following format.&lt;BR /&gt;* ip/netmask: e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;192.0.2.17/255.255.255.240&lt;BR /&gt;* ip/prefix: e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;192.0.2.17/28&lt;BR /&gt;* ipv6/prefix: e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2001:db8:1234::1/64&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Numeral system macros for Splunk&lt;BR /&gt;&lt;A class="" href="https://splunkbase.splunk.com/app/6595" target="_blank" rel="noopener noreferrer"&gt;https://splunkbase.splunk.com/app/6595&lt;/A&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 19:54:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Do-we-have-a-function-or-way-to-determine-network-address/m-p/653105#M110806</guid>
      <dc:creator>tfujita_splunk</dc:creator>
      <dc:date>2023-08-03T19:54:30Z</dc:date>
    </item>
  </channel>
</rss>

