Post details: Network Time Protocol Daemon

08/12/06

Permalink Categories: Guides   English (US)

Network Time Protocol Daemon

The NTP is designed to keep clocks on multiple servers synchronized to Atomic Time and is a great tool for Server Administrators. You may be asking why a tool like this is important or why it would be necessary. Well the answer is very simple; over time, time keeping devices tend to "drift" off of an accurate measure. For instance, the watch on your wrist will drift over time and this is still a problem that occurs even on the most modern computers.

Prerequisites

  • The examples in this article are all shown on FreeBSD 6.x
  • The NTPd is part of the FreeBSD base files. You can install the daemon from ports but that is not covered in this document
  • A CLI editor such as ee
  • Additional files and references may be found at the end of the article

[More:]

Setup

The only required file is /etc/ntp.conf. To be able to use the NTPd this file is a must. There are two parts to this file; however, the second part is not necessary since it is covered in the start command. Below I have listed my ntp.conf, but you will want to look up your own time servers to use. Another thing to note is the option 'logconfig all'. You may wish to comment this out to maintain smaller log files.

# This is the configuration file for NTP
# (Network Time Protocol). More info at
# www.NTP.org
# This computer will act as a stratum 2 time
# server by referencing the following
# stratum 1 time servers:

server time.nist.gov prefer
server time-b.timefreq.bldrdoc.gov
server time-a.timefreq.bldrdoc.gov
server nist1.aol-va.truetime.com
server nist1.columbiacountyga.gov
server clock.via.net

# Log Configuration

logconfig all
logfile /var/log/ntp.log

The next step is to edit /etc/rc.conf so that we can start NTPd as soon as the server starts up. To do this, open the file with your favorite editor and add the following lines to the end. The first line tells the the system to enable NTPd. The second line instructs the server to sync when initially started. Pretty simple stuff.

# NTPd
ntpd_enable="YES"
ntpd_sync_on_start="YES"

Starting NTPd


Now there's not much left to do except start the server. That can be accomplished by using the RC script /etc/rc.d/ntpd.

baku# /etc/rc.d/ntpd status
ntpd is not running.
baku# /etc/rc.d/ntpd start
Starting ntpd.
baku# /etc/rc.d/ntpd status
ntpd is running as pid 50037.
baku#

You can verify that the server is running with a couple of quick checks. You can tail the log file or you can look in the process list. Another check is using the date command.

baku# ps x | grep ntp
50037 ?? Ss 0:00.10 /usr/sbin/ntpd -g -p /var/run/ntpd.pid -f /var/db/ntpd.drift
50045 ?? S 0:00.00 /usr/sbin/ntpd -g -p /var/run/ntpd.pid -f /var/db/ntpd.drift
baku# date
Fri Aug 11 18:25:52 CDT 2006
baku#

Earlier I mentioned that the second part of the configuration file wasn't necessary. The reasoning for this is because of the command issued from the RC script to start the daemon above. The switch and file (-f /var/db/ntpd.drift) are there to keep a log of your clock's tendency to drift and compensates for it.

Conclusion


See, that wasn't very hard now was it? Keeping your time accurate is very useful. There are more things you can do with NTPd like securing your daemon so that your network is the only one with access to it. You can also leave it open to share your daemon as a Stratum 2 server. These are more advanced techniques, but that's for another article.

References


ntp.conf

Network Time Protocol
NTP Public Services Project
Clock Synchronization with NTP


Creative Commons LicenseThis post is licensed under a
Creative Commons License.

Comments:

Comment from: smurf [Member] Email · http://www.eluid.org
That's pretty interesting about the clocks drifting over time, I always figured that if you have a full charged battery then your clock would stay dead on but I guess not.
PermalinkPermalink 08/12/06 @ 17:44

This post has 2 feedbacks awaiting moderation...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

Retarded Kids

FreeBSD and Unix/Linux information and software to make it more secure.

August 2010
Sun Mon Tue Wed Thu Fri Sat
<< <     
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Search

Categories

Linkblog

Links

Syndicate this blog XML

What is RSS?

powered by
b2evolution