NTP Configuration on Cisco Devices

Configure NTP - Network Time Protocol - on Cisco devices, with Packet Tracer Lab

Share This Post

Share on linkedin
Share on facebook
Share on twitter
Share on email

We all want to be on time, so much that timing is a major concern for our fast-paced world. ICT makes no exception, as timing is a real constraint for any modern application. What happens if you make an online payment and then another before concluding the first one? Without the perfect synchronization between systems, you could potentially generate free money, or even destroy them. For this reason, we need a protocol that allows always up-to-date time between devices. We are talking about Network Time Protocol, or simply NTP.

In this article, we will explain how does NTP work from a high-level perspective. Furthermore, we are going to highlight its major benefits from a network perspective, and learn how to configure it on Cisco devices. To do that, we created a simple Packet Tracer lab, that you can download for free using the link below.

Get this lab! Practice what you learn and gain experience with our networking labs and demos - download now

Once you do, just open the Packet Tracer file and continue reading. Following the instructions, you will learn how to configure NTP in minutes.

NTP Configuration Lab Intro

The Topology

For this lab, we tried to keep the topology as simple as possible. The result is a chain of five devices, as in the picture below.

NTP Configuration Lab Topology in Cisco Packet Tracer
This is the topology for this lab.

On the left, we have a small LAN made of a server and a switch, while on the right we have three routers. The three routers exchange reachability information using RIP, so that R2 can ping the NTP Server and vice versa. If you check the IP addresses on the interfaces, you will find that all addresses come from the 10.0.0.0/8 major network.

The Requirements

For this lab, we simply want to configure the NTP association between routers and the NTP Server. The end goal is to have up-to-date time on all devices. Furthermore, we want the date and time to appear on any log information our router generates. As you will see, we can do this with two simple commands per router. However, the big deal here is to understand how NTP works, so just continue to the next section.

Introducing NTP

Network Time Protocol, NTP, is an application-layer protocol that allows the synchronization of times between two devices. While its purpose is simple, the algorithms behind it are extremely complex. You can deploy NTP either in a client-server model or in a peer-to-peer model. While in small environments you are going to use just the first model, in larger deployments you might find both of them.

With the client-server model, there is a device that synchronizes to the time of another device. In other words, the client will end up having the same time as the sever, while the time on the server will remain untouched. For this approach, we need to introduce the concept of Stratum, a number indicating how accurate the NTP Server is. The lower the stratum, the better the server (value ranges from 1 to 15 in Cisco devices). When a client synchronizes to a server with a stratum of X, the client will go to Stratum X+1.

Some systems may require to synchronize with the server at a specific stratum, or lower. This means that those systems have a specific requirement in terms of timing. Stratum 0 is reserved for Atomic clocks, the most precise technology we currently have to measure time.

Instead, with the peer-to-peer model, two devices will synchronize the time with each other. In this case, there is no server device deciding the time. The two devices will slightly adjust their timing going closer to the time of the other until they meet. As a result, when two peers are synchronized they will have the mean time between their original timings.

We use this peer-to-peer approach between servers at low stratum (0-2), to have redundancy. This way, we are going to have two great NTP servers always in sync.

Benefits for the network

In networking, we do not manage financial transactions. Even if we manage the underlying network, this does not necessarily mean that switches in a bank needs to have a 100% accurate time. In networking, timing is important for other reasons.

A clear example is when we deal with many different devices, and we have an Event Management System to collect all logs. If time is accurate, we can understand a sequence of actions over the entire infrastructure. For example, we can know that someone detached a cable, and just after that a routing update was generated.

But there’s more! Many advanced protocols that allow fast convergence of the network rely on time. For example, two switches may send keepalives with each other at milliseconds intervals. In this case, NTP is a must.

Configuring NTP

Now that you have an overview of the NTP functionalities, we can dive into its configuration. Luckily, this is the simplest part. If you want your Cisco router to be an NTP client, you only need to tell the IP address of the server. To do that, we use the ntp server global configuration command, followed by the IP address of the server. In our lab, the NTP Server is 10.0.10.11.

After that, the router will start synchronizing. In real-life, this process can take even a few minutes. However, once the clock is synchronized, we won’t see any difference. If we want to have evidence of the fact that it is functioning, we need to enable date and time logging. By default, every time a router generates a syslog message, it associates it with the number of seconds passed since the boot. If, instead of that, we want to display the exact time and date, we can use service timestamps log datetime msec. This way, we are adding even the milliseconds! To recap, here we have the command we need to enter.

ntp-server 10.0.10.11
service timestamps log datetime msec

Enter these commands on all the routers and your score should reach 100%.

Checking NTP Status

To check if our NTP configuration is healthy, we can use a simple troubleshooting command: show ntp status. This will show us some useful information, like the server we are pointing to and the stratum of our client. Here’s a sample output from R0.

Use show ntp status to check the Network Time Protocol operation, find out more in our free Cisco Packet Tracer lab
Our NTP configuration is working.

The first thing the output is telling us is whether the clock is in sync or not. Then, we know our stratum (of the client), and the reference server. Below, we have some NTP-specific information such as the precision, the reference time, or the root dispersion. These are advanced items we don’t need to worry about for our CCNA journey.

Conclusion

In this simple lab, we discovered how NTP works and how we can use it to improve our network’s performance and behavior. We covered the differences between client-server and peer-to-peer models, and we learned the following IOS commands.

  • ntp server to specify the NTP server to point to
  • service timestamps log datetime msec to enable logging with real-time
  • show ntp status to check the status of an NTP association

Now here’s an extra tip, you can use ntp master followed by the stratum (an integer value from 1 to 15) to create an NTP Server on your Cisco router. Unfortunately, we can’t do this in Packet Tracer.

Now, we are ready to focus on more advanced technologies, such as Access Lists and Network Address Translation. For those, just continue with the CCNA Course, we are almost there!

Don't fail the CCNA Exam!

Failing the CCNA exam equals wasting $300. Don't do that, be prepared instead.
Together with our free course, we offer a companion book with Questions and Answers. And it's only $27.50 if you are following the course.
Alessandro Maggio

Alessandro Maggio

Project manager, critical-thinker, passionate about networking & coding. I believe that time is the most precious resource we have, and that technology can help us not to waste it. I founded ICTShore.com with the same principle: I share what I learn so that you get value from it faster than I did.
Alessandro Maggio

Alessandro Maggio

Project manager, critical-thinker, passionate about networking & coding. I believe that time is the most precious resource we have, and that technology can help us not to waste it. I founded ICTShore.com with the same principle: I share what I learn so that you get value from it faster than I did.

Join the Newsletter to Get Ahead

Revolutionary tips to get ahead with technology directly in your Inbox.

Alessandro Maggio

2017-06-01T16:30:53+00:00

Unspecified

Free CCNA Course

Unspecified

Want Visibility from Tech Professionals?

If you feel like sharing your knowledge, we are open to guest posting - and it's free. Find out more now.