Date: Thu, 21 Jun 2001 10:50:55 +0100 From: Mark Drayton <mark.drayton@4thwave.co.uk> To: freebsd-questions@FreeBSD.ORG Subject: Re: [OT] Domain names that are just numbers -- what's this?? Message-ID: <20010621105055.B2058@tethys.valhalla.net> In-Reply-To: <NDBBIMKICMDGDMNOOCAICEOPCMAA.patrick@mip.co.za>; from patrick@mip.co.za on Thu, Jun 21, 2001 at 11:33:44AM %2B0200 References: <H0000e990840a470@MHS> <NDBBIMKICMDGDMNOOCAICEOPCMAA.patrick@mip.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
Patrick O'Reilly (patrick@mip.co.za) wrote: > Andrei, > > you said: --- Original Message --- > > Take the number and convert it to hex, then take each 2 hex digits > > and convert to decimal. > ... as seen in earlier mail from ravi --> [188.]63.107.146.186 --- > > Please forgive my ignorance, but what's the [188.] doing before the > rest of the IP??? The problem is that an IP address is a 32 bit unsigned int (4 bytes) but 808517866170 is a 40 bit int (5 bytes). The first byte is junk, and it appears that the MS TCP/IP stack (and FreeBSD sometimes) drops it. This is where the 188 comes from. I don't know if this is correct, or even if there is a document defining what to do with IP addresses that are more than 32 bits. Pointers? Here's a perl program that will convert the 4 lowest bytes from a decimal IP address to a dotted quad IP addresses: ----start---- #!/usr/bin/perl -w use strict; use Math::BigInt; my $dec = Math::BigInt->new($ARGV[0]); my $i = 0; my @ip; while ($i <= 3) { push @ip, ($dec >> ($i * 8)) & 255; $i++; } print join('.', reverse(@ip)) . "\n"; ----end---- The output is a bit ugly (I can't find out how to change a Math::BigInt object back to a scalar... suggestions appreciated): [mark@tethys perl]$ perl ip.pl 808517866170 +63.+107.+146.+186 Cheers, -- Mark Drayton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010621105055.B2058>