• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 784
  • Last Modified:

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.
0
sldiamond
Asked:
sldiamond
  • 6
  • 6
  • 3
1 Solution
 
kfullartonCommented:
Add this line to /etc/resolv.conf

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

>127.0.0.1               linux.local

This should be your IP address, not the loopback.
0
 
sldiamondAuthor Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sldiamondAuthor Commented:
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.
0
 
Gabriel OrozcoSolution ArchitectCommented:
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
0
 
sldiamondAuthor Commented:
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.

0
 
Gabriel OrozcoSolution ArchitectCommented:
one question. what's the centos ip address?
0
 
Gabriel OrozcoSolution ArchitectCommented:
second question. can you post your /etc/resolv.conf and your /etc/hosts?
thanks
0
 
sldiamondAuthor Commented:
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
0
 
Gabriel OrozcoSolution ArchitectCommented:
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
0
 
sldiamondAuthor Commented:
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."
0
 
Gabriel OrozcoSolution ArchitectCommented:
ho, sorry, I forgot to write about this

you can edit dhclient options to not rewrite your resolv.conf, or (better) you can edit your DHCP server to send also the domain part =)

0
 
kfullartonCommented:
I agree that the better route would be to edit your DHCP server config and have it pass out the search list.
0
 
sldiamondAuthor Commented:
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?
0
 
Gabriel OrozcoSolution ArchitectCommented:
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now