I know there is host and dig and all those... but they are DNS tools and they don't query the local resolver library.

/etc/hosts can change what the local resolver returns. The local resolver does caching too. /etc/nsswitch.conf can completely remove DNS from the resolution path...

So it seems wierd that there is no command for checking what the local resolver library has.

I normally do something like this:

export VAR='"nics-acer"'; python -c "import socket; print(socket.gethostbyname($VAR));"

and when I wrote my Python version of resolvconf, I added a switch to test the resolver, but shouldn't there be a reason for there not being a standard tool?


There is such command: getent.

Try following: getent hosts google.com, getent hosts - it will query using system resolver (see also /etc/nsswitch.conf to check what is actually being queries and in what order).


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.