Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 14
    However there's apparently a caveat, see stackoverflow.com/a/7477384/3787376 ("Max length for client ip address") - Quote: "For IPv4 mapped IPv6 addresses, the string can be longer than 39 characters.". It says that an "IPv4-mapped IPv6" is 45 characters and is in the format "NNNN:NNNN:NNNN:NNNN:NNNN:NNNN:192.168.158.190". The maximum should therefore be 45 characters. The answer at stackoverflow.com/a/166157/3787376 (this question) also seems to demonstrate this point. Commented Apr 17, 2016 at 12:26
  • That IPv4 mapping are STILL just 8 groups of 4 hex digits in IPv6 addresses. It is just a way of printing the IPv6 address. And yes, you could also add the device name with %dev suffix, for added size. I would store it in the same format, and transfer to appropriate format when showing/printing to users. Same with device, which actually is only used in link local addresses. So, 8 16:bit numbers, and add some flags for other formats and optional device name. Commented Sep 27, 2022 at 17:24
  • Not to mention the netmask, which is 32 bits for IPv4, but you only need a byte for IPv6 (as it uses CIDR format). Commented Sep 27, 2022 at 17:54
  • It seems like Google randomly latched onto this incorrect answer, since "ipv6 maximum length" responds with "39 characters". I wonder how many people have been bit by that... Commented Mar 17, 2023 at 0:54