Operating System - Linux
1826651 Members
3534 Online
109695 Solutions
New Discussion

nslookup to use /etc/hosts in LINUX

 
SOLVED
Go to solution
Sajeesh O.K
Advisor

nslookup to use /etc/hosts in LINUX

Hi

In LINUX nslookup is always using BIND for
hostname resolution. Anybody know how to override this with /etc/hosts


Thanks
Sajeesh
4 REPLIES 4
Alexander Chuzhoy
Honored Contributor

Re: nslookup to use /etc/hosts in LINUX

edit the file /etc/nsswitch.conf
come to the line:
dns files (it can in defferent order)
and change it to:
files dns
This will cause the search order to be first in /etc/hosts and then in DNS.If you wish to eliminate search in DNS remove "dns" from this line.
Vitaly Karasik_1
Honored Contributor
Solution

Re: nslookup to use /etc/hosts in LINUX

AFAIK, nslookup is always uses DNS;
for getting info from /etc/hosts you may use getent utility.

See "Getting an entry with getent?http://www.itworld.com/Comp/3380/nls_unixgetent041202/index.html for more.
Alexander Chuzhoy
Honored Contributor

Re: nslookup to use /etc/hosts in LINUX

Sorry, got confused with regular name resolution.
The purpose of nslookup utility is to query DNS,so ...
Sajeesh O.K
Advisor

Re: nslookup to use /etc/hosts in LINUX

Vitaly

Thanks. This solve the purpuse.

Sajeesh