Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Get Accurate time from NTP Servers

  • ntp.py will fetch accurate time from pool.ntp.org for validating/sanity-checking time in your current context. This is nothing unique -- there are thousands of projects on Github alone that do something like this. I generally use this idiom for timestamps that MUST be as accurate as is practical when troubleshooting or documenting activities in risk management research.

pool.ntp.org is an extremely valuable resource, so don't abuse it. If you need an ntp source for frequently fetching trusted time consider setting up your own ntp server [Windows and Linux examples) and have it sync with pool.ntp.org, then have your host sync with that, and then get time from your local environment. If that is impractical (for example, if your software will be running on lots of locally managed hosts), then fetch time from own ntp server. What constitutes too frequently? Bjørn Hansen, who runs pool.ntp.org, says that "Reasonable query intervals are typically from once or twice a day to a 4-5 times an hour depending on the application. Really consider how often the device will need fresh time. A standard ntpd or openntpd server works, too."

If you are deciding to set up your own NTP timesource, consider joining pool.ntp.org -- see: https://www.ntppool.org/join.html

Modern general purpose operating systems all have some kind of Network Time Protocol daemon (ntpd). Ensuring that your standard endpoint setup configures and starts that ntpd seems like a baseline quality goal that should be monitored and show up in your periodic operations & security quality reporting. That will also make it easy for you and those you serve to get reasonably accurate time at a reasonable confidence level.

Use of pool.ntp.org from inside your organization may be policy-inappropriate or or it may be inaccessible (NTP protocol may be blocked at your network perimeter. In that case, your organization may have an "internal" NTP server. If so, replace "pool.ntp.org" with your trusted server.