2

I have some raspberry pi computers on a private network which do not have real time clocks and thus cannot keep time accurately after they are shut off. Because they are disconnected from the internet, they cannot use ntp to update their clocks after they sync.

However, I can connect my mac to the private network and ask the raspberry pi computers to get the the current time from the mac.

When I try doing this, it does not work.

The ntpd launchd service is disabled on High Sierra. When I try to start it, this happens.

$ sudo launchctl load -w /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist 
Password:
/System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist: Service is disabled

I tried to enable like so, to no avail

$ sudo launchctl enable system/org.ntp.ntpd-legacy
$ sudo launchctl load -w /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist
Password:
/System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist: Service is disabled

so I have to start it manually like so:

sudo /usr/sbin/ntpd

When I test on the pi to see if the ntp sync is working, I get this:

pi@jessie:~ $ timedatectl status
      Local time: Mon 2018-05-07 14:53:03 GMT+7
  Universal time: Mon 2018-05-07 21:53:03 UTC
        RTC time: n/a
       Time zone: Etc/GMT+7 (GMT+7, -0700)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Notice that NTP synchronized is set to "no".

When I test to see if the times are synchronized, this is the result:

$ date; SSHPASS='pass' sshpass -e ssh pi@pi1 date
Mon May  7 14:52:23 PDT 2018
Mon May  7 14:52:00 GMT+7 2018

The times are not synchronized. I am uncertain how to debug. It is not clear where the ntpd logs are stored.

Ultimately, I just want to be able to start ntpd and have it respond to requests for time.

2 Answers 2

4

You have to configure ntp.conf and ntp-restrict.conf to run a local time server:

  1. Kill ntpd
  2. Add

    server 127.0.0.1 prefer
    fudge 127.0.0.1
    

    at the end of /etc/ntp.conf.

  3. Add

    restrict <network_address> mask <net_mask> nomodify notrap
    

    after the localhost restriction block in /etc/ntp-restrict.conf. Replace <network_address> with your local network address (e.g. 192.168.2.0) and <net_mask>with your mask (e.g. 255.255.255.0)

  4. Reload org.ntp.ntpd-legacy (I had no problem to load the system daemon - SIP disabled though):

    sudo launchctl unload -w /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist
    sudo launchctl load -w /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist
    
  5. Check your time server locally:

    ntpdate -vdq 127.0.0.1
    

    Usually the server is not suitable on the first attempt because the stratum is to high (i.e. 16 = unsynchronized)! Wait some time and try again. Here it took about 10 minutes to bring the stratum down to 2 from 16.

  6. Connect your Mac to the private network and try to sync your Raspberry Pi clients.
1
  • With SIP enabled you can just copy the file: sudo cp /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist /Library/LaunchDaemons/ and modify it to be 'Enabled' then run it: sudo launchctl load -w /Library/LaunchDaemons/org.ntp.ntpd-legacy.plist
    – Pierz
    Commented Jun 21, 2018 at 21:25
0

Pierz' * solution worked, and seems the best, for me. (I quote it more or less verbatim because I don't have enough reputation to just comment)

  • Copy the disabled plist file from /System/Library to /Library:
    • sudo cp /System/Library/LaunchDaemons/org.ntp.ntpd-legacy.plist /Library/LaunchDaemons/
  • Edit the new file to un-disable the job. I.e. remove both these lines:
    • <key>Disabled</key> <true/>
  • Then start the launchd job (which will persist after reboots):
    • sudo launchctl load -w /Library/LaunchDaemons/org.ntp.ntpd-legacy.plist

I didn't have to turn off SIP or edit any config files for this to "just work"

(NB: This gets you out of the problem for High Sierra, for Mojave, ntpd is gone, see How do I enable ntpd to serve ntp clients (using macOS 10.14 Mojave)?)

*No relation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .