0

I have IPv6 in decimal format, I am trying to convert it into the ip addresses then converting the start and end ip addresses into CIDR notation using PowerShell.

Sample Data:

startIP: "281470698520851"
endIP: "281470698520851"

Result:

ipv6-range: "::ffff:1.0.1.19/128"

JSON Data for elastic:

{"index":{"_index":"enrich-data-ipv6-range-vpn","_id":"ffff10119128"}}
{"startIP":"281470698520851","endIP":"281470698520851","ipv6-range":"::ffff:1.0.1.19/128"}

Index Mapping:

{
  "_doc": {
    "_routing": {
      "required": false
    },
    "dynamic": false,
    "_source": {
      "excludes": [],
      "includes": [],
      "enabled": true
    },
    "dynamic_templates": [],
    "properties": {
      "ipv6-range": {
        "type": "ip_range"
      }
    }
  }
}

I am using elastic bulk API to post the JSON data but getting below error

"reason": "CIDR notation is not allowed with IPv6-mapped IPv4 address '::ffff:1.0.1.19' as it introduces ambiguity as to whether the prefix length should be interpreted as a v4 prefix length or a v6 prefix length"

Could someone help me converting the ipv6 into correct format.

Naveen Kumar
  • 1,266
  • 1
  • 21
  • 50
  • The IPv6 IPv4-Mapped addressing is _not_ actually IPv6 addressing; it is IPv4 addressing formatted as IPv6 addressing in order to have a common format to store the text representations of IP addresses. IPv4-Mapped addresses are not allowed to be use as source or destination addresses, nor are they allowed to be forwarded, and this is part of the IPv6 protocol, itself. See the _[ANA IPv6 Special-Purpose Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml)_. – Ron Maupin Apr 20 '23 at 12:36
  • Thanks @RonMaupin do you know how to convert above ip decimal to ipv4 address as I am getting ip decimal data for both ipv4 mapped and actual ipv6 is there any way to differentiate before converting to ip address ex: `47861213238125828469483745266362220544` and `281470698520851` – Naveen Kumar Apr 21 '23 at 05:08

0 Answers0