Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 12 down vote accepted

There is such command: getent.

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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