Internal - external Timeserver settings

Kevin_mueller
New Contributor III

Does anybody have an idea, if there is the possibility to automatically force a mac to choose a different timeserver, depending on your connection?

For example:
If connected to our Office network or VPN -> use an internal Server (DC)
If external -> Use the Apple time server.

Thanks and best regards,
Kevin

2 REPLIES 2

pblake
Contributor III

I have not seen a way to do that. But to combat this, I have edited the Authorizations database to allow non-admin users access to the Date & Time System Preferences Pane. Doing that allowed users to update their time server to anywhere else if needed. See this post by the great @rtrouton - https://derflounder.wordpress.com/2014/02/16/managing-the-authorization-database-in-os-x-mavericks/

GaToRAiD
Contributor II

Here ya go, we have two set, for internal and external. Internal is first, if it can't find that, it will failover to the external which we set as apples.

#!/bin/sh

# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
TimeZone="America/Charleston"
TimeServer1="YourTimeServer"
TimeServer2="time.apple.com"

############# Pause for network services #############
/bin/sleep 10
#################################################

/usr/sbin/systemsetup -setusingnetworktime off 

#Set an initial time zone
/usr/sbin/systemsetup -settimezone $TimeZone

#Set specific time servers
/usr/sbin/systemsetup -setnetworktimeserver $TimeServer1
echo "server $TimeServer2" >> /etc/ntp.conf

# enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
uuid=`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57`
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist

# set time zone automatically using current location 
/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true

/usr/sbin/systemsetup -setusingnetworktime on 

/usr/sbin/systemsetup -gettimezone
/usr/sbin/systemsetup -getnetworktimeserver

exit 0