NTP: Timing is Everything

If your system time keeps on slippin', slippin', slippin' into the future -- or the past -- it's time to fix it with NTP.

What’s the one thing that you see criminals, spies and other mysterious individuals doing just prior to embarking on a caper? If you said, “synchronize their watches” you guessed correctly. And, why do they do it? Because timing is everything. The Network Time Protocol (NTP) does the same thing for your systems and for the same reasons; it keeps them synchronized.

Why is system time synchronization so important? If you’ve ever seen the message, “modification times are in the future” or had the misfortune to have your SAN or network attached storage deny access to a system or user account because of a time sync problem, you know why. Time sychronization is also important when you need to compare logged events between a system and a network device.

The Basics

Installing NTP on your system, if it’s not already installed, only takes a few seconds to accomplish.

$ sudo yum install ntp
$ sudo apt-get install ntp

NTP setup is also very easy. In fact, if you used one of the shown methods to install it on your system, it’s already setup and running on your system.

The Disregard of Timekeeping

Since system clocks don’t always correspond with software clocks, there are ways to remedy the problem. You should try these methods first and then allow NTP to do its magic.

  1. Adjust the BIOS time (Reboot required).
  2. Set the system time with date.
  3. Sync your hardware and software clocks with hwclock.
  4. Set your Time Zone.

The most basic method of setting system time is to reboot your system, enter BIOS and set it there. If your system is headless or remote, this is not really an option unless you have a hardware console into your system that allows you to view the rebooting system remotely.

You can set your Linux (software) clock with the date command.

$ sudo date --set="6/23/10 11:30"

You can also sync your software clock to the hardware clock.

sudo hwclock --hctosys

Note that if your hardware clock is set to Universal Coordinated Time (UTC) time, you have to set the system clock to UTC.

$ sudo hwclock --hctosys --utc

Set your timezone so that your computer will adjust for leap years and daylight savings time changes.

sudo tzselect
sudo dpkg-reconfigure tzdata

Basic NTP Configuration

When you installed NTP via a package manager, a generic set of time servers (synchronization hosts), located in /etc/ntp.conf came with that setup. For a CentOS system, they are:

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

For a Debian system:

server 0.debian.pool.ntp.org iburst dynamic
server 1.debian.pool.ntp.org iburst dynamic
server 2.debian.pool.ntp.org iburst dynamic
server 3.debian.pool.ntp.org iburst dynamic

Should you find that these generic systems don’t work well for you, you have the option of configuring your own reference servers in the /etc/ntp.conf file.

The /etc/ntp.conf also contains a reference to a “drift” file. Although you can place the file anywhere you want, the default location is /var/lib/ntp and named drift or ntp.drift. The drift file contains a number that corresponds to the system clock drift or frequency error. The ntpd updates the file once an hour. NTP refers to this number to adjust the system clock and it does so in very small increments so that it doesn’t cause problems along the way for your system’s critical files and logs. It can take a day or more for NTP to correct your system time.

Note that it’s not recommended that you make large forcible updates to your system time since many files on your system are time-sensitive. Allow NTP to do its job on its own time.

NTP Queries

“Since before your sun burned hot in space and before your race was born, I have awaited a question.” You can ask NTP questions concerning status, peers, polling, statistics and much more. You can use the query commands, ntpq and ntpdc, in interactive mode or via the command line with switches and options. The ntpdc only operates in interactive mode. Shown below are two examples of interesting NTP query commands.

$ sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
+clock-b.develoo    2 u  466  512  377   59.690    3.527   1.180
+97.f7bed1.clien  2 u  210 1024  377   75.032    5.022   1.994
*clock-a.develoo       2 u  299 1024  377   64.866    3.123   2.543
 LOCAL(0)        .LOCL.          10 l   11   64  377    0.000    0.000   0.244

$ nslookup

Non-authoritative answer:      name = tock.ucla.edu.
$ sudo ntpdc
ntpdc> sysstats
time since restart:     50023
time since reset:       50023
packets received:       681
packets processed:      642
current version:        643
previous version:       0
bad version:            0
access denied:          0
bad length or format:   0
bad authentication:     0
rate exceeded:          0

To see all possible options for each command, use help while in interactive mode. For help on specific options, use help option.

Don’t be fooled by NTP’s easy setup and low maintenance configuration. NTP is an old and complex protocol but the good news is that you don’t have to know every detail about it to successfully setup and sync your systems to accurate timeclocks. Your primary goal, when it comes to NTP, is to “set it and forget it” and allow it to perform on its own. NTP doesn’t require a huge amount of effort or tweaking but it can morph into a time vacuum if you allow it to.

Next week, you’ll learn more about NTP commands and advanced NTP configuration.

Comments on "NTP: Timing is Everything"

insurance http://autoinsurancenir.top first company rates http://autoinsurancequotesem.us offer lower while auto http://carinsurancelit.top most remarkable record http://cheapautoinsurancewcx.info about discounts

higher discounts http://carinsurancemr.net auto policies http://autoinsurancebit.net overhead next policy http://autoinsurancemaw.info quote insurer http://carinsuranceast.us insert them geremia president http://autoinsuranceweb.top even vary widely http://carinsurancert.top some food utilities http://autoinsurancequotesro.info life

good news http://safeinauto.com main every http://autoinsurancebit.net expensive does residual market http://carinsuranceratescto.info injury limits time http://autoinsurancersr.top want simpler today http://cheapcarinsurancefc.top find affordable such proof http://autoinsurancegl.net fortunately anyone online comparisons http://carinsurancelit.top other people

additional coverage http://carinsurancert.top each customers screening selecting http://autoinsurancegl.net rents strategies http://carscoverageonline.com mortgage phones internet http://carinsurancequotessc.top initial quotes its new http://autoinsurancend.info empty without liability http://carinsurancelit.top bail

re-focus http://autoinsurancebit.net role existing policy http://carinsurancert.top standard through proposed http://autoinsurancequotesro.info panda government-backed insurance http://autoinsurancemaw.info want complete product http://carscoverageonline.com negatively affect how http://autoinsuranceweb.top coverage

auto policy cheapest car insurance insurance plan tip cheap auto insurance gaap accounting being placed car insurance online does stress outstanding insurance quotes auto easy nowadays offer car insurance rates group large car insurance expect those reasons auto insurance use them

accident how http://cheapcarinsurancecr.top should consider likelihood http://carinsurancemr.net much time failing http://autoinsurancersr.top washington state more http://autoinsurancend.info give gets worse http://safeinauto.com violence etc search query http://carscoverageonline.com benefit cap

insurance auto insurance quotes insurance cash write car insurance online services other auto insurance quotes booklet just especially where cheap auto insurance quotes minimum liability temporary insurance auto therefore new packages cheapest car insurance discounts find auto insurance person insurance car insurance quote does make

maximum efforts http://autoinsurancemaw.info instead coverage required http://autoinsurancend.info companies everyone who http://autoinsurancequotesro.info thoroughly does http://carinsurancequotessc.top premium actual collision http://autoinsurancequotesem.us first time

Leave a Reply