Header Shadow Image


NTPD: Setting up an NTP server on DD-WRT

Recent power outages and ISP outages left my network without a proper internal NTP server which was, coincidently, installed on an ESXi host.  Having to revert to an external NTP server for the time being, a recent outage with my ISP highlighted the fact that even that isn't enough.  The ISP outage () made it clear I need a solution that is:

  1. Sitting on a lower power device and external to my LAB, so isolated from any large server hosted device.
  2. Doesn't depend on DNS to syn cup time in case an ISP is offline.  
  3. Maintain an accurate time on it's own so it itself will be a reliable source of time when everything is offline.

So went with an OpenWRT and a Raspberry Pi device for just this very thing.  This is super simple:

opkg update
opkg install ntpd
/etc/init.d/sysntpd disable
/etc/init.d/ntpd enable
/etc/init.d/ntpd start
netstat -l | grep ntp

Configure the external NTP servers to use:

root@OWRT01:~# cat /etc/config/system

config system
        option ttylogin '0'
        option log_size '64'
        option urandom_seed '0'
        option hostname 'OWRT01'
        option log_proto 'udp'
        option conloglevel '8'
        option cronloglevel '5'
        option timezone 'EST5EDT,M3.2.0,M11.1.0'
        option zonename 'America/Toronto'
        option log_ip 192.168.0.14
        option log_port 514
        option log_proto udp


config timeserver 'ntp'
        list server '0.ca.pool.ntp.org'
        list server '1.ca.pool.ntp.org'
        list server '2.ca.pool.ntp.org'
root@OWRT01:~#

Set the time manually, in the event the system can't sync it's time with an external server:

# date
# date -k

So our brand new NTP server is sitting on:

192.168.0.12

Let's now set the Date / Time to sync from this NTP server.  For Cisco switches:

mdscisco01#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
mdscisco01(config)#ntp server 192.168.0.12
mdscisco01(config)#end
mdscisco01#show run
mdscisco01#show running-config

Ensure local time is also set correctly:

mdscisco02#
mdscisco02#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
mdscisco02(config)#clock timezone EST -5
mdscisco02(config)#end
mdscisco02#clock set 11:52:00 July 10 2022
mdscisco02#copy run
mdscisco02#copy running-config startup-config
Destination filename [startup-config]?
Building configuration…
Compressed configuration from 7043 bytes to 2639 bytes[OK]
mdscisco02#

For Linux Servers:

[root@mbpc-pc ~]# cat /etc/ntp.conf|grep -Eiv "^#"
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 192.168.0.12
server idmipa01.nix.mds.xyz prefer
server idmipa02.nix.mds.xyz prefer
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

For DD-WRT, configure via the basic config to use the OpenWRT NTP server:

https://i2.wp.com/www.microdevsys.com/WordPressImages/DD-WRT-NTP-Setup.PNG?ssl=1

Configure ESXi hosts you may have:

https://i0.wp.com/www.microdevsys.com/wordpressimages/DD-WRT-NTP-Setup-ESXi-Config.PNG?ssl=1

REF: https://openwrt.org/docs/guide-user/services/ntp/client-server 
REF: https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst3750x_3560x/software/release/12-2_55_se/configuration/guide/3750xscg/swadmin.html 
REF: https://wiki.dd-wrt.com/wiki/index.php/Network_Time_Protocol#:~:text=You%20cannot%20set%20your%20time,to%20match%20your%20local%20time.

HTH


 


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License