HOWTO: Network Time Protocol On Linux, FreeBSD, And Windows

Glenn Sidman
email address
Updated: April 27, 2005




1.0 About This HOWTO

Numerous services rely on accurate date and time: Kerberos authentication, file synchronization, logging, and certificate services to name a few. Setting up time synchronization with the NTP (Network Time Protocol) on your local network is fairly straightforward and provides some real benefits. Additionally, NTP can be used to synchronize your local network time with free public Internet timeservers.

This HOWTO covers setting up time synchronization between *nix and Windows machines with NTP. Specifically, I will cover using ntpd as both a client and a server on Linux and FreeBSD systems to synchronize local system time with public Internet time servers and provide NTP services for a local area network which may contain Windows clients. For Windows, I will cover setting up an NTP client with Netime 2.0 as well as converting the W32Time service on Windows 2000/XP to speak NTP.


2.0 A Quick Look At Time Protocols

The Network Time Protocol (NTP) has become the de facto standard for network time synchronization. The current version of NTP, version 4, is backward compatible with version 3 defined by RFC 1305 (At this time, I am not aware of an RFC specifically for NTP version 4). A "simpler" version of NTP is the Simple Network Time Protocol (SNTP) as defined in RFC 2030. Windows NT/2000/XP use SNTP over RPC (Remote Procedure Call) to synchronize time with Domain Controllers and with some minor modification can be made to work with NTP over UDP. The two protocols are designed to be compatible with each other and are often referred to interchangeably.

NTP is simple yet intelligent when implemented with ntpd (The Unix Network Time Protocol Damon). The ntpd program will poll multiple synchronization sources, calculate the round trip time for each query, adjust the results to account for network latency, and average the results to produce the most accurate reference time possible. If this reference time varies by a few milliseconds from the system time, then ntpd will make a correction to the local system clock. Larger variances will be distributed over a period of time (slewing), while significant changes will be rejected completely (sanity check). Additionally, ntpd will keep track of the internal clock's accuracy and adjust the number of NTP time queries accordingly. In the event that synchronization sources become unavailable, ntpd can anticipate the internal clock skew and make a good guess on the correct adjustments until a synchronization source is again available (this requires that a "driftfile" is specified as explained later). A more detailed explanation of the NTP algorithm is available at: http://www.ntp.org/ntpfaq/NTP-s-algo.htm

The most reliable source of time is a Stratum 1 server which polls time directly from a precise reference clock such as a cesium clock or a GPS (Global Positioning System) unit. A Stratum 2 server polls its time directly from one or more Stratum 1 servers and so on. If you need extremely accurate, secure, and reliable time, you can spend some money and setup a Stratum 1 timeserver with a GPS unit. For the rest of us, we will want to benefit from the availability of numerous free Stratum 1 and Stratum 2 public time servers. Due to the high load on Stratum 1 time servers, it is often more reliable, and certainly more polite, to use the Stratum 2 time servers.


3.0 Selecting A Public Internet Time Server

The first thing we will need is a source of accurate time. There are many originations gracious enough to provide public time services. You should at least look at their agreement terms before using their services. A good list and explanation of public time servers is available at www.eecis.udel.edu/~mills/ntp/servers.html. You should pick at least 2 to 3 different timeservers each on different networks and/or geographic regions for redundancy and correctness.


4.0 A Note For Dialup Users

The NTP configuration used in this HOWTO for external synchronization sources will cause problems with dialup or other part-time Internet connections. While a properly configured internal client connecting to an internal NTP server will not bring up a connection, you will need to look at other options to synchronize your NTP server with the public timeservers. The first option is to pretend you have a full-time connection and simply configure PPP to not raise or keep a link alive on UDP port 123. The NTP demon may complain a bit, but it should continue to synchronize during times when the link is up.

