From owner-freebsd-questions Thu Jun 21 2:51: 1 2001 Delivered-To: freebsd-questions@freebsd.org Received: from tethys.valhalla.net (tethys.valhalla.net [195.26.32.112]) by hub.freebsd.org (Postfix) with ESMTP id 560B837B401 for ; Thu, 21 Jun 2001 02:50:57 -0700 (PDT) (envelope-from mark@tethys.valhalla.net) Received: by tethys.valhalla.net (Postfix, from userid 500) id 24DAC340CA; Thu, 21 Jun 2001 10:50:55 +0100 (BST) Date: Thu, 21 Jun 2001 10:50:55 +0100 From: Mark Drayton To: freebsd-questions@FreeBSD.ORG Subject: Re: [OT] Domain names that are just numbers -- what's this?? Message-ID: <20010621105055.B2058@tethys.valhalla.net> Mail-Followup-To: freebsd-questions@FreeBSD.ORG References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from patrick@mip.co.za on Thu, Jun 21, 2001 at 11:33:44AM +0200 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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