Network Time Protocol Overview

By: Richard Glaser - Revised: 2014-01-22 richard

Download Slides – PDF-File, 572.4 KB

Introduction

Richard will provide an overview on the campus network time services and options to modify the configuration on Mac OS X clients, like System Preferences, ARD 2.x, editing ntp.conf and using a script.


What is the Network Time Protocol?

Network Time Protocol (NTP) is a protocol designed to synchronize the clocks of computers over a network. Mac OS X uses ntpd internally to synchronize time, as done on other unix systems. Configuration is easiest via the System Preferences application, which is easy to do on a few stations, but there are other options that are less time consuming, if you manage many Mac OS X clients.

At the University of Utah, there are network time servers provided for students, staff & faculty. Using this central server, will help troubleshoot issues, because other devices will use same time server, and this will allow events to be more easily correlated.

For example areas that greatly depend on the synched time service: log files, bandwidth usage, interface statistics, loss of connectivity, dropped packets, RPT, etc.

Currently, nothing restricts off-campus devices from querying this campus time service. So, it can be used by students, staff & faculty at home.

What are the servers?

There are two sources setup for time services. This are located in two separate locations, reducing issues with network or power outages. Currently in Mac OS X, you cannot setup multiple network time servers using System Preference and need to use another methods noted on this web page.

Hosts

  • time-a.utah.edu
  • time-b.utah.edu
Or you can use the DNS round-robin of time-a and time-b hosts.

Round-Robin DNS
  • time.utah.edu

System Preferences

Mac OS X 10.3

To set NTP or time server, open System Preferences


Click on the "Date & Time" icon in the System.


Click on the "Date & Time" tab, and for the University of Utah, enter the hostname "time.utah.edu".


Apple Remote Access 2.x

If you are using Apple Remote Desktop 2 and have it install on all your Mac OS X clients, you can use the Send UNIX Command to send the following command to update one or more of your clients.

Select clients that you want to update the network time server.


Select "Send UNIX Command" command from the Manage menu.


Enter the following UNIX command, and run command as a admin user.
systemsetup -setnetworktimeserver <timeserver>
For the University of Utah, you want to enter, the following for DNS round-robin, time.utah.edu


Here are some other useful commands in regards to network time:
  • systemsetup -getusingnetworktime
    Display whether network time is on or off.
  • systemsetup -setusingnetworktime <on off>
    Set using network time to either <on> or <off>.
  • systemsetup -getnetworktimeserver
    Display network time server.
  • systemsetup -setnetworktimeserver <timeserver>
    Set network time server to <timeserver>
Here are some other useful commands in regards to time zone:
  • systemsetup -gettimezone
    Display current time zone.
  • systemsetup -settimezone <timezone>
    Set current time zone to <timezone>.
  • systemsetup -listtimezones
    List time zones supported by this machine.
For more information about the systemsetup command, you can use the Send UNIX command , with the "display all output" option enabled and run the following command:
systemsetup -help



Editing ntp.conf

Another option is editing Network Time Protocol configuration file, ntp.conf located in /etc directory. This is a great option if you are using the file maintenance software radmind to manage your clients file system. You would simply edit the file with your favorite text editor and modify the line to:
server time.utah.edu minpoll 12 maxpoll 17


And create an overload of the file to distribute to your managed clients.

The basic format is:
server <timeserver> minpoll <#> maxpoll <#>


Scripting

Here is an script that will enable time synchronization and specific time server for Mac OS X:

#!/bin/sh
#
# script to enable time syncing on Mac OS X.

if [ `uname -s` != "Darwin" ]; then
       echo "error: script must only be run on Darwin systems"
       exit 1
fi

# set this to the NTP server hostname
TIMESERVER=time.utah.edu

# ntp.conf data
TIMECONFIG="$TIMESERVER minpoll 12 maxpoll 17"

# set proper values in NetInfo for ntpd (Mac OS X 10.0 and 10.1?)
niutil -create / /config/ntp
niutil -createprop / /config/ntp server $TIMECONFIG
niutil -resync /

# and set file data, just in case (Mac OS X 10.2?)
echo "server $TIMECONFIG" > /etc/ntp.conf

# enable timesyncing in startup preferences file
if grep ^TIMESYNC /etc/hostconfig >/dev/null; then
       perl -i -ple 's/-NO-/-YES-/ if /^TIMESYNC/' /etc/hostconfig
else
       echo "TIMESYNC=-YES-" >> /etc/hostconfig
fi