Set the time reference on your EC2 instance to use the local Amazon Time Sync Service
The local Amazon Time Sync Service either uses the Network Time Protocol (NTP), or provides a local Precision Time Protocol (PTP) hardware clock on supported instances. The PTP hardware clock supports either an NTP connection (Linux and Windows instances), or a direct PTP connection (Linux instances only). The NTP and direct PTP connections use the same highly accurate time source, but the direct PTP connection is more accurate than the NTP connection. The NTP connection to the Amazon Time Sync Service supports leap smearing while the PTP connection to the PTP hardware clock does not smear time. For more information, see Leap seconds.
Your instances can access the local Amazon Time Sync Service as follows:
-
Through NTP at the following IP address endpoints:
-
IPv4:
169.254.169.123
-
IPv6:
fd00:ec2::123
(Only accessible on Nitro-based instances.)
-
-
(Linux only) Through a direct PTP connection to connect to a local PTP hardware clock:
-
PHC0
-
Amazon Linux AMIs, Windows AMIs, and most partner AMIs configure your instance to use the NTP IPv4 endpoint by default. This is the recommended setting for most customer workloads. No further configuration is required for instances launched from these AMIs unless you want to use the IPv6 endpoint or connect directly to the PTP hardware clock.
NTP and PTP connections do not require any VPC configuration changes, and your instance does not require access to the internet.
Considerations
There is a 1024 packet per second (PPS) limit to services that use link-local addresses. This limit includes the aggregate of Route 53 Resolver DNS Queries, Instance Metadata Service (IMDS) requests, Amazon Time Service Network Time Protocol (NTP) requests, and Windows Licensing Service (for Microsoft Windows based instances)
requests. Only Linux instances can use a direct PTP connection to connect to the local PTP hardware clock. Windows instances use NTP to connect to the local PTP hardware clock.
Contents
Connect to the IPv4 endpoint of the Amazon Time Sync Service
Your AMI might already have configured the Amazon Time Sync Service by default. Otherwise, use the following procedures to configure your instance to use the local Amazon Time Sync Service through the IPv4 endpoint.
For help troubleshooting issues, see Troubleshoot NTP synchronization issues on Linux instances
Connect to the IPv6 endpoint of the Amazon Time Sync Service
This section explains how the steps described in Connect to the IPv4 endpoint of the Amazon Time Sync Service differ if you are configuring your instance to use the local Amazon Time Sync Service through the IPv6 endpoint. It doesn't explain the entire Amazon Time Sync Service configuration process.
The IPv6 endpoint is only accessible on Nitro-based instances.
We don't recommend using both the IPv4 and IPv6 endpoint entries together. The IPv4 and IPv6 NTP packets come from the same local server for your instance. Configuring both IPv4 and IPv6 endpoints is unnecessary and will not improve the accuracy of the time on your instance.
Connect to the PTP hardware clock
The PTP hardware clock is part of the AWS Nitro System, so it is directly accessible on supported bare metal and virtualized EC2 instances without using any customer resources.
The NTP endpoints for the PTP hardware clock are the same as those for the regular Amazon Time Sync Service. If your instance has a PTP hardware clock and you configured the NTP connection (to either the IPv4 or IPv6 endpoint), your instance time is automatically sourced from the PTP hardware clock over NTP.
For Linux instances, you can configure a direct PTP connection, which will give you more accurate time than the NTP connection. Windows instances only support an NTP connection to the PTP hardware clock.
Requirements
The PTP hardware clock is available on an instance when the following requirements are met:
-
Supported AWS Regions: US East (N. Virginia), US East (Ohio), Asia Pacific (Malaysia), Asia Pacific (Thailand), Asia Pacific (Tokyo), and Europe (Stockholm)
-
Supported Local Zones: US East (New York City)
-
Supported instance families:
-
General purpose: M7a, M7g, M7gd, M7i, M8g
-
Compute optimized: C7a, C7gd, C7i, C8g
-
Memory optimized: R7a, R7g, R7gd, R7i, R8g, X8g
-
Storage optimized: I8g
-
High performance computing: Hpc7a
-
-
(Linux only) ENA driver version 2.10.0 or later installed on a supported operating system. For more information about supported operating systems, see the driver prerequisites
on GitHub.
This section describes how to configure your Linux instance to use the
local Amazon Time Sync Service through the PTP hardware clock using a direct PTP connection.
It requires adding a server entry for the PTP hardware clock in the
chrony
configuration file.
To configure a direct PTP connection to the PTP hardware clock (Linux instances only)
-
Install prerequisites
Connect to your Linux instance and do the following:
-
Install the Linux kernel driver for Elastic Network Adapter (ENA) version 2.10.0 or later.
-
Enable the PTP hardware clock.
For the installation instructions, see Linux kernel driver for Elastic Network Adapter (ENA) family
on GitHub. -
-
Verify ENA PTP device
Verify that the ENA PTP hardware clock device shows up on your instance.
[ec2-user ~]$
for file in /sys/class/ptp/*; do echo -n "$file: "; cat "$file/clock_name"; done
Expected output
/sys/class/ptp/ptp
<index>
: ena-ptp-<PCI slot>
Where:
-
is the kernel-registered PTP hardware clock index.index
-
is the ENA ethernet controller PCI slot. This is the same slot as shown inPCI slot
lspci | grep ENA
.
Example output
/sys/class/ptp/
ptp0
: ena-ptp-05
If
ena-ptp-
is not in the output, the ENA driver was not correctly installed. Review step 1 in this procedure for installing the driver.<PCI slot>
-
-
Configure PTP symlink
PTP devices are typically named
/dev/ptp0
,/dev/ptp1
, and so on, with their index depending on the hardware initialization order. Creating a symlink ensures that applications like chrony consistently reference the correct device, regardless of index changes.The latest Amazon Linux 2023 AMIs include a
udev
rule that creates the/dev/ptp_ena
symlink, pointing to the correct/dev/ptp
entry associated with the ENA host.First check if the symlink is present by running the following command.
[ec2-user ~]$
ls -l /dev/ptp*
Example output
crw------- 1 root root 245, 0 Jan 31 2025 /dev/ptp0 lrwxrwxrwx 1 root root 4 Jan 31 2025 /dev/ptp_ena -> ptp0
Where:
-
/dev/ptp
is the path to the PTP device.<index>
-
/dev/ptp_ena
is the constant symlink, which points to the same PTP device.
If the
/dev/ptp_ena
symlink is present, skip to Step 4 in this procedure. If it's missing, do the following:-
Add the following
udev
rule.[ec2-user ~]$
echo "SUBSYSTEM==\"ptp\", ATTR{clock_name}==\"ena-ptp-*\", SYMLINK += \"ptp_ena\"" | sudo tee -a /etc/udev/rules.d/53-ec2-network-interfaces.rules
-
Reload the
udev
rule, either by rebooting the instance, or by running the following command.[ec2-user ~]$
sudo udevadm control --reload-rules && udevadm trigger
-
-
Configure chrony
chrony must be configured to use the
/dev/ptp_ena
symlink instead of directly referencing /dev/ptp
.<index>
-
Edit
/etc/chrony.conf
using a text editor and add the following line anywhere in the file.refclock PHC /dev/ptp_ena poll 0 delay 0.000010 prefer
-
Restart chrony.
[ec2-user ~]$
sudo systemctl restart chronyd
-
-
Verify chrony configuration
Verify that chrony is using the PTP hardware clock to synchronize the time on this instance.
[ec2-user ~]$
chronyc sources
Expected output
MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== #* PHC0 0 0 377 1 +2ns[ +1ns] +/- 5031ns
In the output that's returned,
*
indicates the preferred time source.PHC0
corresponds to the PTP hardware clock. You might need to wait a few seconds after restarting chrony for the asterisk to appear.