[SOLVED] nslookup, host, dig not resolving entries in /etc/hosts
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yep but it is simpler to use the "getent ahosts <hostname>" suggested above as it requires no additional configuration.
My original question was caused by the fact that HP-UX modified their version of "dig" to resolve from local files based on nsswitch.conf settings but as noted long ago that is not part of the "dig" as provided by the folks that made it as part of BIND.
Amazing after all these years this thread is still getting hits.
Now its the application OSAD/jabberd/xmpp that is highly sensitive to FQDN resolving and it is not connecting due to failed DNS resolution.
so i do not have a control over how to tell application to use 'genet'.
the work around link: https://access.redhat.com/solutions/46767 recommended by 'syedwaheedz' doest help as I do not have the support with redhat so can't really see what the work around is?
The work around involves setting up dnsmasq on the local host and telling it to resolve from /etc/hosts.
I can't post what RedHat wrote but if you do a Google search for dnsmasq and /etc/hosts you'll find hits talking about this for other distros like Ubuntu that you should be able to adapt to your CentOS setup.
Thread is marked as Solved but still open. Does closing a thread require mod intervention? If so, triggering this comment to catch moderators' attention, might want to close
Entries in my /etc/hosts file on a RedHat AS 3.0 installation are not being resolved when I use nslookup. (Also when I use "dig" or "host" utilities.)
Essentially the versions of nslookup, dig and host in the "bind" package are using dns only. That's what they are distributed with and that's what they do.
Other implementations of those commands may work differently (i.e. in NIS(+)
Essentially the versions of nslookup, dig and host in the "bind" package are using dns only. That's what they are distributed with and that's what they do.
Other implementations of those commands may work differently (i.e. in NIS(+)
This thread is fourteen years old. In fact when someone posted an answer after it was seven years old (oddly enough about seven years ago) I posted the thing about HP-UX' nslookup having been configured to read hosts but most other implementations not doing that.
If you're going to respond to a thread, especially an ancient one, you ought to look through the entire thread to see if the solution is already there. The other poster today was just thanking everyone for having posted before.
Last edited by MensaWater; 07-19-2019 at 01:50 PM.
Even almost 15 years later the reply by Fravadona was very helpful to me - thanks a lot!
I've run into the problem several times already, and most replies I found online just stated that nslookup won't do it - what a constructive response.
Using instead, e.g., ping with a timeout is not really nice.
Meanwhile I've put the solution in a one-line script called getipaddr:
Code:
getent ahosts $1 | head -n 1 | awk '{ print $1 }'
such that I can easily use it, e.g., in ~/.ssh/config:
I have a W10 machine running Ubuntu 20.045/WSL and I am trying to test out nslookup, host, and dig commands. First, it suggested that I run "sudo apt install net-cools," which I did. But when I try to run "dig @127.0.0.1 google.com" or "dig --help" I get the error, "dig: parse of /etc/resolv.conf failed." Any ideas on what to do? Thanks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.