Operating System - Linux
1756503 Members
2684 Online
108848 Solutions
New Discussion юеВ

RHEL4U$ > nslookup not looking up /etc/hosts on private network

 
Bill McNAMARA_1
Honored Contributor

RHEL4U$ > nslookup not looking up /etc/hosts on private network

Hi,

I've installed Red Hat Enterprise Linux AS release 4 (Nahant Update 4) on a server for testing purposes.

I have no DNS server and am defining the hostname and domainname my self..
ie:
domainname: my.test.com
hostname: box

IP is private: 192.168.0.101

There are two servers on this network.
they can ping each other and I can ssh from one to the other.

However, when installing an application (not mine) it's startup scripts run the host command.
this command does not work and times out on my server just as nslookup does:

[root@box ~]# nslookup box
;; connection timed out; no servers could be reached

my config is as attached...

It works for me (tm)
11 REPLIES 11
Court Campbell
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

clobber /etc/resolv.conf. And since you are not using dns you can remove it from nsswitch.conf. You can get rid of nis also, unless you are using it. I assume you aren't.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Steven E. Protter
Exalted Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

Shalom,

Unless you are hosting a DNS server on the system, this is the problem.

[root@diameter ~]# cat /etc/resolv.conf

domain my.test.com

search my.test.com

nameserver 127.0.0.1



You need a nameserver that contains DNS information for your network

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill McNAMARA_1
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

ok, I've no DNS server on the network, just two hosts a client and a server.

I removed resolv.conf
and removed everything but files for hosts from nsswitch.conf and rebooted.

nslookup, host commands still timeout:



[root@box /]# Last login: Thu Sep 25 11:33:09 2008 from 192.168.0.102
[ocadmin@box ~]$ nslookup box
;; connection timed out; no servers could be reached

[ocadmin@box ~]$ host box
;; connection timed out; no servers could be reached
[ocadmin@diameter ~]$ ping diameter

PING box (192.168.0.101) 56(84) bytes of data.
64 bytes from diameter (192.168.0.101): icmp_seq=0 ttl=64 time=2.00 ms


[ocadmin@box ~]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost localhost.localdomain
192.168.0.101 box box.my.test.com


Thanks for the replies so far...
It works for me (tm)
Ivan Ferreira
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

Maybe your options are:

Configure a DNS server on one fo the linux boxes, you can do it quickly by modifying the files provided by caching-nameserver.

Or maybe, you can just trick the installation program, build your own "host" command with a script to return the desired value.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Bill McNAMARA_1
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

yes Ivan, this is what I've done to workaround this for the moment:

[ocadmin@diameter lib]$ cat /usr/bin/host
echo "box.my.test.com has address 192.168.0.101"

etc...


It works for me (tm)
Court Campbell
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

Did you ever try

nslookup 192.168.0.101
nslookup box.my.test.com

or

host 192.168.0.101
host box.my.test.com
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Bill McNAMARA_1
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

yes, for all host command (as well as nslookup) lookups (ip or hostname) I get:

;; connection timed out; no servers could be reached

It works for me (tm)
Brem Belguebli
Regular Advisor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

Hi

Contrary to HP-UX where nslookup tries to resolve from /etc/hosts and dns, the normal nslookup (as implemented in Linux and all the other systems (Unixes, windows, etc...)) stands to request only DNS nameservers.

If there is no resolv.conf on the system, nslookup will try to request 127.0.0.1 even if there is no bind running on the system.

To try to resolve host names (as well as many other services) you should try getent:

getent hosts box or getent hosts 192.168.0.101

It will rely on /etc/nsswitch.conf (man nsswitch.conf)
Rob Leadbeater
Honored Contributor

Re: RHEL4U$ > nslookup not looking up /etc/hosts on private network

Hi Bill,

As Brem points out, host and nslookup are working as expected, or at least as I'd expect them to on Linux.

The man page for nslookup on Linux is quite different to that on HP-UX.

HP-UX: nslookup is a program to query Internet domain name servers. If a name server is not configured, nslookup uses NIS if it is configured. Otherwise the local host table, /etc/hosts, is used.

Linux: nslookup is a program to query Internet domain name servers.


It's doing what it says on the tin !

Cheers,

Rob