OsX Network Time Server | YOSEMITE

Setting up Time servers on Os X (servers) for the Os X clients of your network.

  • time.euro.apple.com as the source ntp Server.

  • Make sure your DNS are Ok and if needed Add Aliases records

On the Servers you want to deliver Network Time to your Computers, 2 would be a good choice.

Server hostname DNS Alias
srv1.example.com ntp1.example.com
srv2.example.com ntp2.example.com

I’ll consider you’ve setup the Time in System Preferences.

See below for commandline.

We’ll do as follow on the Servers :

Server hostname ntp server 0 ntp server 1
srv1.example.com time.euro.apple.com ntp2.example.com
srv2.example.com time.euro.apple.com  ntp1.example.com

We’ll do as follow on the Clients :

Server hostname ntp server 0 ntp server 1
client1.example.com ntp1.example.com ntp2.example.com
clientn.example.com ntp1.example.com ntp2.example.com

Server Setup

Unload the ntpd service :

sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist

Two ntp Servers as source (time.euro.apple.com + other internal Server)

/etc/ntp.conf

Edit the file /etc/ntp.conf and add iburst at the end of the line of the ‘primary’ ntp server. iburst option will cause ntpd to synchronize right upon startup and not waiting too long. We only put it on the apple ntp server.

Srv1.example.com :

server time.euro.apple.com iburst
server ntp2.example.com

Srv2.example.com :

/etc/ntp.conf

server time.euro.apple.com iburst
server ntp1.example.com

/etc/ntp-restrict.conf

Remove the noquery switch. Restrict to your Subnets only.

Srv1.example.com & Srv2.example.com:

change from :

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# localhost is unrestricted
restrict 127.0.0.1
restrict -6 ::1

to :

restrict default kod nomodify notrap nopeer
restrict -6 default kod nomodify notrap nopeer

# localhost is unrestricted
restrict 127.0.0.1
restrict -6 ::1

# local subnets are unrestricted
restrict 192.168.1.0 mask 255.255.248.0 nomodify notrap

N.B. : edit subnets according to your needs.

Reload the ntpd service :

sudo launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist

Test the Time from a Client or a Server.

On any client (or on the server with 127.0.0.1 as IP) run :

sudo ntpdate -u 192.168.22.1
    15 Dec 23:59:25 ntpdate[95884]: step time server 192.168.1.1 offset 181.272478 sec

sudo ntpdate -u 192.168.22.1
    15 Dec 23:59:33 ntpdate[95903]: adjust time server 192.168.1.1 offset 0.000225 sec

Configure the clients

If you need to find out your timezone :

sudo systemsetup -listtimezones

Stop ntpd

sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist

Set the time zone :

sudo systemsetup -settimezone "Europe/Paris"

Enable Network Time:

sudo systemsetup -setusingnetworktime on

Set the network Time Server:

sudo systemsetup -setnetworktimeserver ntp1.example.com

note, that this command will permit you to enter ONLY ONE Server – aka – one line on /etc/ntp.conf. So this will do the trick :

sudo chmod 777 /etc/ntp.conf
sudo echo "server ntp1.example.com iburst" >> /etc/ntp.conf
sudo echo "server ntp2.example.com" >> /etc/ntp.conf
sudo chmod 644 /etc/ntp.conf

reStart ntpd

sudo launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist

Test it :

sudo ntpdate -u ntp1.example.com
16 Dec 00:36:58 ntpdate[97481]: adjust time server 192.168.1.1 offset 0.000076 sec

Configure the Servers from the command line

Set the time zone :

sudo systemsetup -settimezone "Europe/Paris"

Enable Network Time:

sudo systemsetup -setusingnetworktime on

Set the network Time Server: (server1)

sudo chmod 777 /etc/ntp.conf
sudo echo "server time.euro.apple.com iburst" >> /etc/ntp.conf
sudo echo "server ntp2.example.com" >> /etc/ntp.conf
sudo chmod 644 /etc/ntp.conf

Set the network Time Server: (server2)

sudo chmod 777 /etc/ntp.conf
sudo echo "server time.euro.apple.com iburst" >> /etc/ntp.conf
sudo echo "server ntp1.example.com" >> /etc/ntp.conf
sudo chmod 644 /etc/ntp.conf

Note : Editing the Pref Panes would blow this setting (at least the iburst option)

Usefull Sources :

https://macmule.com/2013/12/15/how-to-use-osx-server-as-a-time-server/

http://ubuntuforums.org/showthread.php?t=862620

Olivier
About

Product and graphic designer turned to be a Mac SysAdmin.

Posted in Admin, Mac, tips tricks scripts Tagged with: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>