kcc wrote:
I search google but couldn't get any solution
Can you send me information?
Easiest way. Take the integer, plug it into windows 'calc'. Go to 'View: Scientific'. Hit 'Hex'. That will show you the hex representation of the integer. Notice that it's either 7 or 8 characters long. If it's 7, prepend it with a 0. Break that into 4 groups of 2. Those are the hex values for the four dotted quads. Make sure 'Hex' is still selected, and put in the first 2 characters, then hit 'binary'. That's your first part of the IP. Repeat for the other 3. For example, you have 1089055123 for an integer. In Hex thats 40E9A993. 40 Hex = 64 E9 Hex = 233 A9 Hex = 169 94 Hex = 147 So your IP is 64.233.169.147 Ken ________________________________ From: Colin Alston [mailto:karnaugh@karnaugh.za.net] Sent: Wed 8/27/2008 5:21 AM To: kcc Cc: nanog@nanog.org Subject: Re: interger to I P address kcc wrote:
I search google but couldn't get any solution
Can you send me information?
On 27 aug 2008, at 14:18, Matlock, Kenneth L wrote:
Easiest way.
$ ping 1089055123 PING 1089055123 (64.233.169.147): 56 data bytes 64 bytes from 64.233.169.147: icmp_seq=0 ttl=242 time=105.418 ms 64 bytes from 64.233.169.147: icmp_seq=1 ttl=242 time=105.891 ms ^C --- 1089055123 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 105.418/105.655/105.891/0.236 ms :-)
On Wed, Aug 27, 2008 at 02:27:24PM +0200, Iljitsch van Beijnum <iljitsch@muada.com> wrote a message of 14 lines which said:
Easiest way.
$ ping 1089055123 PING 1089055123 (64.233.169.147): 56 data bytes
It relies on an undocumented feature (it is not in RFC 791, nor in getaddrinfo() manual) :-)
Huh, learn something new every day! Well, at least my method shows the underlying theory behind how the conversion works :) Thanks! Ken Matlock Network Analyst (303) 467-4671 matlockk@exempla.org -----Original Message----- From: Iljitsch van Beijnum [mailto:iljitsch@muada.com] Sent: Wednesday, August 27, 2008 6:27 AM To: Matlock, Kenneth L Cc: Colin Alston; kcc; nanog@nanog.org Subject: Re: interger to I P address On 27 aug 2008, at 14:18, Matlock, Kenneth L wrote:
Easiest way.
$ ping 1089055123 PING 1089055123 (64.233.169.147): 56 data bytes 64 bytes from 64.233.169.147: icmp_seq=0 ttl=242 time=105.418 ms 64 bytes from 64.233.169.147: icmp_seq=1 ttl=242 time=105.891 ms ^C --- 1089055123 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 105.418/105.655/105.891/0.236 ms :-)
The harder way: Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147 Robert D. Scott Robert@ufl.edu Senior Network Engineer 352-273-0113 Phone CNS - Network Services 352-392-2061 CNS Receptionist University of Florida 352-392-9440 FAX Florida Lambda Rail 352-294-3571 FLR NOC Gainesville, FL 32611 321-663-0421 Cell -----Original Message----- From: Matlock, Kenneth L [mailto:MatlockK@exempla.org] Sent: Wednesday, August 27, 2008 9:47 AM To: Iljitsch van Beijnum Cc: nanog@nanog.org Subject: RE: interger to I P address Huh, learn something new every day! Well, at least my method shows the underlying theory behind how the conversion works :) Thanks! Ken Matlock Network Analyst (303) 467-4671 matlockk@exempla.org -----Original Message----- From: Iljitsch van Beijnum [mailto:iljitsch@muada.com] Sent: Wednesday, August 27, 2008 6:27 AM To: Matlock, Kenneth L Cc: Colin Alston; kcc; nanog@nanog.org Subject: Re: interger to I P address On 27 aug 2008, at 14:18, Matlock, Kenneth L wrote:
Easiest way.
$ ping 1089055123 PING 1089055123 (64.233.169.147): 56 data bytes 64 bytes from 64.233.169.147: icmp_seq=0 ttl=242 time=105.418 ms 64 bytes from 64.233.169.147: icmp_seq=1 ttl=242 time=105.891 ms ^C --- 1089055123 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 105.418/105.655/105.891/0.236 ms :-)
Robert D. Scott wrote:
The harder way:
Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147
The Python way
import socket, struct socket.inet_ntoa(struct.pack('>l', 1089055123)) '64.233.169.147'
Robert D. Scott wrote:
The harder way:
Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147
The "this could take all day" way : (in bc with scale=0 for integer portions only) 1089055123/(2^24)%(2^8) 64 1089055123/(2^16)%(2^8) 233 1089055123/(2^8)%(2^8) 169 1089055123/(2^0)%(2^8) 147 (Note: 2^0=1 & x/1=x so last line could reduce to 1089055123%(2^8).) -Nicholas shadow@gti.net
Normally, I don't participate in this sort of thing, but I'm a sucker for a "there's more than one way to do it" challenge. Shadow wrote:
Robert D. Scott wrote:
The harder way:
Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147
The "this could take all day" way :
(in bc with scale=0 for integer portions only)
1089055123/(2^24)%(2^8) 64 1089055123/(2^16)%(2^8) 233 1089055123/(2^8)%(2^8) 169 1089055123/(2^0)%(2^8) 147
(Note: 2^0=1 & x/1=x so last line could reduce to 1089055123%(2^8).)
-Nicholas shadow@gti.net
The "ugly, please adjust according to your endianness, etc" way: int *dec; unsigned char *oct1, *oct2, *oct3, *oct4; main(int argc, char **argv) { dec = malloc(sizeof(int)); *dec = 1089055123; oct4 = dec; oct3 = oct4 + sizeof(char); oct2 = oct3 + sizeof(char); oct1 = oct2 + sizeof(char); printf("dec: %lu ip: %hu.%hu.%hu.%hu\n", *dec, *oct1, *oct2, *oct3, *oct4); }
On 2008/08/27 05:22 PM Dave Israel wrote:
Normally, I don't participate in this sort of thing, but I'm a sucker for a "there's more than one way to do it" challenge.
Aww come on, C gets way more "fun" than that ;) #define _u8 unsigned char #define _u32 unsigned long int main(void) { _u32 ipn = 1089055123; _u8 ipa[3]; _u8 oct = 0; for (oct=0; oct <4; oct++){ ipa[oct] = (char)( (ipn & (0xFF000000 >> (8*oct))) >> (8*(3-oct)) ); } printf("%d.%d.%d.%d\n", ipa[0], ipa[1], ipa[2], ipa[3]); return 0; }
Colin Alston wrote:
On 2008/08/27 05:22 PM Dave Israel wrote:
Normally, I don't participate in this sort of thing, but I'm a sucker for a "there's more than one way to do it" challenge.
Aww come on, C gets way more "fun" than that ;)
#define _u8 unsigned char #define _u32 unsigned long
int main(void) { _u32 ipn = 1089055123; _u8 ipa[3]; _u8 oct = 0;
for (oct=0; oct <4; oct++){ ipa[oct] = (char)( (ipn & (0xFF000000 >> (8*oct))) >> (8*(3-oct)) ); }
printf("%d.%d.%d.%d\n", ipa[0], ipa[1], ipa[2], ipa[3]);
return 0; }
Actually, who needs loops for that? #include <stdio.h> int main() { unsigned i = 1089055123; printf("%d.%d.%d.%d\n", (unsigned char)(((char*)&i)[3]), (unsigned char)(((char*)&i)[2]), (unsigned char)(((char*)&i)[1]), (unsigned char)(((char*)&i)[0]) ); return 0; } Robert
Actually, who needs loops for that? ... (unsigned char)(((char*)&i)[3]), (unsigned char)(((char*)&i)[2]), (unsigned char)(((char*)&i)[1]), (unsigned char)(((char*)&i)[0])
Let data structures work for you. #include <stdio.h> main(int argc, char *argv[]) { union { unsigned int i; unsigned char c[4]; } ip; int i = 0; ip.i = 1089055123; /* endian-neutral iteration: */ printf("%d.%d.%d.%d\n", ip.c[i++], ip.c[i++], ip.c[i++], ip.c[i++]); return 0; }
$ bc bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. obase=256 1089055123 064 233 169 147
Curse you with your large number bases. But if you don't do GNU: dc <<EOF [0 sd [d 10 % 48 + Sm ld 1 + sd 10 / d 0 <M] sM lMx [LmP ld 1 - d sd 0 <M] sM lMx ] sN 1089055123 [[.]P] sP 4so [d 256 % Si 256 / lo 1 - dso 0 <O] sO lOx 4so [Li lNx lo 1 - dd so 0 <P 0 <O] sO lOx [ ]P EOF -- -D. dgc@uchicago.edu NSIT University of Chicago
OK... I'll bite... The pedantic way: No. IP addresses are already integers. All conversation on this topic has been about how to convert between different methods of representing integers, but, at the end of the day, IP addresses are either 32 (IPv4) or 128 (IPv6) bit integers. There is no conversion possible or required between IP addresses and integers as the set of {IP Addresses} is a true subset of the set {integers}. Owen On Aug 27, 2008, at 10:07 AM, Robert Kisteleki wrote:
Colin Alston wrote:
On 2008/08/27 05:22 PM Dave Israel wrote:
Normally, I don't participate in this sort of thing, but I'm a sucker for a "there's more than one way to do it" challenge.
Aww come on, C gets way more "fun" than that ;) #define _u8 unsigned char #define _u32 unsigned long int main(void) { _u32 ipn = 1089055123; _u8 ipa[3]; _u8 oct = 0; for (oct=0; oct <4; oct++){ ipa[oct] = (char)( (ipn & (0xFF000000 >> (8*oct))) >> (8*(3-oct)) ); } printf("%d.%d.%d.%d\n", ipa[0], ipa[1], ipa[2], ipa[3]); return 0; }
Actually, who needs loops for that?
#include <stdio.h>
int main() { unsigned i = 1089055123; printf("%d.%d.%d.%d\n", (unsigned char)(((char*)&i)[3]), (unsigned char)(((char*)&i)[2]), (unsigned char)(((char*)&i)[1]), (unsigned char)(((char*)&i)[0]) ); return 0; }
Robert
On Wed, Aug 27, 2008 at 10:25:10AM -0400, Shadow wrote:
Robert D. Scott wrote:
The harder way:
Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147
The "this could take all day" way :
(in bc with scale=0 for integer portions only)
1089055123/(2^24)%(2^8) 64 1089055123/(2^16)%(2^8) 233 1089055123/(2^8)%(2^8) 169 1089055123/(2^0)%(2^8) 147
(Note: 2^0=1 & x/1=x so last line could reduce to 1089055123%(2^8).)
$ bc bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. obase=256 1089055123 064 233 169 147 -Scott
.-- My secret spy satellite informs me that at Wed, 27 Aug 2008, Colin Alston wrote:
The harder way:
Decimal: 1089055123 Hex (dashes inserted at octals): 40-E9-A9-93 Decimal (of each octet): 64-233-169-147 IP Address: 64.233.169.147
The Python way
import socket, struct socket.inet_ntoa(struct.pack('>l', 1089055123)) '64.233.169.147'
The Perl way: sub ntoa { my $one = shift; my $four = $one & 0xff; $one >>= 8; my $three = $one & 0xff; $one >>= 8; my $two = $one & 0xff; $one >>= 8; return "$one.$two.$three.$four"; } #or in one line, like ipcalc does: sub ntoa_in_one_line { join(".", unpack("CCCC", pack("N", $_[0]))); } print ntoa(1089055123) . "\n"; print ntoa_in_one_line(1089055123) . "\n"; Cheers, Andree -- Andree Toonk http://www.toonk.ca/blog/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 08/27/2008 11:50 AM, Andree Toonk wrote: | #or in one line, like ipcalc does: | sub ntoa_in_one_line { join(".", unpack("CCCC", pack("N", $_[0]))); } For completeness: sub aton_in_one_line { unpack('N',pack('C4',split(/\./,$_[0]))); } Thanks, ep - -- Brian Epstein <bepstein@ias.edu> +1 609-734-8179 Network and Security Officer Institute for Advanced Study Key fingerprint = 128A 38F4 4CFA 5EDB 99CE 4734 6117 4C25 0371 C12A -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFItXy2YRdMJQNxwSoRAvVpAJwIZSnjfTxXKRo0IR4JykMfxFECRwCgzDMS EUi/2U9FwoaIEnygJIWIV1o= =dQ4q -----END PGP SIGNATURE-----
In MySQL : mysql> SELECT INET_NTOA(ip_in_decimal) AS ipa; .. or the reverse : mysql> SELECT INET_ATON('dotted.quad') AS ipn;
On Wed, Aug 27, 2008 at 05:50:44PM +0200, Andree Toonk wrote:
The Perl way:
sub ntoa_in_one_line { join(".", unpack("CCCC", pack("N", $_[0]))); } print ntoa_in_one_line(1089055123) . "\n";
dec2ip awk '{ print int($1 / 16777216) "." int($1 % 16777216 / 65536) "." int($1 % 65536 / 256) "." int($1 % 256) }' ip2dec awk '{ split($1, a, "."); print a[1]*16777216 + a[2]*65536 + a[3]*256 + a[4] }' -- . ___ ___ . . ___ . \ / |\ |\ \ . _\_ /__ |-\ |-\ \__
For the curious, have a look at the IASON tools http://iason.site.voila.fr/ and try c:~$ natnum 1089055123 host_look("64.233.169.147","1089055123","1089055123"). host_name("64.233.169.147","yo-in-f147.google.com"). natnum takes a hostname, an integer or an IPv4 address and shows you the IPv4 address, the integer and the hostname. If you do maintain your /etc/hosts it will tell you the aliases too. Most of the stuff is unix only, but I guess you can compile natnum even for windows. Kind regards Peter Matlock, Kenneth L wrote:
Easiest way.
Take the integer, plug it into windows 'calc'.
Go to 'View: Scientific'.
Hit 'Hex'. That will show you the hex representation of the integer. Notice that it's either 7 or 8 characters long.
If it's 7, prepend it with a 0.
Break that into 4 groups of 2. Those are the hex values for the four dotted quads.
Make sure 'Hex' is still selected, and put in the first 2 characters, then hit 'binary'. That's your first part of the IP. Repeat for the other 3.
For example, you have 1089055123 for an integer.
In Hex thats 40E9A993.
40 Hex = 64 E9 Hex = 233 A9 Hex = 169 94 Hex = 147
So your IP is 64.233.169.147
Ken
________________________________
From: Colin Alston [mailto:karnaugh@karnaugh.za.net] Sent: Wed 8/27/2008 5:21 AM To: kcc Cc: nanog@nanog.org Subject: Re: interger to I P address
kcc wrote:
I search google but couldn't get any solution
Can you send me information?
Sure!
-- Peter and Karin Dambier Cesidian Root - Radice Cesidiana Rimbacher Strasse 16 D-69509 Moerlenbach-Bonsweiher +49(6209)795-816 (Telekom) +49(6252)750-308 (VoIP: sipgate.de) mail: peter@peter-dambier.de http://www.peter-dambier.de/ http://iason.site.voila.fr/ https://sourceforge.net/projects/iason/
Simon Lockhart wrote:
On Wed Aug 27, 2008 at 07:11:41AM -0400, kcc wrote:
ls it possible t convert the interger to ip
Yes.
If you are using 128-bit integers, which according to some will also change some day, thus one should be using "struct addrinfo" and: getaddrinfo() getnameinfo() as those are the girlfriends of programmers. Note that one should effectively avoid inet_pton/inet_ntop as they still require the programmer to know about address families, the get*info() ones ignore all those details. Also see Itojun's (RIP :( ) excellent document at: http://www.kame.net/newsletter/19980604/ and of course Eva's document at: http://gsyc.escet.urjc.es/~eva/IPv6-web/ipv6.html Greets, Jeroen
On Wed, 27 Aug 2008, Simon Lockhart wrote:
On Wed Aug 27, 2008 at 07:11:41AM -0400, kcc wrote:
ls it possible t convert the interger to ip
Yes.
Simon
Yes. But be aware whether you are using IPv6 or IPv4... Janos Mohacsi Network Engineer, Research Associate, Head of Network Planning and Projects NIIF/HUNGARNET, HUNGARY Key 70EF9882: DEC2 C685 1ED4 C95A 145F 4300 6F64 7B00 70EF 9882
ls it possible t convert the interger to ip
#!/usr/local/bin/perl # Perl script to convert between numeric and dotted quad IPs. # give credit to Paul Gregg for this one while (<STDIN>) { chomp; $input = $_; if (/\./) { ($a, $b, $c, $d) = split(/\./); $decimal = $d + ($c * 256) + ($b * 256**2) + ($a * 256**3); } else { $decimal = $_; $d = $_ % 256; $_ -= $d; $_ /= 256; $c = $_ % 256; $_ -= $c; $_ /= 256; $b = $_ % 256; $_ -= $b; $_ /= 256; $a = $_; } if ( ($a>255) || ($b>255) || ($c>255) || ($d>255) ) { print "$0: Invalid input: $input\n"; } else { printf ("Address: %d.%d.%d.%d is %u (Hex:%02x%02x%02x%02x)\n", $a,$b,$c,$d, $decimal,$a,$b,$c,$d); } }
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yo All!
ls it possible t convert the interger to ip
# php -r 'echo ip2long("196.3.39.209"), "\n";' RGDS GARY - --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 gem@rellim.com Tel:+1(541)382-8588 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFItc7dBmnRqz71OvMRAshNAKCoM8Lifs17RI7vwfF6ACF1ZiDTxgCgt6Sh H6JRMLnsX8n/Hs8fCLhguqA= =hwxF -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yo All! On Wed, 27 Aug 2008, Gary E. Miller wrote:
ls it possible t convert the interger to ip # php -r 'echo ip2long("196.3.39.209"), "\n";'
Whoops, wrong way. # php -r 'echo long2ip("3288541137"), "\n";' RGDS GARY - --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701 gem@rellim.com Tel:+1(541)382-8588 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFItdBgBmnRqz71OvMRAlpDAKCd+G4Qtj/d/65bSLx2vWXEM6XesACgnc5/ f9BdpC6mwrOYV0X5VzRVKQw= =hHcZ -----END PGP SIGNATURE-----
Perl provides some cleaner methods for interpreting/displaying IPs. There isn't a formal standard notation for an IP that looks like a string of decimal digits with no dots though. I.e. no RFC will define the host byte order and tell you that "127.0.0.1" corresponds to the decimal integer 2130706433; I might be little-endian and argue that the right human-readable integer to call that ip is 16777343. There are a vast number of different numerical representations the very same ip address could be converted to, because a string of bits has no inherent representation. Displaying an IP in a novel format seems dangerous. Ips have only a binary notation and.. in recent years dots-and-decimals are formalized. In general, rather than just in the context of SMTP. Still conflicting conventions exists that haven't been fixed, for example try pinging "127.1" (hint: it's an old abbreviation mechanism not merely a "bug") In any case, to get from quad-octet notation to a decimal integer representation you may be thinking of (if you interpret those octets in the network byte order used for other items such as port numbers): $ perl -e 'use IO::Socket; print unpack("N",inet_aton("127.0.0.1"))."\n"' 2130706433 $ perl -e 'use IO::Socket; print inet_ntoa(pack("N",2130706433))."\n";' 127.0.0.1 $ perl -e 'use IO::Socket; print inet_ntoa(pack("N",2066563929))."\n";' 123.45.67.89 And of course... $ perl -e 'print "",(123<<24)|(45<<16)|(89<<8),"\n"' 2066569472 Or if you don't like one-liners, 3 separate short scripts: ipv4-to-hex: #!/usr/bin/perl use IO::Socket; printf("%x\n", unpack("N",inet_aton($ARGV[0]))); ipv4-to-integer: #!/usr/bin/perl use IO::Socket; printf("%d\n", unpack("N",inet_aton($ARGV[0]))); hex-to-ipv4: #!/usr/bin/perl use IO::Socket; print inet_ntoa(pack("N",hex($ARGV[0]))); On Wed, Aug 27, 2008 at 9:13 AM, Michael Holstein <michael.holstein@csuohio.edu> wrote:
ls it possible t convert the interger to ip
#!/usr/local/bin/perl # Perl script to convert between numeric and dotted quad IPs. # give credit to Paul Gregg for this one while (<STDIN>) { chomp; $input = $_; if (/\./) { ($a, $b, $c, $d) = split(/\./); $decimal = $d + ($c * 256) + ($b * 256**2) + ($a * 256**3); } else { $decimal = $_; $d = $_ % 256; $_ -= $d; $_ /= 256; $c = $_ % 256; $_ -= $c; $_ /= 256; $b = $_ % 256; $_ -= $b; $_ /= 256; $a = $_; }
if ( ($a>255) || ($b>255) || ($c>255) || ($d>255) ) { print "$0: Invalid input: $input\n"; } else { printf ("Address: %d.%d.%d.%d is %u (Hex:%02x%02x%02x%02x)\n", $a,$b,$c,$d, $decimal,$a,$b,$c,$d); } }
-----Original Message----- From: kcc [mailto:peterkcc2001@gmail.com] Sent: Wednesday, August 27, 2008 7:12 AM To: nanog@nanog.org Subject: interger to I P address
Hi all
ls it possible t convert the interger to ip
Thank you
My two cents: # ping 1089055123 PING 1089055123 (64.233.169.147) 56(84) bytes of data. 64 bytes from 64.233.169.147: icmp_seq=1 ttl=248 time=2.55 ms 64 bytes from 64.233.169.147: icmp_seq=2 ttl=248 time=2.00 ms To do in reverse, you can use 'sipcalc': # sipcalc 64.233.169.147 -[ipv4 : 64.233.169.147] - 0 [CIDR] Host address - 64.233.169.147 Host address (decimal) - 1089055123 Host address (hex) - 40E9A993 Network address - 64.233.169.147 Network mask - 255.255.255.255 Network mask (bits) - 32 Network mask (hex) - FFFFFFFF Broadcast address - 64.233.169.147 Cisco wildcard - 0.0.0.0 Addresses in network - 1 Network range - 64.233.169.147 - 64.233.169.147 -evt
Ruby's IPAddr class is quite handy for IPv4 and IPv6 integer representation conversions. For IP to integer, whether IPv4 or IPv6, ruby code: require 'ipaddr' print "#{IPAddr.new('10.0.0.55').to_i}\n" print "#{IPAddr.new('2001:0db8:85a3:08d3:1319:8a2e:0370:7334').to_i}\n" Results in: 167772215 42540766452641195744311209248773141300 And for integer to IPv4, ruby code: require "ipaddr" print "#{IPAddr.new(167772215,Socket::AF_INET)}\n" Results in: 10.0.0.55 And for integer to IPv6, ruby code: require 'ipaddr' print "#{IPAddr.new(42540766452641195744311209248773141300, Socket::AF_INET6)}\n" Results in: 2001:0db8:85a3:08d3:1319:8a2e:0370:7334 Aaron out.
Howdy, Careful, this appears to not be inline with another persons thoughts. Not mine mind you. "Anything concerning an "end network" is not relevant to this list. " lol I am however, very interested in the content/replies thus far. Very entertaining. Ok, sorry, back to the scheduled programs. -Joe
-----Original Message----- From: bmanning@vacation.karoshi.com [mailto:bmanning@vacation.karoshi.com] Sent: Wednesday, August 27, 2008 10:41 PM To: kcc Cc: nanog@nanog.org Subject: Re: interger to I P address
On Wed, Aug 27, 2008 at 07:11:41AM -0400, kcc wrote:
Hi all
ls it possible t convert the interger to ip
Thank you
sure. how do you want that IP? hex? octal, decimal, binary? (*) v4 or v6?
* other bases by request....
--bill
"Anything concerning an "end network" is not relevant to this list. "
lol
I am however, very interested in the content/replies thus far. Very entertaining.
Yes, while certainly off topic, also for me it's probably been one of the most entertaining threads of this kind. So just one more solution, as there's so much unused processing power available on all your PostScript gear: Let your printer do the math! ##### BEGIN of ntoa.ps ##### %! /ntoa { 3 { dup 256 idiv exch 256 mod exch } repeat 256 mod } def /printa { 3 string cvs show 3 { (.) show 3 string cvs show } repeat } def /Helvetica findfont 36 scalefont setfont 36 444 moveto 1089055123 ntoa printa showpage ###### END of ntoa.ps ######
participants (27)
-
Aaron Gifford
-
Andree Toonk
-
Beat Vontobel
-
bmanning@vacation.karoshi.com
-
Brian Epstein
-
Colin Alston
-
Dave Israel
-
David Champion
-
Eric Van Tol
-
Gary E. Miller
-
Iljitsch van Beijnum
-
Izaac
-
James Hess
-
Jeroen Massar
-
Joe Blanchard
-
kcc
-
Matlock, Kenneth L
-
Michael Holstein
-
Mohacsi Janos
-
Owen DeLong
-
Peter Dambier
-
Robert D. Scott
-
Robert Kisteleki
-
Scott Doty
-
Shadow
-
Simon Lockhart
-
Stephane Bortzmeyer