Another option is to use ntpdate to synchronize your internal NTP server with the public timeservers. Before proceeding with ntpdate, you should be aware that there is no sanity checking performed prior to time and date changes. If the synchronization source is off by several hours or even days, your system time will suddenly be off by several hours or days. To use ntpdate, simply remove the "server" arguments and public timeservers from the /etc/ntp.conf file to prevent ntpd from performing synchronization. (/etc/ntp.conf configuration is explained later).

You can tell ntpdate to synchronize time on each boot by adding the following to /etc/rc.conf:

ntpdate_enable="YES"
ntpdate_flags="[name_or_IP_of_timeserver]"

Additionally, you can add a cron job to run the following script, say maybe once a day. (ntpdate needs to run 2 times on each external synchronization source, and the script will need to bring up your link if PPP is not configured to bring it up automatically):

# update time with ntpdate
ntpdate [name_or_IP_of_1st_NTP_server]
ntpdate [name_or_IP_of_1st_NTP_server]

I have seen mention of "slicker" ways to deal with NTP and part-time connections, but have never tested them. You may want to Goggle it.


5.0 Installing ntpd (Linux and FreeBSD)

For FreeBSD users, there is nothing to do. It is already installed. Move on to "Configuring ntpd with ntp.conf (Linux and FreeBSD)".

For Linux users, it is probably installed, but not always. As there are many different ways to install packages on the variety of Linux distributions, I will focus on the popular Red Hat distribution. Chances are, if you are using something different, you already know how to install it. Lets find out if ntpd is installed on a Red Hat 9.0 machine.

rpm -q ntp

If you receive zero output, then ntpd is not installed. In my case, rpm returned "ntp-4-1.1.1a-9". Yes, it is already installed. Though we may want to consider upgrading to the latest package. Either way, the following command will perform a new installation of ntpd or upgrade an existing instillation. This example assumes you downloaded ntp-4.1.2-0.rc1.2.i386.rpm.

rpm -Uvh ntp-4.1.2-0.rc1.2.i386.rpm


6.0 Configuring ntp.conf (Linux and FreeBSD)

As far as I know, the configuration of ntpd is the same for all Linux and FreeBSD systems. There is one file, ntp.conf. If your system does not have an /etc/ntp.conf, simply create it. Otherwise, you can edit the existing file as well as refer to the comments within the existing file. (ntp.conf resides in /etc on both Linux and FreeBSD, although, FreeBSD users will likely need to create it).

I have seen many, I mean many, different ways of configuring ntpd. I chose to use a fairly restrictive configuration. In the following example, NTP query and control messages from everyone are denied except those we specifically allow, though the only command that is actually required for ntpd to function is a single "server" command. The 1.1.1.1, 2.2.2.2, 3.3.3.3 represent the addresses for our synchronization sources and are fake. You should have at least 3 synchronization sources, but can add more. Our internal network for this example is assumed to be 192.168.1.0 with a subnet mask of 255.255.255.0. Obviously, these numbers may need to be change for your real configuration.


         
# /etc/ntp.conf 

restrict default ignore

restrict 127.0.0.1

restrict 1.1.1.1 mask 255.255.255.255 nomodify notrap noquery	
server 1.1.1.1

restrict 2.2.2.2 mask 255.255.255.255 nomodify notrap noquery
server 2.2.2.2 

restrict 3.3.3.3 mask 255.255.255.255 nomodify notrap noquery
server 3.3.3.3

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap noquery notrust 
	
driftfile /etc/ntp/drift

The restrict default ignore, ignores all NTP packets from all hosts. The restrict is a keyword followed by the arguments default and ignore. The default represents a default entry of (address 0.0.0.0, mask 0.0.0.0), which means everything. We could also write this as restrict 0.0.0.0 mask 0.0.0.0 ignore. In this example, we begin our configuration by denying everything, and later allowing specified host addresses and subnets. Without these restrictions, anyone on the Internet could use your machine as a timeserver.

    Note: You must add a restriction for each timeserver IP address when you use the "ignore" argument. This will be explained more as we go, but I should tell you now that the restrict key word only works with IP addresses and not DNS names.

