Skip to content

Cisco IOS Clock Sync (with NTP) and Summer Time/Daylight Saving Time

Tired of having a Cisco-device that always ends up with a wrong clock? I was.

The first thing you’ll need, is a proper NTP-server. You can either set up one locally (which syncs from a hardware-device ? like a GPS ? or from an external server), or you can choose one of the public available NTP-servers. I’ve chosen to use ?158.37.91.134? in this example.

Router(config)#ntp server 158.37.91.134

Thats it. Now your Cisco-device will stay in sync (it might need some time to get in a ?accurate? state, as it has to learn how it’s internal clock varies compared to the external server). Just let it work it’s magic for a while. We can, of course, check it’s NTP-sync-status;

Router#sh ntp status
Clock is synchronized, stratum 3, reference is 158.37.91.134 
nominal freq is 250.0000 Hz, actual freq is 249.9955 Hz, precision is 2**32
reference time is D06AC4AA.47CC6D7C (15:54:50.280 CEST Thu Oct 21 2010)
clock offset is -0.0002 msec, root delay is 0.02 msec
root dispersion is 0.09 msec, peer dispersion is 0.01 msec
loopfilter state is 'CTRL' (Normal Controlled Loop), drift is 0.000017902 s/s
system poll interval is 1024, last update was 1886 sec ago.

Now that we have a working sync, we’ll need to set the correct time zone. You can verify what time zone it’s currently in, if you want;

Router#sh clock
16:29:00.378 CEST Thu Oct 21 2010

This one is in the CEST time zone (Central European Summer Time). To set your time zone;

Router(config)#clock timezone ?
  WORD  name of time zone

Router(config)#clock timezone CET ?
  <-23 - 23>  Hours offset from UTC

Router(config)#clock timezone CET 1

Where the name of the time zone is basically whatever you’d like to call the time zone. Wether you call it ?CET?, ?UTC/GMT+1? or ?LOLZONE? doesn’t really matter; it will accept it. The important part is that you get the offset correct. The offset needs to be between -23 and +23, and to figure out which one you need, you can use Google (search for ?time zone + your country? or something).

Now we have a synced clock, and a correct time zone. Let’s get to the part where we configure the Summer Time/Daylight Saving Time. I’m not sure if this varies between different countries, so make sure you check what applies to your country. I’m from Norway, hence the following example is valid for Norway. We turn our clocks one hour forward at the last Sunday in March, from 02:00 to 03:00, effectively making the new time zone CEST (Central European Summer Time). The Summer Time ends at the last Sunday in October, where we turn our clocks one hour backwards, from 03:00 to 02:00, hence making our new time zone CET. Having this clarified, we can now configure it;

Router(config)#clock summer-time ?
  WORD  name of time zone in summer

Router(config)#clock summer-time CEST ?
  date       Configure absolute summer time
  recurring  Configure recurring summer time

Router(config)#clock summer-time CEST recurring ?
  <1-4>  Week number to start
  first  First week of the month
  last   Last week of the month

Router(config)#clock summer-time CEST recurring last ?
  DAY  Weekday to start

Router(config)#clock summer-time CEST recurring last Sun ?
  MONTH  Month to start

Router(config)#clock summer-time CEST recurring last Sun Mar ?
  hh:mm  Time to start (hh:mm)

Router(config)#clock summer-time CEST recurring last Sun Mar 02:00 ?
  <1-4>  Week number to end
  first  First week of the month
  last   Last week of the month

Router(config)#clock summer-time CEST recurring last Sun Mar 02:00 last ?
  DAY  Weekday to end

Router(config)#clock summer-time CEST recurring last Sun Mar 02:00 last Sun ?
  MONTH  Month to end

Router(config)#clock summer-time CEST recurring last Sun Mar 02:00 last Sun Oct ?
  hh:mm  Time to end (hh:mm)

Router(config)#clock summer-time CEST recurring last Sun Mar 02:00 last Sun Oct 03:00

Now we’re almost done. We need to make sure the time zone is printed in logs and debugs.

Router(config)#service timestamps debug datetime ?
  localtime      Use local time zone for timestamps
  msec           Include milliseconds in timestamp
  show-timezone  Add time zone information to timestamp
  year           Include year in timestamp

Router(config)#service timestamps debug datetime msec ?
  localtime      Use local time zone for timestamps
  show-timezone  Add time zone information to timestamp
  year           Include year in timestamp

Router(config)#service timestamps debug datetime msec localtime ?
  show-timezone  Add time zone information to timestamp
  year           Include year in timestamp

Router(config)#service timestamps debug datetime msec localtime show-timezone ?
  year  Include year in timestamp

Router(config)#service timestamps debug datetime msec localtime show-timezone year

This will format debugs the following way;

Oct 21 2010 16:54:53.598 CEST: ISAKMP (0): received packet from 192.168.0.200 dport 500 sport 500 Global (N) NEW SA

If you also want the above format for logs, just change ?debug? with ?log?;

Router(config)#service timestamps log datetime msec localtime show-timezone year

That’s it. Finally you can enjoy a Cisco-device with a working clock!

9 Comments

  1. I can’t stress the importance of good timekeeping. Most of our devices are running UTC. Everytime we are in summer time we need to remember to move the logs back. Damn annoying!

  2. havard havard

    You can set the router as a NTP server as well. And with an ACL you have your own intern NTP server not eating Internett-bandwith :)
    command: NTP master

    Then your router syncs agains a NTP server and you have your own private NTP in your network. Add it to your DHCP pool with
    ip dhcp POOL
    option 41 ip.to.router

    • jocke jocke

      I had totally forgotten the ?option 41? in DHCP pools. Thanks!

      You don’t have to use the ?ntp master? to enable it as an NTP-server (as long as you use ?ntp server?, that is). The ?ntp master? is just if you’d like it to be an NTP-server without the use of an external NTP-server.

    • jocke jocke

      Btw, it seems that NTP is ?option 42?, and not ?option 41?. (The latter is for NIS).

      • havard havard

        oops! miss-typing.! ment option 42 ;) Just like the meaning with life, the universe and everything ;)

  3. […] ??? ?????1 Cisco IOS Clock Sync (with NTP) and Summer Time/Daylight Saving Time Always Looking To Learn More ???? ?? ??? […]

  4. Andre Andre

    Summer Time/Daylight Saving Time does vary between different countries, but some are the same. Anywho – great recipe for NTP/summertime! :)

    Bergen, NO

  5. Nice one! I still find it annoying that for Europe we need to enter the whole information on the clock summer-time command.

  6. objectclass objectclass

    Great article!

Leave a Reply

Your email address will not be published. Required fields are marked *