Looking for DNS/Operational experience

Bjørn Mork bjorn at mork.no
Fri May 8 12:20:31 CEST 2009


Mike Leber <mleber at he.net> writes:

> Since you mentioned Perl, here is a way to do it with Perl:
>
> $ perl -e 'use Net::IP;$ip=new Net::IP("2a02:c0:100::2/128");print
> ($ip->reverse_ip()."\n");'
>
> 2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.c.0.0.2.0.a.2.ip6.arpa.
>
> You'll probably find Net::IP very useful.  You can use it to write
> code that is nearly address family agnostic.

No, you can't.  You can use it for IPv6, but it fails for IPv4 (CIDR):

bjorn at nemi:/tmp$  perl -e 'use Net::IP;$ip=new Net::IP("192.168.4.0/24");print $ip->reverse_ip()."\n"'
4.168.192.in-addr.arpa.
bjorn at nemi:/tmp$  perl -e 'use Net::IP;$ip=new Net::IP("192.168.0.0/24");print $ip->reverse_ip()."\n"'
168.192.in-addr.arpa.


The output of the latter should of course have been
0.168.192.in-addr.arpa.


Bjørn


More information about the ipv6-ops mailing list