[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howtos:network_services:ntp [2012/09/26 03:34 (UTC)] – [Sources] updated tag mfillpothowtos:network_services:ntp [2013/03/01 16:36 (UTC)] – Added a short explanation about problems with NFS and NIS when clients are out of sync kikinovak
Line 6: Line 6:
   * configuring an NTP server on Slackware Linux;   * configuring an NTP server on Slackware Linux;
   * synchronizing client PCs with your local NTP server.   * synchronizing client PCs with your local NTP server.
 +
 +===== Introduction =====
 +
 +When several users manipulate shared data on different client PCs on a network, it's important that these machines are all synchronized. This is especially true if you share files over NFS, or if you use NIS for centralized authentication. You'll get all sorts of weird errors if your clocks are out of sync. Unfortunately, the clients' onboard clocks aren't sufficiently precise.
 +
 +That's where NTP (//Network Time Protocol//) comes in handy. It allows networked machines to adjust their clocks so as to be perfectly synchronized. A series of public time servers on the Internet allow the reception of the exact time. From this point, we can use NTP in several ways.
 +
 +  * The ''ntpdate'' command makes an initial correction of the BIOS clock.
 +  * This one-time-adjustment isn't sufficient for a server that is supposed to be up 24/7, since its clock will drift away gradually from the exact time. In that case, we have to configure the ''ntpd'' daemon (shipping with the ''ntp'' package). This daemon contacts public time servers at regular intervals and proceeds with incremental corrections of the local clock.
 +  * The ''ntpd'' daemon can in its turn be configured as a time server for the local client machines.
 +
 +It's considered good practice to use ''ntpdate'' for the initial adjustment and ''ntpd'' for regular time synchronization.
 +
 +===== Firewall considerations =====
 +
 +The NTP services uses UDP port 123. Open this port if you want to allow remote machines to connect to your NTP server.
  
 ===== Synchronize a LAN server or a public root server with an NTP server on the Internet ===== ===== Synchronize a LAN server or a public root server with an NTP server on the Internet =====
Line 58: Line 74:
  
 <code> <code>
-# chmod 0755 /etc/rc.d/rc.ntpd+# chmod +x /etc/rc.d/rc.ntpd
 </code> </code>
  
Line 82: Line 98:
 The little ''*'' asterisk preceding one of the above lines means your machine is effectively synchronized with the respective NTP server. The little ''*'' asterisk preceding one of the above lines means your machine is effectively synchronized with the respective NTP server.
  
-=== Synchronizing at boot time === +<note tip>The first synchronization can take few minutessometimes up to half an hour.</note>
-If instead of using daemonall you want to do is to synchronize time once per boot, it is possible to add the command ''ntpd -qg &'' in the bottom of the file ''/etc/rc.d/rc.local''. This will synchronize the time once in the background and will exit and it needs ''/etc/rc.d/rc.ntpd'' to not be an executable. +
-   +
-  ~# cat /etc/rc.d/rc.local +
-  #!/bin/sh +
-  # +
-  # /etc/rc.d/rc.local:  Local system initialization script. +
-  # +
-  # Put any local startup commands in here.  Also, if you have +
-  # anything that needs to be run at shutdown time you can +
-  # make an /etc/rc.d/rc.local_shutdown script and put those +
-  # commands in there. +
-  . +
-  . +
-  . +
-  ntpd -qg &+
  
-<note tip>The first synchronization can take a few minutes, sometimes up to half an hour.</note> 
 ===== Synchronize your client PC(s) with your local NTP server ===== ===== Synchronize your client PC(s) with your local NTP server =====
  
Line 139: Line 139:
  
 <code> <code>
-# chmod 0755 /etc/rc.d/rc.ntpd+# chmod +x /etc/rc.d/rc.ntpd
 # /etc/rc.d/rc.ntpd start # /etc/rc.d/rc.ntpd start
 </code> </code>
Line 155: Line 155:
 <note tip>Again, you might have to wait a few minutes before the first synchronization takes place.</note> <note tip>Again, you might have to wait a few minutes before the first synchronization takes place.</note>
  
-===== Firewall considerations =====+=== Synchronizing at boot time ===
  
-The NTP services uses UDP port 123. Open this port if you want to allow remote machines to connect to your NTP server.+If instead of using a daemon, all you want to do is to synchronize time once per boot, it is possible to add the command ''ntpd -qg &'' in the bottom of the file ''/etc/rc.d/rc.local''. This will synchronize the time once in the background and will exit and it needs ''/etc/rc.d/rc.ntpd'' to not be an executable. 
 +   
 +  ~# cat /etc/rc.d/rc.local 
 +  #!/bin/sh 
 +  # 
 +  # /etc/rc.d/rc.local:  Local system initialization script. 
 +  # 
 +  # Put any local startup commands in here.  Also, if you have 
 +  # anything that needs to be run at shutdown time you can 
 +  # make an /etc/rc.d/rc.local_shutdown script and put those 
 +  # commands in there. 
 +  . 
 +  . 
 +  . 
 +  ntpd -qg &
  
 ====== Sources ====== ====== Sources ======
 +
   * Originally written by [[wiki:user:kikinovak|Niki Kovacs]]   * Originally written by [[wiki:user:kikinovak|Niki Kovacs]]
  
 howtos:network_services:ntp ()