<?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: Eval to convert IPv6 - to IPv4 Dotted decimal format in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/612159#M212828</link>
    <description>&lt;P&gt;Had to do this today because VPN logs for eStreamer returns the IPv4 client_ip field in hex encoded IPv6 format (e.g. 104.33.245.146 is listed as 0000:0000:0000:0000:0000:ffff:6821:f592)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=estreamer
| eval A=if(like(client_ip,"0000:0000:0000:0000:0000:ffff:%"), substr(ipv6,31,9) , client_ip)
| eval src_ip=if(len(A)==9, tonumber(substr(A,1,2),16). "." .tonumber(substr(A,3,2),16). "." .tonumber(substr(A,6,2),16). "." .tonumber(substr(A,8,2),16), A)&lt;/LI-CODE&gt;&lt;P&gt;Not sure what the use case OP originally was looking for, but hope this helps someone.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;First eval compares set temp variable A to the hex-encoded IPv4 if matches the format, otherwise stores the IPv6&lt;/LI&gt;&lt;LI&gt;Second eval parses &amp;amp; converts each IPv4 octet if A is 9 characters long, othewise returns the IPv6&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope this helps someone else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Sep 2022 20:40:32 GMT</pubDate>
    <dc:creator>gordo32</dc:creator>
    <dc:date>2022-09-06T20:40:32Z</dc:date>
    <item>
      <title>How to convert IPv6 to IPv4 dotted decimal format with eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311541#M93361</link>
      <description>&lt;P&gt;I've found many samples of how to convert an IPv4 to many different formats but I can't seem to locate one to convert an IPv6 address to IPv4 - Dotted decimal format.&lt;/P&gt;
&lt;P&gt;Can anyone help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Robert&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 20:49:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311541#M93361</guid>
      <dc:creator>roayers</dc:creator>
      <dc:date>2022-09-06T20:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Eval to convert IPv6 - to IPv4 Dotted decimal format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311542#M93362</link>
      <description>&lt;P&gt;Splunk has built-in functions to convert hexadecimal to decimal: &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/ConversionFunctions#tonumber.28NUMSTR.2CBASE.29"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.2/SearchReference/ConversionFunctions#tonumber.28NUMSTR.2CBASE.29&lt;/A&gt;&lt;BR /&gt;
Using that, you can build whatever representation you like for IP addresses. &lt;/P&gt;

&lt;P&gt;I can't help you with how to write the &lt;CODE&gt;eval&lt;/CODE&gt; until you let me know how you'd like the lossy conversion from IPv6 to IPv4 to look like - keep in mind, IPv6 addresses are 128bit while IPv4 ones are only 32bit.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 23:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311542#M93362</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-02-24T23:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Eval to convert IPv6 - to IPv4 Dotted decimal format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311543#M93363</link>
      <description>&lt;P&gt;There is an RFC related to this. &lt;A href="https://tools.ietf.org/html/rfc6144"&gt;https://tools.ietf.org/html/rfc6144&lt;/A&gt; which speaks of &lt;/P&gt;

&lt;P&gt;IPv4-translatable addresses:  IPv6 addresses to be assigned to IPv6&lt;BR /&gt;
      nodes for use with stateless translation.  They have an explicit&lt;BR /&gt;
      mapping relationship to IPv4 addresses.  A stateless translator&lt;BR /&gt;
      uses the corresponding IPv4 addresses to represent the IPv6&lt;BR /&gt;
      addresses.  A stateful translator does not use this kind of&lt;BR /&gt;
      addresses, since IPv6 hosts are represented by the IPv4 address&lt;BR /&gt;
      pool in the translator via dynamic state.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 03:29:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/311543#M93363</guid>
      <dc:creator>benjimons</dc:creator>
      <dc:date>2020-02-28T03:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Eval to convert IPv6 - to IPv4 Dotted decimal format</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/612159#M212828</link>
      <description>&lt;P&gt;Had to do this today because VPN logs for eStreamer returns the IPv4 client_ip field in hex encoded IPv6 format (e.g. 104.33.245.146 is listed as 0000:0000:0000:0000:0000:ffff:6821:f592)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=estreamer
| eval A=if(like(client_ip,"0000:0000:0000:0000:0000:ffff:%"), substr(ipv6,31,9) , client_ip)
| eval src_ip=if(len(A)==9, tonumber(substr(A,1,2),16). "." .tonumber(substr(A,3,2),16). "." .tonumber(substr(A,6,2),16). "." .tonumber(substr(A,8,2),16), A)&lt;/LI-CODE&gt;&lt;P&gt;Not sure what the use case OP originally was looking for, but hope this helps someone.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;First eval compares set temp variable A to the hex-encoded IPv4 if matches the format, otherwise stores the IPv6&lt;/LI&gt;&lt;LI&gt;Second eval parses &amp;amp; converts each IPv4 octet if A is 9 characters long, othewise returns the IPv6&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope this helps someone else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 20:40:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-IPv6-to-IPv4-dotted-decimal-format-with-eval/m-p/612159#M212828</guid>
      <dc:creator>gordo32</dc:creator>
      <dc:date>2022-09-06T20:40:32Z</dc:date>
    </item>
  </channel>
</rss>

