Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed NTP server on Ubuntu Server 10.04 using:

sudo apt-get install ntp

The NTP daemon seems working and listening on the 123 port.

However, I was not able to get the time from another machine:

sudo ntpdate -u my_ntp_server
23 Nov 18:48:41 ntpdate[2990]: no server suitable for synchronization found

Is there any necessary configurations to do?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Here's a good how-to from ubuntu forums: http://ubuntuforums.org/showthread.php?t=862620

share|improve this answer
    
Thanks for the link. Actually, I did not change my configuration! It just worked after some time. –  Khaled Nov 24 '10 at 8:03
add comment

There are many links about this and it seems to me that they complicate the procedure. In my case I have one machine that acts as a proxy server and a firewall, and all my others connect to the internet through it. I did not want to open ports on the firewall. Therefore the proxy server must be the time (ntp) server and the other machines (clients) get the time from it.

You must install ntp on all the machines, and you should install ntpq on all of them as well.

First, see if ntp is working. By default, ntpd (the ntp daemon) will be running as soon as it is installed, and the defaults should work. However, ntp does not work instantly, so wait a while. Then, the command:

ntpq -c lpeer

should give you output that looks something like this:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+golem.canonical 193.79.237.14    2 u  170 1024  377  140.458   -0.655   3.234
*gatekeeper.tss. 204.123.2.72     2 u  608 1024  377   84.650    2.168   0.471

or:

ntpq --numeric --peers

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+91.189.89.199   193.79.237.14    2 u  652 1024  377  140.151   -0.242   2.821
*66.7.96.1       204.123.2.72     2 u   64 1024  377   85.074    2.409   0.963

If so, you're connected and your time server is getting the time. If not, use

ps -e | grep "ntp" 

to be sure that ntp in running, and try again. Also try restarting ntp:

sudo /etc/init.d/ntp restart

it may take some "time" (sorry!) before the connection is established. The daemon does not poll the servers very often. The "when" column in the output above shows the time in seconds since the server was polled.

Now, you have to make the time server send the time to your other machines.

Edit the file /etc/ntp.conf on the server. You have to add a line for your network. In my case, I have a 10.0.0.0 network. In the ntp.conf file, I added the line:

broadcast 10.255.255.255

You must add a broadcast line for each segment of your network. If your network is simple like mine, one line like the above is all you need. Now, restart ntp using the command above, and check again using ntpq, and you should see:

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+golem.canonical 193.79.237.14    2 u   70 1024  377  140.151   -0.242   2.821
*gatekeeper.tss. 204.123.2.72     2 u  506 1024  377   84.650    2.168   0.241
 10.255.255.255  .BCST.          16 u    -   64    0    0.000    0.000   0.002

Voila, it's broadcasting.

Now, you must make every client machine get the time from your broadcasting server. On each one, edit the file:

/etc/ntp.conf

and you will see some lines specifying servers.

add a line

server 10.10.10.1

or whatever the address of your server is. Then restart ntp on the client machine using the above command. Alternatively, you can get the process ID and just kill it, and run it again. Whatever.

Then, after sufficient time, check with ntpq:

ntpq --numeric --peers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*10.10.10.1      66.7.96.1        3 u  123 1024  377    0.430    1.022   1.831

and you can see that the client is using the time server.

This takes some time.

share|improve this answer
add comment

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.