歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 實用程序-從DNS 查IP

實用程序-從DNS 查IP

日期:2017/2/27 14:21:18   编辑:更多Linux
  發現好多人問我要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 "; }




Copyright © Linux教程網 All Rights Reserved