Looking for DNS/Operational experience
Mike Leber
mleber at he.net
Sat May 9 03:28:13 CEST 2009
Hehehe, that's pretty cool that you already submitted a patch for it! :)
Mike.
Bjørn Mork wrote:
> Mike Leber <mleber at he.net> writes:
>> Bjørn Mork wrote:
>>> 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):
>> To date, I'd bet Net::IP has been used in more IPv4 code than IPv6.
>
> Sure. You just can't use the reverse_ip function. The rest of Net::IP
> is quite nice, and I certainly use it for IPv6.
>
>> The documentation for the reverse_ip function is:
>>
>> QUOTE
>> Return the reverse IP for a given IP address (in.addr. format).
>> ENDQUOTE
>>
>> It says IP address (not prefix)
>
> Oh, but it doesn't work any better with an IP address:
>
> bjorn at nemi:/tmp$ perl -e 'use Net::IP;$ip=new Net::IP("192.168.4.0");print $ip->reverse_ip()."\n"'
> 4.168.192.in-addr.arpa.
>
>> plus they probably didn't test for somebody using .0 of a prefix.
>
> No, the probably didn't. Which probably is why it doesn't work :-)
>
>> This function is just one of 27.
>>
>> If you find a behavior in a package you don't agree with:
>>
>> 1) Find out how other people made it work correctly. Read the
>> documentation and use Google. Look at what how the module writer
>> actually wrote the function you are using.
>
> I did. I sent this patch to the author in february 2008:
>
> diff -urN a/Net/IP.pm b/Net/IP.pm
> --- a/Net/IP.pm 2008-02-06 11:47:39.870067846 +0100
> +++ b/Net/IP.pm 2008-02-06 11:54:26.622068489 +0100
> @@ -1769,15 +1769,12 @@
>
> if ($ip_version == 4) {
> my @quads = split /\./, $ip;
> - my $no_quads = ($len / 8);
> + my $first_quad_index = $len ? 4 - (int($len / 8)) : 0;
>
> my @reverse_quads = reverse @quads;
>
> - while (@reverse_quads and $reverse_quads[0] == 0) {
> - shift(@reverse_quads);
> - }
> -
> - return join '.', @reverse_quads, 'in-addr', 'arpa.';
> + return join '.', @reverse_quads[ $first_quad_index .. $#reverse_quads ],
> + 'in-addr', 'arpa.';
> }
> elsif ($ip_version == 6) {
> my @rev_groups = reverse split /:/, $ip;
>
>
>> 2) Write your own perl code to handle it.
>
> I did. It's not like it's a big problem.
>
>> 3) Find another package that does what you want.
>
> It's not that important to me.
>
>> 4) Fix the module, or write a fixed version of the function, and mail
>> the module writer. Other people will probably run into the same
>> thing.
>
> Oh, they already did. See
>
> http://rt.cpan.org/Public/Bug/Display.html?id=42793
> http://rt.cpan.org/Public/Bug/Display.html?id=25169
>
>
> Bjørn
--
+---------------- H U R R I C A N E - E L E C T R I C ----------------+
| Mike Leber Wholesale IPv4 and IPv6 Transit 510 580 4100 |
| Hurricane Electric AS6939 |
| mleber at he.net Internet Backbone & Colocation http://he.net |
+---------------------------------------------------------------------+
More information about the ipv6-ops
mailing list