CCIE or Null!

My journey to CCIE!

Who’s got the time? NTP – Network Time Protocol

with one comment

Anyone who has ever had to troubleshoot any type of issue on a Cisco router knows they have to look through log messages, and anyone who has ever done this knows what’s it’s like to look through a log where the time is off by minutes, hours, days, or even years. It tends to add on another layer of complexity in itself & typically you are going to be in this type of situation:

  1. Ok, I’ve got a problem let’s troubleshoot
  2. Lets look at the logs
  3. HHmm those dates/times are all wrong
  4. Ok let’s issue the sh clock command to see what time the router thinks it is
  5. Now how far off is the router’s internal clock from the real world current time
  6. Alright now what what time did the problem occur in the real world and what time did the problem occur in the router’s time zone
  7. There we go!

It’s not overly complex but it can be a little time consuming and it can cost you a good amount of time depending on the type of issue you are troubleshooting. In my mind this is completely unnecessary and should just be corrected. How do we correct this though? Well we configure our devices to check in with a time server and get the correct time using NTP (Network Time Protocol).

The first thing we will want to do is pick one (or more) of your routers to be the NTP master for the network, and the other routers will connect to this NTP master for the correct time, this will provide us with some type of hierarchical NTP design. Before we configure any clients to check in with the NTP master we decide on we’ll need to get the correct time on the master. To do this we can peer to some of the Stratum 1 public NTP servers. In terms of NTP and Stratum levels, Stratum 1 will be the most accurate time sources, these Stratum 1 servers are directly attached to some type of GPS, WWV, or CDMA device which are stratum 0 devices and are known to have the most accurate time. (Note: Cisco devices do not support the use of these devices if directly attached)

Here is our current topology:

Now let’s configure our router:

From here we configured a timezone for our router, I named the timezone EST I figured I’d keep it simple and set it to -5 which is where the Eastern time zone fits in the world. Then I set daylight saving time with the clock summer-time EST recurring command. After that I start configuring some NTP parameters I start by turning on NTP logging, I did this just for the sake of showing off some of the NTP logging messages. Then I configure the router to update it’s hardware clock with the time it receives from the server with the command ntp update-calendar, the hardware clock runs off an internal battery and will keep the correct time even when the router loses power. Now we configure our router to check in with ntp.you.org this is just one of the stratum 1 servers I pulled off the webpage mentioned earlier.

Now, shortly after I finish with those commands I see some of the NTP logging messages flash through the console:

The messages are simply telling us the clock was reset, and synchronized successfully with the server we configured. We can verify this by looking at the sh ntp status & sh ntp associations output.

You can see from the sh ntp status output, that our time is synchronized, our stratum level is 2, and when the last update was. From the sh ntp associations we can see we are peered with the NTP server 204.9.54.119 (Confirmed with the * before the IP address) and the NTP server we are peering with is using a CDMA device for it’s clock source. Also notice the 127.127.1.1 address, which is the local router.

Next we going to setup our router to be an NTP master for other network devices in our network, and we are going to give our router a stratum level of 2, see the below config. We can can configure this router with any stratum level we want but it’s usually best to configure the stratum level to match it’s real stratum level. A router with a lower stratum will override the time of router configured with a higher stratum level so its best to configure appropriate stratum levels.

So now in SW1 and SW2 I am going to issue the following commands:

This tells the other devices to check in with the router we configured as the NTP master, very similar to the commands we issued earlier on the master. We can verify this again by issuing the sh ntp statussh ntp associations:

Notice there is less information, but it still tells us what we need to know. We see our clock is synchronized and to whom, as well as our stratum level. Our stratum level here is 3, since we got our time from a stratum 2 source and we are one more “time hop” away from the stratum 1 source.

So essentially our NTP design looks like this:

We can do the same thing with even more complex designs:

However NTP would be behave like this:

RFC 1305 goes into NTPv3 much more in depth if you want to read about it, also keep in mind NTP runs off UDP Port 123. (I just had to throw that in there somewhere before I ended this post)

Written by Stephen J. Occhiogrosso

May 29, 2012 at 7:00 AM

One Response

Subscribe to comments with RSS.

  1. […] keep in mind, I’ve built this configuration off my previous NTP lab post so not every NTP command is shown […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: