What's new

NTP Daemon for ASUSWRT/Merlin

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Hello,

I want to run a NTP server on my ASUS merlin router.

Currently my ASUS merlin router synchronize its time via NTP on the internet.
But internally within my network, I want all devices to get the time from the ASUS merlin router.

So I need to set up ntp server on my Asus Router (RT-AC66U). I found out that I could start ntpd -l in the file: /jffs/scripts/services-start

I noticed I can give ntpd -l command, but it asks for /etc/ntp.conf. I have created an empty file at that place and am able to start ntpd and see in a process overview that it runs (something).

Questions:
1) What should be in the ntp.conf file? Does anyone have a proper example?
2) After a reset the ntp.conf file in /etc/ is gone, and ntpd doesn't seem to be running. How do I fix that?

Who can help me? Thanks!

Pieter

Remarks/context:
- I did give the following file the correct rights: /jffs/scripts/services-start
- ntpd -c does not work, so I don't see how I can redirect to a ntp.conf at another place.
- I run the latest Asus-Wrt merlin as of today.
- I would prefer not to run entware/optware unless really needed.
 

My config file

Code:
# use a random selection of 4 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

interface ignore wildcard
interface listen br0

#restrict default nomodify notrap noquery
#restrict default noquery

disable monitor auth stats

driftfile  /opt/var/spool/ntp/ntp.drift

# replace the following three time servers to
# the ones close to you
server 193.63.94.26 iburst
server 85.199.214.99 iburst
server 194.35.252.7 iburst
server 85.199.214.102 iburst
server 92.27.75.51 iburst
server 85.199.214.100 iburst
server 85.199.214.98 iburst


# GPS(NMEA)+PPS
#server 127.127.20.0 minpoll 4 prefer
#fudge 127.127.20.0 flag3 1 flag2 0

# SMA PPS
#server 127.127.28.0 minpoll 4 prefer
#fudge 127.127.28.0 refid PPS flag3 1
 
I want to run a NTP server on my ASUS merlin router.

...

Questions:
1) What should be in the ntp.conf file? Does anyone have a proper example?
2) After a reset the ntp.conf file in /etc/ is gone, and ntpd doesn't seem to be running. How do I fix that?

Who can help me? Thanks!

Pieter

Remarks/context:
- I did give the following file the correct rights: /jffs/scripts/services-start
- ntpd -c does not work, so I don't see how I can redirect to a ntp.conf at another place.
- I run the latest Asus-Wrt merlin as of today.
- I would prefer not to run entware/optware unless really needed.

It's kinda off -topic, as this thread is specifically dedicated to the original ntpd binary and the instructions to get it up and running, graphs included, as provided by @kvic at http:/github.com/kvic-z/goodies-asuswrt/wiki/Install-NTP-Daemon-for-Asuswrt-Merlin. If someone feels the need to move this to a separate topic, feel free to do so.

Basically, without entware-ng installed, you're limited to a crippled version of ntp, more specific the minimal version supplied with busybox.

The busybox version of ntp can be used both as client and server. When you enter

Code:
/usr/sbin/ntpd --help

... you'll see the options available:

Code:
BusyBox v1.25.1 (2017-05-26 17:55:13 EDT) multi-call binary.

Usage: ntpd [-dnqNwtl -I IFACE] [-S PROG] [-p PEER]...

NTP client/server

        -d      Verbose
        -n      Do not daemonize
        -q      Quit after clock is set
        -N      Run at high priority
        -w      Do not set time (only query peers), implies -n
        -t      Trust network and server, no RFC-4330 cross-checks
        -S PROG Run PROG after stepping time, stratum change, and every 11 mins
        -p PEER Obtain time from PEER (may be repeated)
                If -p is not given, 'server HOST' lines
                from /etc/ntp.conf are used
        -l      Also run as server on port 123
        -I IFACE Bind server to IFACE, implies -l

I'm not sure whether it will work, but you could try creating ntp.conf in /jffs/tmp/etc/. That's where the symlink /etc leads to. Theoretically, if no options are specified, it should look there for it's config file, but I haven't tried this myself, I'm more than satisfied with the setup @kvic has provided. You can use the example above as a starting point, more detailed info can be found here: http://doc.ntp.org/4.1.0/confopt.htm

If that doesn't work, I think running it from /jffs/scripts/services-start at boot (as a daemon) with the -p option (which can be used multiple times in a single command line, you should not run ntpd multipe times) to specify each ntp-server you want to query, would be your best bet. If you google for 'busybox ntp -p' you'll find several examples, but keep in mind, your options are limited. I'd probably fabricate something that periodically checks whether it's still up and running and if not, it should be restarted to get back in sync.

Out of curiousity: any specific reason why you would rather not install entware-ng? The installation is a breeze and it will open a world of possibilities... All you need is an USB-drive and follow the instructions here: https://github.com/RMerl/asuswrt-merlin/wiki/Entware, that's all.

As for @kvic 's (extended) setup: if you don't want stats and graphs, the package provided includes the full non-crippled ntpd binary, with some adjustments (mostly skipping a lot of stuff in instructions, along with some modifications), you'll be able to run ntpd as it was intended, IMHO. Just make sure you download the package for the correct architecture (ARM/MIPS) and open a new topic and reach out for help to get it up and running.
 
