nanog mailing list archives

Re: Regular Expression for IPv6 addresses


From: Mark Andrews <marka () isc org>
Date: Fri, 05 Feb 2010 12:02:11 +1100


In message <4B6B66FF.50108 () spaghetti zurich ibm com>, Jeroen Massar writes:
Richard E. Brown wrote:
Folks,
=20
My company, Dartware, have derived a regex for testing whether an IPv6
address is correct. I've posted it in my blog:
=20
    http://intermapper.ning.com/profiles/blogs/a-regular-expression-for=
-ipv6
=20
=20
This has links to the regular expression, a (Perl) program that tests
various correct and malformed addresses, and a Ruby implementation of
the same.

You know, link local addresses (fe80::/10) are quite useless without
specifying the zone of that address. See section 11 of RFC4007.

The only proper way of "testing" if an address is a valid IPv6 address
is to feed it to getaddrinfo() and then use it through that API.
Yes, you can make some assumptions, but it has shown that people
assuming that everything stayed under 2001::/16 also got it wrong at one
point in time. Thus just feed it to getaddrinfo() if you really need it.

Greets,
 Jeroen

And now for the trick question.  Is ::ffff:077.077.077.077 a legal
mapped address and if it, does it match 077.077.077.077?

Mark
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: marka () isc org


Current thread: