host
geralmente retorna 0
para hosts existentes
$ host www.google.com ; echo $?
www.google.com has address 172.217.16.132
www.google.com has IPv6 address 2a00:1450:400a:805::2004
0
e 1
em caso de erros
$ host does.not.exist ; echo $?
Host does.not.exist not found: 3(NXDOMAIN)
1
Agora tenho um host não existente em que host
retorna 0 sem nenhuma saída
$ host red3.ethz.ch; echo $?
0
nslookup
gera um erro (como esperado):
$ nslookup red3.ethz.ch
Server: 129.132.98.12
Address: 129.132.98.12#53
Non-authoritative answer:
*** Can't find red3.ethz.ch: No answer
Com -d
e -v
não vejo nenhuma seção ANSWER
na saída
$ host -v -d red3.ethz.ch
Trying "red3.ethz.ch"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55752
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;red3.ethz.ch. IN A
;; AUTHORITY SECTION:
ethz.ch. 246 IN SOA dummy-ns.ethz.ch. hostmaster.ethz.ch. 2008016728 10800 3600 1814400 600
Received 86 bytes from 129.132.98.12#53 in 30 ms
Trying "red3.ethz.ch"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31530
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;red3.ethz.ch. IN AAAA
;; AUTHORITY SECTION:
ethz.ch. 246 IN SOA dummy-ns.ethz.ch. hostmaster.ethz.ch. 2008016728 10800 3600 1814400 600
Received 86 bytes from 129.132.98.12#53 in 0 ms
Trying "red3.ethz.ch"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43023
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;red3.ethz.ch. IN MX
;; AUTHORITY SECTION:
ethz.ch. 246 IN SOA dummy-ns.ethz.ch. hostmaster.ethz.ch. 2008016728 10800 3600 1814400 600
Received 86 bytes from 129.132.98.12#53 in 0 ms
Por que host
retorna 0?
Editar
Olhando para o comentário, parece que podemos reduzi-lo a uma configuração diferente no DNS.
No mesmo domínio ( ethz.ch
)
$ host doesnotexist.ethz.ch; echo $?
Host doesnotexist.ethz.ch not found: 3(NXDOMAIN)
1
$ host red3.ethz.ch; echo $?
0
$ host www.ethz.ch; echo $?
www.ethz.ch has address 129.132.19.216
www.ethz.ch has IPv6 address 2001:67c:10ec:4380::216
0
Parece que a resposta sem um IP é considerada OK por 'hosts', mas não por 'nslookup'.