Link to home
Start Free TrialLog in
Avatar of sldiamond
sldiamond

asked on

Ping of short hostname doesn't work, ping of hostname. works, host works, nslookup works

Just installed CentOS 4.3 (kernel 2.6.9-34.EL) on a box and the local network name resolution doesn't work properly. It did work fine with CentOS 3.4 (kernel 2.4.21-32.EL).

Pinging a host on the local network doesn't work. Pinging the same host with a trailing dot works. Local name resolution with both host and nslookup work. Pinging a host on the Internet works. Here's the results of a few commands which show the problem:

[root@linux etc]# hostname
linux.local

[root@linux etc]# ping windows //DOESN'T WORK//
ping: unknown host windows

[root@linux etc]# ping windows. //THIS WORKS--NOTE TRAILING DOT//
PING windows (192.168.0.10) 56(84) bytes of data.
64 bytes from windows (192.168.0.10): icmp_seq=0 ttl=128 time=0.512 ms

[root@linux etc]# host windows //THIS WORKS WITHOUT THE TRAILING DOT//
windows has address 192.168.0.10

[root@linux etc]# nslookup windows //THIS WORKS WITHOUT THE TRAILING DOT//
Server:         192.168.0.1
Address:        192.168.0.1#53
Non-authoritative answer:
Name:   windows
Address: 192.168.0.10

Contents of some files:

/etc/host.conf:
order hosts,bind

/etc/hosts:
127.0.0.1               localhost
127.0.0.1               linux.local

/etc/sysconfig/network:
NETWORKING=yes
HOSTNAME=linux.local

Thanks in advance.
Avatar of kfullarton
kfullarton

Add this line to /etc/resolv.conf

search <your-domain-name>
In your /etc/hosts file,

>127.0.0.1               linux.local

This should be your IP address, not the loopback.
Avatar of sldiamond

ASKER

Thanks for the suggestion.

However, changing /etc/resolv.conf directly won't work, as the file seems to be generated dynamically on boot by /sbin/dhclient-script.
kfullarton:

To your second comment, thanks. However the machine's IP address is assigned by a DHCP server elsewhere on the network, so I can't put it in the /etc/hosts file.
do your /etc/resolv.conf have a line with
nameserver x.y.z.w

where such ip is your internal nameserver ip?

also take note of kfullarton post:
in /etc/hosts your 127.0.0.1 should be directed to localhost, or many things will not work correctly:
127.0.0.1        localhost.localdomain localhost
Redimido,

Thanks for your comment. /etc/resolv.conf already contains the nameserver directive:

; generated by /sbin/dhclient-script
nameserver 192.168.0.1

I edited /etc/hosts as you suggested, but the problem remains.

one question. what's the centos ip address?
second question. can you post your /etc/resolv.conf and your /etc/hosts?
thanks
IP address is 192.168.0.10

/etc/resolv.conf:
; generated by /sbin/dhclient-script
nameserver 192.168.0.1

/etc/hosts:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
I see you need to add to /etc/resolv.conf: (as kfullarton said)
nameserver 192.168.0.1
search your.internal.domain.name (replace)

it should work
Thanks for the suggestion.

However, please note my posting on 04/17/2006 12:07PM PDT to kfullarton: "...changing /etc/resolv.conf directly won't work, as the file seems to be generated dynamically on boot by /sbin/dhclient-script."
ASKER CERTIFIED SOLUTION
Avatar of Gabriel Orozco
Gabriel Orozco
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree that the better route would be to edit your DHCP server config and have it pass out the search list.
Thanks. However, the DHCP server is a firewall/router appliance and dhcpd.conf is automatically re-written by the firmware.

Please note that everything works fine on a CentOS 3.4 (kernel 2.4.21-32.EL) box which has the same configuration files. Does that suggest anything?
I think you have the option to check your dhclient options so /etc/resolv.conf does not get changed.

for the CentOS 3.4 behavior, it would be good if you check it's config files for any difference