Front page | perl.beginners |
Postings from December 2002
Re: Resolving DNS/IP
Thread Previous
|
Thread Next
From:
peter
Date:
December 24, 2002 07:52
Subject:
Re: Resolving DNS/IP
Message ID:
20021224155212.44426.qmail@onion.perl.org
In article <20021224141301.65781.qmail@onion.perl.org>,
dan@abovenet.org (Dan) writes:
>I need my program to resolve hosts to IP's, and vice versa. I came across
>the Net::DNS module on CPAN, but have no idea how to just give it a host,
>and get it to return an IP, and vice versa. The help for it doesn't make
>sense to me either :(
You don't need no module, son, it's easy enough without one:
Single IP:
$ perl -MSocket -le 'print inet_ntoa(scalar gethostbyname("cnn.com"))'
64.236.24.12
All IPs (if you care):
$ perl -MSocket -le '@x = gethostbyname("cnn.com"); \
print inet_ntoa($_) for @x[4..$#x]'
64.236.24.20
64.236.24.28
64.236.16.20
64.236.16.52
64.236.16.84
64.236.16.116
64.236.24.4
64.236.24.12
--
Peter Scott
http://www.perldebugged.com
Thread Previous
|
Thread Next