Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to configure NTP on my machine but it seems that the parameters I set are not being read by the system. Below is my /etc/ntp.conf file. (I applied the most basic configuration to eliminate other issues)

server 10.45.68.47
server 127.0.0.1

After I set the above configuration, I restart the ntpd process by doing the following:

service ntpd restart

And then I get the following output:

Shutting down ntpd:                                        [  OK  ]
ntpd: Synchronizing with time server:                      [FAILED]
Starting ntpd:                                             [  OK  ]

Moreover, I can see the following in /var/etc/messages:

 Apr  2 10:54:07 hsystem1a ntpd[21067]: ntpd exiting on signal 15
 Apr  2 10:54:07 hsystem1a ntpdate[21537]: can't find host ntpServer1 
 Apr  2 10:54:07 hsystem1a ntpdate[21537]: can't find host ntpServer2 
 Apr  2 10:54:07 hsystem1a ntpdate[21537]: no servers can be used, exiting

So it seems that the ntpServer1 and the ntpServer2 are being read from somewhere instead of the IPs I configured in /etc/ntp.conf.

NOTE: I done init 6 on the machine just in case.

UPDATE It seems that the target server is reachable but it is not synchronized. I know that if the synchronization is successful, then "*" should appear near the server name:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 omap            127.0.0.1        7 u   50   64  377    0.269  -21536.   4.813
share|improve this question
add comment

2 Answers

On Red Hat there are a couple of things that happen when you do service ntpd restart.

  1. ntpd is stopped
  2. ntpdate is run to set an initial time. This is because, by default, ntpd will not adjust the system time past a certain threshold. ntpdate does a one off time set using a specified time server. You can do this manually with ntpdate 10.45.68.47 as long as ntpd isn't running.
  3. ntpd is started again

ntpd's servers are specified in /etc/ntp.conf but ntpdate takes them from a file called /etc/ntp/step-tickers. If you look in the ntpd script in /etc/init.d you'll notice that ntpdate uses this file if there is anything in it (if it is empty, the ntpdate step is skipped). You can put your time servers in here:

server 10.45.68.47

and ntpdate will use them to set the initial time.

As an aside, you shouldn't have localhost as a time server. Use a local server and maybe some servers from the ntp pool project. Make sure they are geographically close to you for best results. Also, I would re-instate the default Red Hat config as it has some sensible defaults i.e. not allowing other servers to set the time on your server.

share|improve this answer
    
Hi and thank for your very detailed answer! However when I added my IPs to the /etc/ntp/step-tickers, the servers changed but now I see the following in the /var/log/messages/: Apr 2 14:13:22 hsystem1a ntpdate[12701]: can't find host server Apr 2 14:13:22 hsystem1a ntpdate[12701]: can't find host server. I don't understand why the hosts couldn't be found since I can easily SSH to them.. When I try ntpdate 10.45.68.47 I get the following error ` 2 Apr 14:13:38 ntpdate[12712]: the NTP socket is in use, exiting`. Any ideas? Thanks again! –  Eugene S Apr 2 '12 at 11:23
    
Oh, I figured out that ntpdate won't work as long as ntpd is running. So I stopped the ntpd and ran ntpdate 10.45.68.47. I got the following error this time: 2 Apr 14:28:11 ntpdate[20006]: no server suitable for synchronization found. –  Eugene S Apr 2 '12 at 12:08
2  
Check that those two hostnames are resolvable from that machine (using either nslookup or dig). That last message means that that server isn't doing the ntp protocol (though it probably can be reached ok). Can you try pointing ntpdate to a known time server such as one from the pool? Then check that that 10.45.68.47 is serving up ntp and a firewall isn't blocking access to UDP port 123. –  webtoe Apr 2 '12 at 14:11
    
Unfortunately this machine does not have any access to outside world and I do not have a local "valid" NTP server here. I tried to use the nslookup as you've proposed and I've received the following output: nslookup 10.45.68.47 ;; connection timed out; no servers could be reached. –  Eugene S Apr 3 '12 at 8:08
    
Well you can't use ntp then if you have no access to another ntp server. It won't work. When I said use nslookup, I meant something like nslookup hsystem1a which looks up the IP address for hsystem1a. By the looks of that message though, you don't have correct name servers set (so hostnames can't be turned into IP addresses). You need to put some into /etc/resolv.conf. –  webtoe Apr 3 '12 at 9:34
show 4 more comments

You're apparently using Debian.

Default config options are in /etc/default/<daemon-name>.

EDIT: okay, not Debian :)

The simple truth is that you cannot run ntpdate and ntpd on the same computer without a port collision - ntpd listens on UDP 123, and ntpdate sends from UDP 123.

share|improve this answer
    
Nevertheless it's RHEL :) –  Eugene S Apr 2 '12 at 8:12
    
Did you check /etc/default ? :) –  adaptr Apr 2 '12 at 8:12
    
Yes I did, but there are only 2 nonrelated files (nss and useradd). –  Eugene S Apr 2 '12 at 8:13
    
AH, I see in your log that it is in fact ntpdate interfering; this is annoying but happens a lot. ntpdate also uses the source port 123, which means ntpd cannot bind to it... –  adaptr Apr 2 '12 at 8:32
    
I was not aware of it. Isn't it a part of ntp startup/update process itself? These lines appear when I restart the ntpd service. Are you saying that I should configure the ports otherwise? Thanks! –  Eugene S Apr 2 '12 at 9:18
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.