macOS Assign dual NTP Servers

Company issued devices usually point to a Time Server which is accessible anywhere across the globe. In my situation the company i work for was not the case.

Users were taking leave over the Christmas period only to lose sync with the Time Server (which was only internal accessible). To rectify this, we had to create a script which points to a internal NTP server failing that, it should fall over to a external or public facing NTP.

The below script was used to get this remotely configured for our business.

#!/bin/sh

#This script has been created to assign 2 NTP Servers on macOS Clients
#Internal and External NTP Servers as listed below

#Primary Time server for Company Macs
TimeServer1=ntp.xx.xx.com.au
#Secondary Time server for Company Macs outside of Corporate Network
TimeServer2=au.pool.ntp.org
# Set the primary network server with systemsetup -setnetworktimeserver
# Using this command will clear /etc/ntp.conf of existing entries and
# add the primary time server as the first line.
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer1

# Add the secondary time server as the second line in /etc/ntp.conf
echo “server $TimeServer2” >> /etc/ntp.conf

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s