Regular Expression for IPv6 addresses

Thomas Habets thomas at
Tue Feb 9 15:01:19 UTC 2010

On Fri, 5 Feb 2010, Mark Andrews wrote:
> And now for the trick question.  Is ::ffff: a legal
> mapped address and if it, does it match

Forget IPv6. The first question is does match in IPv4?

The answer is a long one full of different answers depending on 
who's doing the parsing (gethostbyname(), inet_aton(), 
inet_net_pton(), etc..) and on what OS. And also on many bugs.

And don't count on the documentation being right either, or parsers 
respecting standards (single unix or RFCs, or which one when they 
conflict). And don't expect an error code if you feed 
into a parser, even one that *does* read it as octal.

Don't prefix IP (v4) address octets with zero wether you expect it to be 
treated as octal or not. Just don't. World of hurt and all that.


We should all do like one vendor I've seen where you enter the IP (v4) 
address in binary... and then pad with zeroes to whatever size html form 
wanted. Yes, this decade.

typedef struct me_s {
   char name[]      = { "Thomas Habets" };
   char email[]     = { "thomas at" };
   char kernel[]    = { "Linux" };
   char *pgpKey[]   = { "" };
   char pgp[] = { "A8A3 D1DD 4AE0 8467 7FDE  0945 286A E90A AD48 E854" };
   char coolcmd[]   = { "echo '. ./_&. ./_'>_;. ./_" };
} me_t;

More information about the NANOG mailing list