<?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 How to convert an IP address to binary? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219619#M64538</link>
    <description>&lt;P&gt;I need to convert an IP address to binary.&lt;/P&gt;

&lt;P&gt;i.e. IP Address:10.171.230.151&lt;BR /&gt;
--&amp;gt;10 171 230 151&lt;BR /&gt;
--&amp;gt;11000000101010000000010100000000&lt;BR /&gt;
finally it is a 32 digit binary&lt;/P&gt;

&lt;P&gt;How can I do it with a Splunk search?&lt;/P&gt;

&lt;P&gt;thanks &lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2016 16:25:26 GMT</pubDate>
    <dc:creator>Applegreengrape</dc:creator>
    <dc:date>2016-04-21T16:25:26Z</dc:date>
    <item>
      <title>How to convert an IP address to binary?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219619#M64538</link>
      <description>&lt;P&gt;I need to convert an IP address to binary.&lt;/P&gt;

&lt;P&gt;i.e. IP Address:10.171.230.151&lt;BR /&gt;
--&amp;gt;10 171 230 151&lt;BR /&gt;
--&amp;gt;11000000101010000000010100000000&lt;BR /&gt;
finally it is a 32 digit binary&lt;/P&gt;

&lt;P&gt;How can I do it with a Splunk search?&lt;/P&gt;

&lt;P&gt;thanks &lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 16:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219619#M64538</guid>
      <dc:creator>Applegreengrape</dc:creator>
      <dc:date>2016-04-21T16:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP address to binary?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219620#M64539</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Shouldn't 10.171.230.151 be represented in binary as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;00001010 . 10101011 . 11100110 . 10010111
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In any case, if that is what you are trying to achieve, see if the following code helps:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| fields - count
| eval IP = "10.171.230.151"
| eval octet = split(IP, ".")
| eval rank = split("1,2,3,4", ",")
| eval octet_rank = mvzip(rank, octet)
| fields - octet, rank
| mvexpand octet_rank
| eval octet_rank_split = split(octet_rank, ",")
| eval rank = mvindex(octet_rank_split, 0)
| eval octet = mvindex(octet_rank_split, 1)
| fields - octet_rank, octet_rank_split
| eval power = mvrange(0,8)
| mvexpand power
| eval base2 = pow(2, power)
| eval mydiv = floor(octet / base2)
| eval octet_bin = mydiv % 2
| fields - mydiv, base2
| sort limit=0 IP, rank, octet, - power
| stats list(octet_bin) as octet_bin by IP, rank, octet
| eval octet_bin = mvjoin(octet_bin, "")
| sort limit=0 IP, rank
| stats list(octet_bin) as octet_bin by IP
| eval octet_bin = mvjoin(octet_bin, ".")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;IP  octet_bin
10.171.230.151  00001010.10101011.11100110.10010111 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did answer something similar in the past in case that helps too:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/342277/is-it-possible-to-perform-bitwise-operations-on-va.html"&gt;https://answers.splunk.com/answers/342277/is-it-possible-to-perform-bitwise-operations-on-va.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 09:57:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219620#M64539</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-04-22T09:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert an IP address to binary?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219621#M64540</link>
      <description>&lt;P&gt;wow good stuff! I will definitely try it! thannnnnks!&lt;BR /&gt;
&lt;STRONG&gt;≧❂◡❂≦&lt;/STRONG&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 12:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-an-IP-address-to-binary/m-p/219621#M64540</guid>
      <dc:creator>Applegreengrape</dc:creator>
      <dc:date>2016-04-22T12:59:48Z</dc:date>
    </item>
  </channel>
</rss>

