Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 12 down vote accepted

There is such command: getent.

Try following: getent hosts google.com, getent hosts 8.8.8.8 - 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

 
discard

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.