實用程式-從DNS 查IP(轉)

post0發表於2007-08-11
實用程式-從DNS 查IP(轉)[@more@]

發現好多人問我要IP, 現在把我常用script 貢獻給大家.

發法很多, 一個是 nslookup host.name

另一簡單方法是用如下script :

#!/usr/local/bin/perl

# gethostbyname.pl - Answer IP queries

$prog = substr ($0, rindex ($0, '/') + 1);

if ($#ARGV != 0) {

die "usage: $prog ( hostname ) "; }

&name_to_address ($ARGV[0]);

exit (0);

sub name_to_address { local ($name) = shift (@_); local (@octets);

local ($nam, $aliases, $addrtype, $length, $address) =

gethostbyname ($name);

if (! length ($address)) { die "$prog: no address found for $name "; }

@octets = unpack ("CCCC", $address);

print (join ('.', @octets[0..3]), " "); }

--

blast email : honglu@trail.comnbsp;for $name "; }

~honglu/ email : honglu@trail.comnbsp;for $name "; }

美國新墨西哥州沙灘驛站

Negethostip.pl (code) 從DNS 查IP

發信站: 美國沙灘驛站(sandland) (Thu Oct 30 01:56:07 1997)

轉信站: Nease!news.nease.net!clinux.ml.org!blast.dyn.ml.org!sandland

發現好多人問我要IP, 現在把我常用script 貢獻給大家.

發法很多, 一個是 nslookup host.name

另一簡單方法是用如下script :

#!/usr/local/bin/perl

# gethostbyname.pl - Answer IP queries

$prog = substr ($0, rindex ($0, '/') + 1);

if ($#ARGV != 0) {

die "usage: $prog ( hostname ) "; }

&name_to_address ($ARGV[0]);

exit (0);

sub name_to_address { local ($name) = shift (@_); local (@octets);

local ($nam, $aliases, $addrtype, $length, $address) =

gethostbyname ($name);

if (! length ($address)) { die "$prog: no address found for $name "; }

@octets = unpack ("CCCC", $address);

print (join ('.', @octets[0..3]), " "); }

--

blast email : honglu@trail.comnbsp;for $name "; }

~honglu/ email : honglu@trail.comnbsp;for $name "; }

美國新墨西哥州沙灘驛站

New Mexico Sandland BBSbsp; email : honglu@trail.comnbsp;for $name "; }

telnet blast.dyn.ml.org; email : honglu@trail.comnbsp;for $name "; }

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-945010/,如需轉載,請註明出處,否則將追究法律責任。

相關文章