[ntp:questions] Reference 'sntp' utility: how do you set the destination port number
stenn at ntp.org
Wed Jul 3 05:54:39 UTC 2019
A C writes:
> On 2019-06-29 19:09, stuartl at longlandclan.id.au wrote:
> > Hi all,
> > This will seem like a silly request, but how do you set the sntp client (di
> stributed with the 'ntp' package in Debian) port number?
> > The reason I need this is that I need to synchronise time with clients whos
> e only link to the outside world is a 1200-baud AX.25 packet radio network.
> Running TCP/IP over this is an impossibility at present.
> > The devices (partly due to an oversight on my part), do not have an RTC. W
> hen first booted, they think the time is 2016.
> > The boards have been manufactured, it's too late to suggest that as the sol
> ution. (The next revision *does* have a space for an RTC.) The devices have
> two serial ports, one connected to an RFID reader, the other to an AX.25 TNC
> . There is no room for a GPS, and no time to order one.
> > Hindsight is 20/20, so I'm looking for a quick software solution.
> > I have therefore written a program that can bind to an arbitrary UDP port,
> and can relay the NTP client requests and server responses over the AX.25 net
> work. It is written in Python 3 and implements all of the AX.25 logic along
> with the data collection function it is meant to perform.
> > Basically, UDP datagram (containing NTP payload) goes in, APRS-formatted AX
> .25 "un-numbered information frame" comes out. APRS UI frame comes in, UDP d
> atagram gets sent back to the (S)NTP client.
> > I do not need, nor want, this script to run as 'root'. So there goes bindi
> ng to port 123/udp. I am instead using 3123/udp. I'd like 'sntp' to talk to
> > 'chrony' can talk on an alternate port, but it takes many measurements to s
> ynchronise the time, which is not ideal, it often takes many minutes to synch
> ronise. I don't need millisecond precision, I just need stations to be withi
> n 60 seconds of each other ('ntp' can take over and fine tune it from there).
> I don't care that the date suddenly jumps from 2016 to 2019 -- I care more
> that the device "lives in 2016" for more than a few minutes.
> > I really just need a one-shot tool like 'ntpdate'. I understand that 'sntp
> ' is that tool. What is the command line option I use to make it talk to a N
> TP server that is on a different port to the standard?
> Clients don't bind to ports. sntp will connect outbound on UDP 123 as a
> normal user just fine (I just tested it myself on a Debian system).
> However, if you don't run as root you won't be able to set the system clock.
> $ sntp -d 10.0.0.1
> 2 Jul 07:48:55 sntp: Started sntp
> 2 Jul 07:48:55 sntp: kod_init_kod_db(): Cannot open KoD db file
> sntp sendpkt: Sending packet to 10.0.0.1... Packet sent.
> sntp recvpkt: packet received from 10.0.0.1 is not authentic.
> Authentication not enforced.
> sntp handle_pkt: Received 48 bytes from 10.0.0.1
> sntp offset_calculation: t21: -0.000545 t34: -0.011008
> delta: 0.010462 offset: -0.005776
> 2019-07-02 07:48:55.219316 (+0800) -0.005776 +/- 0.031540 secs
> 2 Jul 07:48:55 sntp: Can't open KOD db file /var/db/ntp-kod for
> You can also look at the fake-hwclock package which keeps a timestamped
> file updated and reads the timestamp at boot to get the clock close to
> current time. That will at least solve your 2016/2019 problem.
I think you are running an old sntp.
Sntp doesn't bind to port 123 by default.
More information about the questions