When opening ntp.conf with a default restriction, we must then specifically allow our own machine (localhost 127.0.0.1) to communicate with itself. We do this by adding restrict 127.0.0.1 with no arguments. Rather than using something logical like "allow", which does not exist in NTP, we instead use the "restrict" command with no arguments. Just seems odd to me, but that's how it works.

The next three groups of entries make up our chosen synchronization sources, AKA: Internet timeservers. Again, we are using the restrict keyword to override our default restriction of ignore. However, we are tagging on a few restriction arguments because we do not fully trust the Internet timeservers. In the first example, 1.1.1.1 is the IP address of a timeserver. The section mask 255.255.255.255 identifies that we are referring to the single IP address as opposed to a subnet. The nomodify, notrap, and noquery arguments deny NTP control and configuration messages from this IP address, but still allow us to query time. (Actually, I believe nomodify and notrap are redundant when we use the noquery argument, however, I have never tested it, but there is no harm in a little redundancy.)

Now, if we want our internal clients to use this machine as a synchronization source, we need to add a restriction command allowing them to query time. Rather than specify each client machine, which would be insane, we will allow queries from our entire internal subnet with restrict 192.168.1.0 mask 255.255.255.0 (This example assumes your client machines are using address range 192.168.1.1 to 192.168.1.254 with a defined subnet mask of 255.255.255.0). Just as before, the nomodify, notrap, and noquery arguments deny NTP control and configuration messages, but this time from our local subnet. Notice though, that we have added the notrust argument to prevent our timeserver from using machines on our own subnet as synchronization sources.

Finally, driftfile /etc/ntp/drift, declares the path to our optional drift file which can be created anywhere we choose. What is a drift file? In short, ntpd can calculate and predict how far your system time is prone to drift. This information is stored in the driftfile and can be used if NTP servers are unavailable for an extended period of time. I should note that you do not have to create the actual drift file, ntpd will create it after running for 1 hour, and update it every hour after that.

    Note: Why use the IP addresses rather than the DNS names? While referring to DNS names in often recommended for other services, I prefer to use IP addresses for external synchronization sources for a couple of reasons. First, firewall configuration is difficult and often impossible when using DNS names with firewall rules. There are startup issues (DNS is not available until after the firewall rules have loaded) and some timeservers may have multiple addresses associated with a single name. You may open a port for one address while ntpd will attempt to contact the server on a different address and be blocked. Second, and most importantly, the restrict option does not work with DNS names.

Also, while I do prefer to use IP address for external synchronization sources, I always use a DNS name(s), usually an alias, for my internal synchronization source(s). Reasons being, I can easily move my NTP server to a different machine without having to reconfigure each client; I can set the restrict keyword to identify my internal subnet(s) which will apply to all internal clients; Lastly, I do not filter UDP port 123 traffic on my internal subnets, thus, there are no firewall issues preventing clients from successfully using a DNS name.


7.0 Starting ntpd on FreeBSD

If your system time is a little off from the public timeservers, ntpd will gradually synchronize your clock. If there is a significant difference between your system time and the public timeservers (more than 1,000 seconds), ntpd will fail a sanity check. In this case, you will either need to manually set your system (CMOS) time to something reasonably close, or better yet, use ntpdate to force a synchronization by issuing the following command twice against the same time server: CAUTION: ntpdate is capable of making very significant time and date changes. If you clock is way off, these changes can produce some very unexpected results.

ntpdate ntp_server.example.com
ntpdate ntp_server.example.com

The first run will display the offset, and the second run will adjust the clock. If you receive "the NTP socket is already in use" then you already have ntpd running or something else is using the NTP socket. If ntpdate is unable to contact the host, then it is likely you will need to open UDP port 123 on your firewall (or the host is down).

    Note: Newer versions of ntpd provide the -g option to forgo sanity checking and zap in the correct date and time. However, I have never successfully used this option and hear tell most kernels will not allow it in multi-user mode.

Now that we have /etc/ntp.conf configured, and our time and date is in the ballpark, lets start ntpd manually to see if we have syntax errors. But first, a message from the ntp.conf man page: "The syntax checking is not picky; some combinations of ridiculous and even hilarious options and modes may not be detected." Now, start ntpd with the following:

ntpd -p /var/run/ntpd.pid

If you received errors, kill the process, check your /etc/ntp.conf, and restart ntpd. (You can kill ntpd's PID or use killall ntpd to stop ntpd). If ntpd did not complain when you started it, it might be working. Lets find out by using ntpq. Note that ntpd may need to run for a minute or two before ntpq is successful.

ntpq -p (Note that this is ntpq and not ntpd)

The result is a bit cryptic, but you can refer to the NTPQ man page for explanations. The important thing is that you do not receive a LOT of zeros from your synchronization sources and the jitter is something other than 4000. The below example shows successful synchronization with "clock.example.org" and failed synchronization with "ntp1.example.com".

 remote             refid           st  t when  poll   reach   delay   offset   jitter
========================================================================================
clock.example.org   ntp0.broad.mit.  2  u  132  1024   377  152.649   -11.921   3.962
ntp1.example.com    0.0.0.0          2  u   -   64     0    0.000      0.000    4000
If you are unable to synchronize with one or more timeservers, it is possible that the public time servers you have chosen are not accepting your query, have changed their name, or no longer exist. Also, review your ntp.conf configuration and ensure your firewall is open to your synchronization sources.

To start ntpd on boot, we simply need to add xntpd_enable="YES" to /etc/rc.conf. (On FreeBSD5.x, replace xntpd with ntpd ). You can check /etc/defaults/rc.conf for more details, but be sure to make your changes to /etc/rc.conf.

    Note: The correct entry for FreeBSD 4.x is in fact xntpd_enable rather than ntpd_enable even though the real xntpd is an older version of NTP. Why? Lets find out. First we need to know that /etc/defaults/rc.conf is always read when FreeBSD boots and that /etc/rc.conf simply overrides these defaults. Now lets look at all lines with "xntpd" in /etc/defaults/rc.conf by using our good friend grep:

grep xntpd /etc/defaults/rc.conf
   xntpd_enable="NO"               # Run ntpd Network Time Protocol (or NO).
   xntpd_program="/usr/sbin/ntpd"  # path to ntpd, if you want a different one.
   xntpd_flags="-p /var/run/ntpd.pid"      # Flags to ntpd (if enabled).
Notice the xntpd_program="/usr/sbin/ntpd" which points FreeBSD to ntpd rather than the older xntpd. Also notice that the pid file is declared for us in the default rc.conf file. Even though the default file states xntpd_enable="NO", we are overriding it with "YES" in /etc/rc.conf.


8.0 Starting ntpd on Linux

First, lets use pgrep to find out if ntpd is already running:

pgrep ntpd (If pgrep is not recognized, then use ps aux | grep ntpd)

No output indicates that it is not running and we can move on. If it is running, pgrep will have returned the process ID and you may want to kill it for now with kill process_id_number.

If your system time is a little off from the public timeservers, ntpd will gradually synchronize your clock. If there is a significant difference between your system time and the public timeservers (more than 1,000 seconds), ntpd will fail a sanity check. In this case, you will either need to manually set your system (CMOS) time to something reasonably close, or better yet, use ntpdate to force a synchronization by issuing the following command twice against the same time server: CAUTION: ntpdate is capable of making very significant time and date changes. If you clock is way off, these changes can produce some very unexpected results.

ntpdate ntp_server.example.com
ntpdate ntp_server.example.com

The first run will display the offset, and the second run will adjust the clock. If you receive "the NTP socket is already in use" then you already have ntpd running or something else is using the NTP socket. If ntpdate is unable to contact the host, then it is likely you will need to open UDP port 123 on your firewall (or the host is down).

    Note: Newer versions of ntpd provide the -g option to forgo sanity checking and zap in the correct date and time. However, I have never successfully used this option and hear tell most kernels will not allow it in multi-user mode.

Now that we have /etc/ntp.conf configured, and our time and date is in the ballpark, lets start ntpd manually to see if we have syntax errors. But first, a message from the ntp.conf man page: "The syntax checking is not picky; some combinations of ridiculous and even hilarious options and modes may not be detected." Now, start ntpd with the following:

service ntpd start

If you received errors, kill the process, check your /etc/ntp.conf, and restart ntpd (You can stop ntpd with service ntpd stop). If ntpd did not complain when you started it, it might be working. Lets find out by using ntpq. Note that ntpd may need to run for a minute or two before ntpq is successful.

ntpq -p (Note that this is ntpq and not ntpd)

The result is a bit cryptic, but you can refer to the NTPQ man page for explanations. The important thing is that you do not receive a LOT of zeros from your synchronization sources and the jitter is something other than 4000. The below example shows successful synchronization with "clock.example.org" and failed synchronization with "ntp1.example.com".

 remote             refid           st  t when  poll   reach   delay   offset   jitter
========================================================================================
clock.example.org   ntp0.broad.mit.  2  u  132  1024   377  152.649   -11.921   3.962
ntp1.example.com    0.0.0.0          2  u   -   64     0    0.000      0.000    4000
If you are unable to synchronize with one or more timeservers, it is possible that the public time servers you have chosen are not accepting your query, have changed their name, or no longer exist. Also, review your ntp.conf configuration and ensure your firewall is open to your synchronization sources.

Now lets configure ntpd to start on boot. You will need to use the tool appropriate for your Linux distribution, or even Webmin. The following examples use chkconfig available on Red Hat, but often included on other distributions. Lets take a look at the ntpd run levels with chkconfig --list ntpd.

chkconfig --list ntpd
    ntpd    0:off   1:off   2:off    3:off    4:off    5:off    6:off
    Note: If you receive "command not found" when running chkconfig, then it is either not installed on your distribution, or not found within your path variable. You will need to update your path variable, or use the full path to chkconfig which will often be /sbin/chkconfig --list ntpd.

Looks like all run levels are off. Now lets configure it to start using the default runlevel:

chkconfig ntpd on

Now lets take a look at those run levels again:

chkconfig --list ntpd
    ntpd    0:off   1:off   2:on    3:on    4:on    5:on    6:off
Looks like we got it now, ntpd will start on run levels 2, 3, 4, and 5.


9.0 Firewall And Security Considerations

The Network Time Protocol, as described in RFC-1305, operates over UDP port 123. This applies to both the client query and the server response (NTP does not use a random high-number port on the client like many other protocols). Some consideration should be taken before opening UPD 123 to the world, as with any service there is always some level of risk. If you are paranoid, or require a moderately high level of security, do not use Internet time servers and keep UPD port 123 closed. You can still use NTP to synchronize your internal network which is the most critical, but use alternative methods such as manually updating your NTP server clock, or using a GPS device, to keep your internal time reasonably close to real time.

If you are less paranoid, it is best to only allow external UDP 123 traffic between your internal NTP server(s) and your chosen external NTP public servers while denying your internal clients access to any external NTP servers. This does nothing to prevent IP spoofing, but it does provide an additional layer of security and helps to hide your NTP port from scanners.

The bottom line is that you need to consider the consequences of having your network time high-jacked. If someone else can control your time, then scheduled jobs, log files, time-based authentication, file synchronization, and more can all be effected. This is an unacceptable risk for a large company, however, the benefits of free synchronized time are probably more than worth it for home and most small businesses. While I am touching on security, I should probably mention that NTP version 4 provides symmetric-key and public-key authentication. Please refer to the NTP.CONF man page for more information.


10.0 Configuring Windows Clients

Our Windows clients will need an RFC-1305 NTP client that will speak to our *nix NTP server. For Windows 95/98/ME you will need to download a third-party client which is covered later in this section. With Windows NT/2000/XP clients, you have an option of downloading a third-party client or using the built in W32Time service that is based on the SNTP (Simple Network Time Protocol) as described in RFC-2030. I would first like to cover the use of SNTP which is a lighter version of NTP designed for use over RPC, but capable of speaking NTP over UDP 123.

    Samba Note: Samba Note: If you have a Samba server configured to emulate a Windows Domain controller, it may be possible to configure Samba to emulate a Windows timeserver by setting time server = yes in the Samba configuration file. In theory, your Windows 2000/XP clients would then synch time from the Samba server thinking it was a Windows Domain controller. At least that is how I understand the documentation, but have yet to implement it myself. Nonetheless, if you are using Samba, you may want to investigate.


10.1 Using The Registry To Tweak Windows 2000/XP's W32Time Service

When a Windows 2000/XP client is joined to a Windows Domain, it will automatically begin time synchronization with the authenticating Domain controller. Additionally, the net time command can be used to configure the built in W32Time service and even change the preferred synchronization server. I should tell you now that the net time command will only work with SNTP servers, not with our Unix based NTP server. To get around this, as usual for Windows, we will need to make some modifications to the registry. If this makes you nerves, then please move on to installing a third party client.

    Note: Windows NT does not come with W32Time, however, The Windows NT Resource Kit contains a W32Time client that can be installed and should act much like W32Time of Windows 2000/XP.

To configure W32Time on Windows 2000/XP, we will need to set the following registry values:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Start=0x2
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Type="NTP"
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer="ntp.domain.example"
    Tip: You can create a simple ".reg" file to automate the above modifications to the Windows Registry. Just copy the below text into Notepad or some other plain text editor and save the file with a .reg extension such as ntp.reg. Be sure to update the NtpServer value to match your own IP address or server's DNS name. If you latter need to change/update the NtpServer value, just update the file and re-run it. Note that "Windows Registry Editor Version 5.00" must be the first line and it must be followed by at least on blank line.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"NtpServer"="ntp.domain.example"
"Type"="NTP"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time]
"Start"=dword:00000002

An explanation of the the above values follows and more detailed information can be found at: http://support.microsoft.com/default.aspx?scid=kb;EN-US;223184

Start=0x2 This REG_DWORD value will start the W32Time service on boot. Rather than setting this value, we could have also gone to "Services" in "Computer Management" and set the startup type of Windows Time to automatic. For the curious, the available startup types are:

Type="NTP" This sting value will identify how Windows should attempt, or not attempt, to communicate with a synchronization source. We need to change it from (Type : Nt5DS) to (Type : NTP) The available options are listed below:

NtpServer="ntp.domain.example" This string value will set the synchronization source. We simply need to replace ntp.domain.example with the IP address or DNS name of our timeserver. This can also be a space-separated list containing multiple timeservers (how many I dont know). The following examples are all acceptable: NtpServer="ntp.domain.example", NtpServer="10.0.0.6", and NtpServer="ntp1.example.local, ntp2.example.local, ntp3.example.local". You could also use the Windows net time command to set this value (after Type is set to NTP). The following example will make ntp1.example.local and ntp2.example.local our two synchronization sources (the quotes are only required when you have more than one server in your list).

net time /setsntp:"ntp1.example.local ntp2.example.local"

Now we need to start the "Windows Time" (W32Time) service. Open a command prompt (Click Start, then Run, type "cmd" and click ok.) and issue the following command:

net start "windows time"

If you received an error stating that the requested service has already been started, simply issue net stop "windows time" followed by net start "windows time". Now we can check the System log in Windows Event Viewer for W32Time messages. (Right Click My Computer, select Manage, expand System Tools, expand Event Viewer, select System). You should see an Information entry stating "The Windows Time service entered the running state." followed by another Information entry "The time service is now synchronizing the system time with the time source [your ntp server])." If instead you find W32Time error messages then take some solace in the fact that they are usually quite helpful in locating the problem.


10.2 Using A Third-party Client on Windows 95/98/NT/2000/XP

There are a variety of free Windows clients, some of which I have listed in Additional Resources, that will talk to your *nix NTP server. Most will run in the system tray, however, the NetTime client can be configured to run as a service on Windows NT/2000/XP machines. NetTime, available from http://sourceforge.net/projects/nettime/, is also the only open source Windows NTP client. For these reasons, I will cover setting up NetTime, but if you have chosen to use a different client, the setup will be similar.

After downloading NetTime, run the installation and walk through the standard prompts. You will be notified that NetTime can be installed as a service and that you must be logged in with administrative privileges on Windows NT/2000/XP for this to succeed. Select "Install Service" no mater what OS you are using.

Next, you will be asked (forced) to configure NetTime before you can complete the installation. Shown below is the functional and well laid out configuration menu. Do not bother with "Auto Configure" as this will attempt to contact a list of Internet NTP servers. Instead, enter the name of your internal NTP server, select "SNTP" as the protocol, and port 123 if needed. Other than that, the configuration is fairly self-explanatory and the defaults work. You may want to uncheck "Show NetTime icon in the system tray at login". The "Find" provides a nifty browser for locating external time servers by region and has the ability to discover your internal time servers.

