Regular Expression for IPv6 addresses

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


In message <6eb799ab1002061452s51f9cf61p303d36130291301 at mail.gmail.com>, James 
Hess writes:
> On Fri, Feb 5, 2010 at 12:15 AM,  <sthaug at nethelp.no> wrote:
> >> > And now for the trick question. =A0Is ::ffff:077.077.077.077 a legal
> >> > mapped address and if it, does it match 077.077.077.077?
> 
> Wasn't there an  internet draft on that subject, recently?
> http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
> 
> 077.077.077.077  is equivalent to  77.77.77.77  if valid at all
> RFC 4038  is very clear that the text representation of a mapped IPv4
> address is Base 10.     http://tools.ietf.org/html/rfc4038#section-5.1

But 077.077.077.077 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 077.077.077.077
PING 077.077.077.077 (63.63.63.63): 56 data bytes
^C
--- 077.077.077.077 ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
%

"ping ::ffff:077.077.077.077" 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  10.1.0.2, 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 isc.org




More information about the NANOG mailing list