[gull] Comment obtenir les DNS?
Félix Hauri
felix at f-hauri.ch
Thu Nov 2 21:33:09 CET 2006
On Thu, Nov 02, 2006 at 02:05:49PM +0100, Cédric Rochat wrote:
> Un petit script à deux balles, mais qui peut s'avérer utile :
> ...
> #!/bin/sh
> # Description : Search for the DNS servers for a given domain name
> ...
> DNSNUMBER=$(expr $DNSNUMBER + 1)
(au passage: pkoi pas: ``DNSNUMBER=$((1+$DNSNUMBER))'' ?)
Joli!
> Ensuite, il suffit de faire "getDNS.sh google.com" pour obtenir les DNS de
> Google ;-)
Mais bon, si
$ host -t NS -v google.com
donne ces mêmes infos, tu pouvais:
$ host -t NS -v google.com |
awk 'BEGIN {s=0};
/[\t ]IN[\t ]+A[\t ]/ {printf "DNS%s: %s = %s\n", s++,$1,$NF;}'
ou
$ host -t NS -v google.com |
perl -pe 'printf " DNS%d: %s = %s\n", 1+$c++, $1, $2 if
/^(.*)\.\s+\d+\s+IN\s+A\s+(.*)$/;
undef $_;'
voire:
$ host -t NS -v google.com |
perl -pe 'printf "DNS servers for domain %s:\n",$1 if /^Trying (".*")$/;
printf " DNS%d: %s = %s\n", $c++ + 1, $1, $2 if
/^(.*)\.\s+\d+\s+IN\s+A\s+(.*)$/;
undef $_;'
--
Félix Hauri - <felix at f-hauri.ch> - http://www.f-hauri.ch
More information about the gull
mailing list