当前位置:操作系统 > Unix/Linux >>

实用程序-从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 : honglu@trail.comnbsp;for $name "; }

  http://www.trail.com/~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 "; }

  http://www.trail.com/~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 "; } 本文来自:http://www.xiaoyaxiao.com/3880.html
发表您的高见!
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,