1

As part of auditing a RANCID server, I would like to be able to figure out whether it's resolving a particular hostname via /etc/hosts, DNS or some other source. Is there a generic (without me hardcoding the logic and order of my particular nsswitch.conf) way to do this?

gethostbyname just gives me the result. Do does getent, as far as I can tell, although I can get it to only use file or dns with the -s option, that still means I am parsing nsswitch.conf to decide which one it would have chosen, or assuming the configuration.

  • Systemd-resolved provides an API over dbus, which returns this information as a bit set in a bitmap. I don't know if this helps you or not. See freedesktop.org/wiki/Software/systemd/resolved – Johan Myréen Mar 27 '18 at 15:26
  • Well, sort of... it looks like it would do the trick. Now I just need to figure out how dbus works :-) – AnotherHowie Mar 27 '18 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.