NetTime Options Menu

    Tip: By selecting "Find" from the NetTime Options menu, you can select "Find Local NTP Servers" to discover NTP servers on your local subnet. This is a very handy tool for locating machines that should NOT be offering time services on your local subnet. It is also a good way to test your NTP server.


11.0 Setting Up Linux and FreeBSD Clients

The following assumes you already have ntpd installed and configured to start on boot. If not, refer to Starting ntpd On FreeBSD or Starting ntpd On Linux. For our NTP clients, all we need to do is configure /etc/ntp.conf and start or restart ntpd. If your client's time is off by more than 1000 seconds, you will also need to run ntpdate as explained earlier. The /etc/ntp.conf keywords and arguments are covered somewhat in Configuring ntp.conf (Linux and FreeBSD) and thoroughly in the ntp.conf man page. The following two examples will allow our client to synchronize with our timeserver, but provide differing levels of functionality and security. For simplicity I have removed the optional "driftfile", but you can add it if you so choose.

The only required ntp.conf command is "server". The following example will instruct our client to synchronize time with our ntp.example.local timeserver. It will also allow anyone to use this client as a synchronization source and send NTP configuration messages.


         
# /etc/ntp.conf 
server ntp.example.local

The next example provides some reasonable restrictions and allows the client to synchronize time with our ntp.example.local timeserver. Specifically, no one with the exception of 127.0.0.1 can send NTP control and configuration messages, or use this client as a synchronization source.


         
# /etc/ntp.conf 

restrict default nomodify notrap noquery noserve
restrict 127.0.0.1

server ntp.example.local

To further explain, the restrict default arguments nomodify, notrap, and noquery deny NTP control and configuration messages from all machines. The noserve prevents our client from acting as a timeserver. The restrict 127.0.0.1 allows our client full access to itself. The server keyword defines our synchronization source. We do not need to add a restrict keyword for our synchronization source because we are allowing our client to trust all machines as synchronization sources. In fact, we would be forced to use our synchronization source's IP address rather than the DNS name if we had needed to add a restrict keyword. For example, if we added notrust or ignore in the restrict default argument.


12.0 Additional Resources

NTP: The Network Time Protocol
http://www.ntp.org/

Public NTP Time Servers
http://ntp.isc.org/bin/view/Servers/WebHome

The Windows Time Service: TechNet
http://www.microsoft.com/technet/prodtechnol/windows2000serv/maintain/operate/wintime.mspx

Some Free NTP Windows Clients:
    NetTime 2.0 at SourceFORGE: http://sourceforge.net/projects/nettime/
Atomic TimeSync from AnalogX: www.analogx.com/contents/download/network/ats.htm
Automachron from One Guy Coding: www.oneguycoding.com/automachron/
WorldTime from The PawPrint.network: www.pawprint.net/wt/




Please feel free to contact me with comments or corrections.

Glenn Sidman
email address