Regular Expression for IPv6 addresses

Mark Andrews marka at
Sun Feb 7 00:43:15 UTC 2010

In message <6eb799ab1002061452s51f9cf61p303d36130291301 at>, James 
Hess writes:
> On Fri, Feb 5, 2010 at 12:15 AM,  <sthaug at> wrote:
> >> > And now for the trick question. =A0Is ::ffff: a legal
> >> > mapped address and if it, does it match
> Wasn't there an  internet draft on that subject, recently?
>  is equivalent to  if valid at all
> RFC 4038  is very clear that the text representation of a mapped IPv4
> address is Base 10.

But is octal dotted quad.  Decimal dotted quad does
*not* have leading zeros.  The point of allowing for dotted quad
is to allow for easy mapping between IPv4 representation and IPv6
with encoded IPv4 representations.  Accepting a octal representation
as decimal is a bad thing and leads to none obvious failures.

% ping
PING ( 56 data bytes
--- ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss

"ping ::ffff:" would not get to same box if my ping
accepted that as a address literal which luckily it doesn't.

> This is a bit like asking if          "::ffff:10.1.2"  is a valid IP
> address though.

Except it clearly isn't as there are not 4 components.

> And is it the same as the ip address "10.1.2"  ?
> (Which of course expands to, on common implementations of
> inet_pton,  inet_aton, and  getaddrinfo)     Or  ::ffff:0xA010002

inet_pton() did not accept 10.1.2 when it was originally written.
This was a *deliberate* decision.  Some vendors have changed it to
accept it but they are wrong.  I can say that because I was involved
in making that decision.
> I would say these are perfectly  valid  _shorthands_  and
> abbreviations  for entering an IP address, which may be provided by
> some systems,  but that they are non-canonical  text representations
> for displaying  publishing or sharing IP addresses.

> --
> -J
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: marka at

More information about the NANOG mailing list