Using Mac OSX's NTP service for Parallels guests: a solution

Discussion in 'Parallels Desktop for Mac' started by mcg, Nov 24, 2006.

  1. mcg

    mcg

    Messages:
    168
    I have been able to reconfigure Mac OSX's built in ntpd daemon---the one that OSX uses to synchronize its clock to external time sources---so that it also serves as the reference for guest OS's.

    Note that this assumes the use of host-only or shared networking. I'm sure you could do something similar with a bridged network, but the changes to this code would be non-trivial.

    1) Make sure your time server is running on the Mac, by going to the "Time & Date" control panel and turning on network time synchronization. Don't worry about choosing a server, just use whatever one the control panel says (like time.apple.com)

    2) Copy the text fragments attached below to a file /etc/new_ntp.conf and /etc/new_ntpdate.conf. Feel free to alter the time servers from what I've chosen. Heck, go back to time.apple.com if you want; that will work fine.

    Why not just use ntp.conf, since both ntpd and ntpdate access it by default? Two reasons:
    --- First, OS X likes to overwrite ntp.conf with its own settings whenever you even slightly mess with its settings via the time/date GUI. I don't want that to happen!
    --- Second, ntpdate queries all the servers in your config file. I just wanted it to query one, in order to save time. Creating a separate ntpdate config file made this happen. But obviously, if you decide to put only one external server into /etc/new_ntp.conf, you can just use that one for ntpdate as well.

    3) Edit the file /System/Library/StartupItems/NetworkTime/NetworkTime, and replace the 'ntpdate' and 'ntpd' startup lines with the following:
    ntpdate -bvs -c /etc/new_ntpdate.conf
    ntpd -c /etc/new_ntp.conf -f /var/run/ntp.drift -p /var/run/ntpd.pid

    You might want to make a copy of the original file so you can revert if you need to.

    4) Restart the time server with this command:
    SystemStarter restart "Network Time"

    5) Now start an ntpd daemon, or ntpdate cron job, on each of your Guests, and point them to 10.211.55.2 (shared networking) or 10.37.129.2 (host-only networking) and get your time service there. For example, for Linux, here's the /etc/ntp.conf I use:
    server 10.211.55.2 prefer minpoll 4 maxpoll 5
    driftfile /etc/ntp/drift
    tinker stepout 1 panic 0

    but your mileage may vary. The "minpoll 4 maxpoll 5" means that ntp is going to poll every 16-32 seconds. The "tinker" statement makes it pretty aggressive about making large step adjustments (useful if the VM has been awakened from a paused state). It seems like it can still take a little while to make it happen, though, so I'm not sure I'm satisfied with this configuration.

    Windows XP has an ntp query service built in, so you could use that, but it doesn't have as fine of a control over parameters like these, which could explain why the Parallels client is superior.

    ---- begin /etc/new_ntp.conf ----
    # Deny by default, allow all from loopbacks and Parallels internal networks
    restrict default kod ignore
    restrict 127.0.0.0 mask 255.0.0.0
    restrict 10.211.55.0 mask 255.255.255.0 nomodify notrap
    restrict 10.37.129.0 mask 255.255.255.0 nomodify notrap
    # Reference servers
    server 0.us.pool.ntp.org
    server 1.us.pool.ntp.org
    server 2.us.pool.ntp.org
    restrict 0.us.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
    restrict 1.us.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
    restrict 2.us.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
    # Fallback clock: the hardware clock
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10
    ---- end /etc/new_ntp.conf ----

    ---- begin /etc/new_ntpdate.conf ---
    server us.pool.ntp.org
    ---- end /etc/new_ntpdate.conf ---
     
    Last edited: Nov 24, 2006

Share This Page