当前位置:Linux教程 - Linux综合 - 实用程序-从DNS 查IP

实用程序-从DNS 查IP

  发现好多人问我要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 : [email protected];for $name "; } http://www.trail.com/~honglu/ email : [email protected];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 : [email protected];for $name "; } http://www.trail.com/~honglu/ email : [email protected];for $name "; } 美国新墨西哥州沙滩驿站 New Mexico Sandland BBSbsp; email : [email protected];for $name "; } telnet blast.dyn.ml.org; email : [email protected];for $name "; }

(出处:http://www.sheup.com)