On 2019-05-16 17:52:03 +0200, Michael Biebl wrote: > I would suggest the following: If there is a local nameserver but no > network connectivity, query the local nameserver only.
OK, I can do that. Indeed, the default behavior of "host" is to try every server in /etc/resolv.conf until it succeeds. I suppose that the solution would be to use this option: -s Do not send the query to the next nameserver if any server responds with a SERVFAIL response, which is the reverse of normal stub resolver behavior. I have another question: in if ! $(egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf); then why testing 127.0.0.1 only, and not all local nameservers? For instance, 127.0.1.1 is used by NetworkManager: https://askubuntu.com/questions/627899/nameserver-127-0-1-1-in-resolv-conf-wont-go-away Also, the regexp should be something like "^ *nameserver +(127.0.0.1|::1)" or "^ *nameserver +(127\.|::1)", i.e. * one should make sure that it is a nameserver line (in particular, not a comment); * several space characters should match; * one should make sure that ::1 is preceded by "nameserver" (the parentheses are missing). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)