Operating System - HP-UX
1830622 Members
2259 Online
110015 Solutions
New Discussion

Re: Ping does'nt work with dotted name in /etc/hosts

 
SOLVED
Go to solution
Mouad_1
Frequent Advisor

Ping does'nt work with dotted name in /etc/hosts

Hi,
Here is my question :
Having "204.1.4.23 ict-prod-ce0" in /etc/hosts
The ping succed :
ping ict-prod-ce0
PING ict-prod-ce0: 64 byte packets
64 bytes from 204.1.4.23: icmp_seq=0. time=1. ms
64 bytes from 204.1.4.23: icmp_seq=1. time=0. ms
----ict-prod-ce0 PING Statistics----
4 packets transmitted, 4 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/0/1

But with "204.1.4.23 ict-prod.ce0" in /etc/hosts
It does NOT :(
ping ict-prod.ce0
ping: unknown host ict-prod.ce0

WHY ?

Thanks a lot for any responses .
8 REPLIES 8
melvyn burnard
Honored Contributor
Solution

Re: Ping does'nt work with dotted name in /etc/hosts

this is because it understands the "dot" as a delimiter to signify hostname.domain

Either do not use a . in the hostname, or change the ndots setting, as per
man hostname
and
man 5 hostname

My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Steven E. Protter
Exalted Contributor

Re: Ping does'nt work with dotted name in /etc/hosts

dots are used to define fully qualified domain names if you wish.

Doesn't work like a DNS database.

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
Mouad_1
Frequent Advisor

Re: Ping does'nt work with dotted name in /etc/hosts

Thanks
It worked by renaming /etc/resolve.conf
mv /etc/resolve.conf /etc/resolve.conf.old
There was probably some stuff in resolve.conf making trouble
Muthukumar_5
Honored Contributor

Re: Ping does'nt work with dotted name in /etc/hosts

I hope it may be a problem with your /etc/nsswitch.conf settings too :)

Check for hosts: entry in that which decides host -> ip and ip -> host resolvation.

Try to keep as,

hosts: files dns

# mv /etc/resolv.conf.old /etc/resolv.conf
You can verify this setting as,

# nsquery hosts 204.1.4.23 "files dns"
# nsquery hosts 204.1.4.23 "dns"

hth.
It will work.
Easy to suggest when don't know about the problem!
Mouad_1
Frequent Advisor

Re: Ping does'nt work with dotted name in /etc/hosts

I have no file /etc/nsswitch,
anyway the content of the /etc/resolv.conf (now is resolv.conf.old) was :

domain xxx.net.ma
nameserver x.y.z.t
nameserver x.y.z.t

if that may help understanding how the name resolution work .
Mouad

Ranjith_5
Honored Contributor

Re: Ping does'nt work with dotted name in /etc/hosts

Hi Mouad,

/etc/nsswitch sets the search order for a NAME RESOLUTION PROVIDER, like /etc/hosts( termed as file in nsswitch.conf), NIS, DNS etc.

For example if your /etc/nsswitch.conf has got the following entry, the search for a host name resolution will start in the /etc/hosts then DNS and finally NIS resources.

hosts: files dns nis


/etc/resolv.conf is the file for a DNS client where it specifies the search order for a DNS resource.

Regards,
Syam
Mouad_1
Frequent Advisor

Re: Ping does'nt work with dotted name in /etc/hosts

Thanks Syam, that's clear .
But what if nsswitch.conf does'nt even exists, I guess it starts searching in /etc/hosts by default, but the problem here is that it still takes entries in /etc/hosts as host.domain (if dotted name)
Arunvijai_4
Honored Contributor

Re: Ping does'nt work with dotted name in /etc/hosts

# The form for each entry is:
#
#
# For example:
# 192.1.2.34 hpfcrm loghost
#
# See the hosts(4) manual page for more information.
# Note: The entries cannot be preceded by a space.
# The format described in this file is the correct format.
# The original Berkeley manual page contains an error in
# the format description.
#
"A ship in the harbor is safe, but that is not what ships are built for"