Mastering NTP – A Beginner’s Guide to Network Time Synchronization

Mastering NTP – A Beginner’s Guide to Network Time Synchronization

August 17, 2024 Off By Das

Network Time Protocol (NTP) is a protocol that synchronizes the clock on a client with a configured server, ensuring that every device on a network has the same accurate time automatically.

NTP was first introduced in 1985 in IETF’s RFC 958. Since then, the protocol has evolved, and the current version, NTPv4, offers enhanced security features like authentication and encryption, improved correction mechanisms, IPv6 support, and more.

Why is Clock Synchronization Important?

While devices typically offer manual time configuration, NTP is still essential for several reasons:

  1. Human Error and Inaccuracy: Manually setting the time can lead to errors and inconsistencies between devices. NTP ensures that all devices are synchronized with a highly accurate time source.
  2. Log Analysis: Network logs are crucial for management, security, and troubleshooting. If the time is not synchronized across devices, timestamps in logs would be inconsistent, making it difficult to rely on the information from logging systems.
  3. Network Operation Coordination: Time coordination is critical for processes that involve multiple systems. It ensures that operations occur in the correct sequence and at the correct time.
  4. Time-Sensitive Protocols: Accurate time synchronization is vital for security protocols like SSL/TLS certificates, which rely on time-sensitive validity periods.

NTP Hierarchy

NTP operates in a hierarchical structure of clock sources. Each level of this hierarchy is called a stratum:

  • Stratum 1: These are primary clocks, synchronized directly with an authoritative clock source, such as an atomic clock.
  • Stratum 2: These devices synchronize their time with Stratum 1 clocks.
  • Stratum 3: These devices synchronize with Stratum 2 clocks, and so on, up to Stratum 15.

The higher the stratum level, the less reliable the time source is considered.

ntp stratum img

NTP Peers

In addition to the client-server model, NTP can also be configured with NTP peers. Peers are two servers configured to synchronize with each other. If one server loses connection to a higher stratum, it can still stay synchronized by getting the time from its peer. This relationship is bidirectional, meaning each peer can receive time from the other, unlike the unidirectional client-server relationship.

Configuration On Cisco IOS

Manually Clock Configuration:

to manually configure the clock we will use the following command:
to adjust how the time is displayed based on where you are in the world use the following command (‘delta’ is the difference in hours from UTC):

  • (config)# clock timezone [zone_name] [delta]
to modify the current time and date on the device:
  • # clock set

NTP Clock Configuration:

to configure NTP server we will use the following command on the server side:

  • (config)# ntp master [stratum]
to set the server on the client side we will use the following command:
  • (config)# ntp server [server_ip]
to set an NTP peer:
  • (config)# ntp peer [peer_ip]

Verification:

to view the time on he device:

  • #show clock
to watch more details about associans related to NTP servers use the following command:
  • #show NTP assosiciations
to watch more details about the ntp on the device use the following command:
  • #show NTP status