Just as an FYI....I offer the option of turning on the busybox sntp server in my fork.....works great for my needs serving my permanently connected pc's.
 
I wonder if the daemon stopping was due to bad server information as I have now updated to IP only and UK only and it is still up and the jitter is very low, before that is looked more like a heartbeat on an ECG machine!
 
/jffs/bin/ntpd
/jffs/bin/ntpq
/jffs/bin/ntpstats.sh
/jffs/etc/ntp.conf
/jffs/configs/fstab
/opt/etc/init.d/S77ntpd-custom
/opt/var/spool/ntp/Tools_NtpdStats.asp
/opt/var/spool/ntp/stats.rrd
????
 
Hello, can you make a video tutorial for installation? Thank you
 
/jffs/bin/ntpd
/jffs/bin/ntpq
/jffs/bin/ntpstats.sh
/jffs/etc/ntp.conf
/jffs/configs/fstab
/opt/etc/init.d/S77ntpd-custom
/opt/var/spool/ntp/Tools_NtpdStats.asp
/opt/var/spool/ntp/stats.rrd
????
You need to read the install instructions more carefully, then you'd understand what that series of paths/files mean.
 
My English is poor, I use Google to translate into Chinese, but the meaning is not very clear
It says the tar.gz file you downloaded in the previous step contains these files (your list of files you posted).
If you already have any of these files in these locations, make a backup of it.

That's it, just a warning what files are written from the tarbal file.
 
It says the tar.gz file you downloaded in the previous step contains these files (your list of files you posted).
If you already have any of these files in these locations, make a backup of it.

That's it, just a warning what files are written from the tarbal file.
20170622182316149812699678633.jpg

What about this dysfunctional job?
 
20170622182316149812699678633.jpg

What about this dysfunctional job?
Did you reboot the router, and the results need some time to generate as it runs every five minutes.
I just made a complete installer script for all that and it appers to work.
Not ready for release though.
 
Just for those who have problems with WORKING update. There are several ways to fix opkg problems like
1) --force-reinstall
2) remove --autoremove + install
3) `opkg list-installed|grep -v "libc "|sed 's/ - .*$//'|grep lib|grep -v libpthread|grep -v libgcc|xargs -n 5 opkg --force-reinstall install`
 
My GPS dongles here, I would like to get it working with the daemon so I can see it's working and I do like everything syncing from the router, I looked as the guide in post #1 but it is outdated as the required files are no longer in the link.
Is it still possible?
 
Adding this to my home network will get bumped to a much higher priority if anyone can give any evidence or experience in having more success in winning block rewards when mining cryptocurrencies.
 
My GPS dongles here, ... Is it still possible?
First thing you do is download and install the u-blox u-center software, https://www.u-blox.com/sites/default/files/u-centersetup_v8.26.zip

Next, configure your u-blox GPS receiver to report only $GPZDA and disable all other NMEA sentences. AND, remember to save this settings to the GPS flash memory!

Finally, configure a NMEA driver in ntp.conf. Read this, http://doc.ntp.org/4.2.8/drivers/driver20.html

Example:

/jffs/scripts/services-start
Code:
#!/bin/sh
/sbin/modprobe cdc-acm
[ -e /dev/gps0 ] || /bin/ln -s /dev/ttyACM0 /dev/gps0

/opt/etc/ntp.conf
Code:
driftfile /opt/var/lib/ntp/ntp.drift
interface listen lo
interface listen br0
restrict localhost

# Generic NMEA GPS Receiver
#  mode is 9600 baud + process only $GPZDA or $GPZDG
#  /dev/gps0 for NMEA
#  http://doc.ntp.org/4.2.8/drivers/driver20.html
server 127.127.20.0 mode 24 minpoll 4 prefer
fudge 127.127.20.0 flag1 0 # Disable PPS signal processing
fudge 127.127.20.0 flag4 1 # Obscures location in timecode
 
Last edited:
First thing you do is download and install the u-blox u-center software, https://www.u-blox.com/sites/default/files/u-centersetup_v8.26.zip

Next, configure your u-blox GPS receiver to report only $GPZDA and disable all other NEMA sentences. AND, remember to save this settings to the GPS flash memory!

Finally, configure a NEMA driver in ntp.conf. Read this, http://doc.ntp.org/4.2.8/drivers/driver20.html

Example:

/jffs/scripts/services-start
Code:
#!/bin/sh
/sbin/modprobe cdc-acm
[ -e /dev/gps0 ] || /bin/ln -s /dev/ttyACM0 /dev/gps0

/opt/etc/ntp.conf
Code:
driftfile /opt/var/lib/ntp/ntp.drift
interface listen lo
interface listen br0
restrict localhost

# Generic NMEA GPS Receiver
#  mode is 9600 baud + process only $GPZDA or $GPZDG
#  /dev/gps0 for NEMA
#  http://doc.ntp.org/4.2.8/drivers/driver20.html
server 127.127.20.0 mode 24 minpoll 4 prefer
fudge 127.127.20.0 flag1 0 # Disable PPS signal processing
fudge 127.127.20.0 flag4 1 # Obscures location in timecode

configure your u-blox GPS receiver to report only $GPZDA


Can't figure out the above, it's a bit beyond me in the u-center software :)

In fact this is all over my head, balls to it :(
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top