Operating System - HP-UX
1832214 Members
2277 Online
110041 Solutions
New Discussion

"ntpq -p" error: can not find local host

 
SOLVED
Go to solution
szhiyong
Frequent Advisor

"ntpq -p" error: can not find local host

Hi,

I installed ntp in my workstations. But When I "ntpq -p",there is error message:
can not find localhost
Then I "ps -a", I do not find ntp process.

Would someone please tell me what is wrong?

Thanks a lot.

zhiyong
My life is now asking and learning, I wish It can change into replying and discussing
10 REPLIES 10
Patrick Wallek
Honored Contributor
Solution

Re: "ntpq -p" error: can not find local host

Is 'localhost' defined in your /etc/hosts file?

Do you have an /etc/resolv.conf file? If so what are its contents?
szhiyong
Frequent Advisor

Re: "ntpq -p" error: can not find local host

Hi,Patrick,

Thanks for your reply. The localhost is defined in /etc/hosts file. The contents of /etc/resolv.conf:
domain ohsu.edu
nameserver 137.53.1.30
nameserver 137.53.203.5

zhiyong
My life is now asking and learning, I wish It can change into replying and discussing
Patrick Wallek
Honored Contributor

Re: "ntpq -p" error: can not find local host

Sorry, not resolv.conf. I meant /etc/nsswitch.conf
szhiyong
Frequent Advisor

Re: "ntpq -p" error: can not find local host

Patric,

I do not have nsswitch.conf file in etc. Would you please tell me What is use of this file? and what should be put into this file?

Thanks a lot.

zhiyong
My life is now asking and learning, I wish It can change into replying and discussing
T G Manikandan
Honored Contributor

Re: "ntpq -p" error: can not find local host

Hello
/etc/nsswitch.conf file is used to find order of lookup for various sources of OS like passwd,hosts.

It is a name service configuration file.
For ex.
the order of lookup for to resolve your host names
whether first through your /etc/hosts file or using your DNS server..

If you are not using the DNS the machine you can copy the /etc/nsswitch.files /etc/nsswitch.conf

If you are using DNS then you can just edit the /etc/nsswitch.conf file and then make an entry like the below

hosts : dns{NOTFOUND=return} files

Please post the /etc/hosts and /etc/nsswitch.conf contents

thanks
Bill Hassell
Honored Contributor

Re: "ntpq -p" error: can not find local host

The first thing to test when a network program can't find a host is to run: nslookup host_name and see if it actually exists. Without /etc/nsswitch.conf, /etc/hosts will never be consulted if /etc/resolv.conf exists.

However, I would strongly recommend this entry for the hosts line:

hosts: files[NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]

T*The above is one long line)

The reason is that /etc/hosts is 10x-100x faster if resolving IP/hostnames and by putting the most important production servers into /etc/hosts, system reliability goes up tremendously.

The failure you are seeing is that localhost is totally unknown in your DNS servers (as well it should be).


Bill Hassell, sysadmin
Tim D Fulford
Honored Contributor

Re: "ntpq -p" error: can not find local host

Zhiyong (& Bill)

/etc/nsswitch.conf holds the look-up rules e.g
hosts: files nis dns #... and so on

/etc/resolv.conf holds the nameserver to use for lookups i.e. DNS servers may look like
doamin someplace.com
search somplace.com
nameserver 172.12.15.1
nameserver ....

There seems to be some confusion over the two files above...

otherwise (as far as I can tell) the advice is good

Tim
-
Bill Hassell
Honored Contributor

Re: "ntpq -p" error: can not find local host

You'll need to change your nsswitch.conf file to specify an explicit behavior for problems. The line:

hosts: files nis dns

is a bit too undefined. Do you have NIS? If not, don't specify it in nsswitch.conf. Also, both resolv.conf and nsswitch.conf must be permissions: 644 so that everyone can read the rules.

Now change the nsswitch.conf line to:

hosts: files[NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]

Finally, use:

nslookup localhost

to see what you get. It should look at FILES and then find localhost.


Bill Hassell, sysadmin
Roger Baptiste
Honored Contributor

Re: "ntpq -p" error: can not find local host

hi,

Once you have sorted out nsswitch.conf and related resolver checks,
make sure your ntp configuration is set correctly. The /etc/ntp.conf file should have the entry like this:
server HOSTNAME version 3 prefer
(where hostname is the NTP server name)

Then run ntp by
#/sbin/init.d/xntp start

and check by ps -ef |grep ntp

HTH
Take it easy.
szhiyong
Frequent Advisor

Re: "ntpq -p" error: can not find local host

Hi,All,

The instructions are really helpful. I can use ntpq -p now.

Thanks a lot!

zhiyong
My life is now asking and learning, I wish It can change into replying and discussing