0

I have two machines,

  1. host A with IP 192.168.0.1
  2. host B with IP 192.168.0.2

They connected to the same network and I would like to set the date and time of machine B to match those of machine A. While I can set up the machines with an internet connection initially, they will not have access to it once deployed and they will be rebooted every day.

Current Approach using Chrony Reference.

This configuration is not correct, based on some test results, the synchronization succeeds when the NTP server has an internet connection and fails otherwise.

Do you have any advice or suggestions for configuring them effectively?

Machine A - Configured as NTP server

sudo apt update && sudo apt upgrade
sudo apt install chrony
sudo vim /etc/chrony/chrony.conf

Used this configuration to set up the NTP server

confdir /etc/chrony/conf.d
pool ntp.ubuntu.com        iburst maxsources 4
pool 0.ubuntu.pool.ntp.org iburst maxsources 1
pool 1.ubuntu.pool.ntp.org iburst maxsources 1
pool 2.ubuntu.pool.ntp.org iburst maxsources 2
allow 192.168.0.0/24
sourcedir /run/chrony-dhcp
sourcedir /etc/chrony/sources.d
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
ntsdumpdir /var/lib/chrony
logdir /var/log/chrony
maxupdateskew 100.0
rtcsync
makestep 1 3
leapsectz right/UTC

Restarted the chrony service, checked that was running and enabled it to start on boot

sudo systemctl restart chrony
sudo systemctl status chrony
CTRL+C
sudo systemctl enable chrony

Machine B - Configured as Chrony Client

Synced the date and time with a pool of servers and set the 192.168.0.1

sudo apt update && sudo apt upgrade
sudo apt install chrony
sudo vim /etc/chrony/chrony.conf

Used the following configuration file

pool 192.168.0.1 iburst prefer
keyfile /etc/chrony/chrony.keys
driftfile /var/lib/chrony/chrony.drift
logdir /var/log/chrony
log measurements statistics tracking
maxupdateskew 100.0
rtcsync
makestep 1.0 3

Restarted, checked the service and enabled it at startup

sudo systemctl restart chrony
sudo systemctl status chrony
CTRL+C
sudo systemctl enable chrony

Update If I manually synchronize the time, I get the following error No suitable source for synchronisation.

sudo systemctl stop chrony 
sudo chronyd -d 'server 192.168.0.1 iburst'
2023-03-15T15:54:55Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 -DEBUG)
2023-03-15T15:54:55Z Initial frequency -36.773 ppm
2023-03-15T15:55:03Z No suitable source for synchronisation
2023-03-15T15:55:03Z chronyd exiting

Update 2

If I connect the NTP server to internet, then the synchronization succeeds.

2
  • Best advice? Get a cheap sbc and a cheap gps with PPS, and use that as a time server.
    – Bib
    Apr 27 at 12:28
  • Thanks Bib for your input. Actually one of the two host has a dgnss setup. I am parsing and getting the number of milliseconds from 1970. Ex: 1682600940 Now I just need to share this info with other hosts on the local network using a time server, which is where the question comes from.
    – UserK
    Apr 27 at 13:13

1 Answer 1

1

You need the directive local in the server config file for it to synchronize on its own when there is no internet. Typically, you might use local stratum 8 to say it is less good than a remote ntp server that might be stratum 2 or 3. This stops the local clock being preferred over the internet clock source. If the server has a hardware time source like a gps then look at the refclock directive to see if it can be configured in too.

3
  • Thanks @meuh for your answer. This directive allowed the other hosts on the network to sync their time with the NTP server
    – UserK
    Apr 27 at 16:02
  • I have noticed that if the time on the NTP server changes, the clients do not update their time straight away. Is there a way to increase the update frequency to make the synchronization quicker?
    – UserK
    Apr 27 at 16:12
  • 1
    Generally, we don't want the time to change suddenly, except at boot, so we expect the server not to say it is synched until it has a reliable source. If you have some gps device setting the time and causing the big step, then you should probably not start chronyd on the server until the gps has updated the system time. You already have a makestep entry on the client. You could change it to makestep 1 -1 to let the client do step changes later on.
    – meuh
    Apr 27 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .