# ntpd kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized



## bagas (May 23, 2021)

Hello.
My system FreeBSD 11.4-RELEASE-p9 amd64.
I see an incomprehensible error in the log.
What is this error and how can I fix it?
The system's time is synchronized.


> tail /var/log/ntp.log
> 23 May 16:44:06 ntpd[30355]: 80.249.145.122 local addr 1.2.2.8 -> <null>
> 23 May 16:44:06 ntpd[30355]: 79.120.30.43 local addr 1.2.2.8 -> <null>
> 23 May 16:44:07 ntpd[30464]: Listen normally on 0 igb0 1.2.2.8:123
> ...





> cat /etc/ntp.conf
> interface ignore wildcard
> interface listen 1.2.2.8
> disable monitor
> ...





> ntptime
> ntp_gettime() returns code 0 (OK)
> time e454dcab.e06b15f8  Sun, May 23 2021 16:52:43.876, (.876634814),
> maximum error 131705 us, estimated error 291 us, TAI offset 0
> ...





> ntpq -p
> remote           refid      st t when poll reach   delay   offset  jitter
> ==============================================================================
> +91.206.16.3 (tm 40.52.66.2       2 u   39   64   37   78.166   -0.404   3.017
> ...


----------



## mer (May 23, 2021)

When NTP starts, the clock by definition is unsynchronized.    It can take a little while for it to synch with a source.  
Based on what you've included for ntp.log, it looks like ntpd was started around 23 May 16:44:06 or maybe a little before that and the error logs are 23 May 16:44:07.  That's only a second or two, so the clock has not synchronized yet.  It may take minutes to synch.

If ntpq -p is showing a peer and sync, check ntp.log to see if the error logs have stopped (they should have).
I generally discount "unsynchronized" logs in the first 5 minutes of starting ntp as long as it eventually synchs.

My opinion, others may have a different one.


----------



## bagas (May 23, 2021)

cat /etc/ntp.conf
interface listen 1.2.2.8
The service weighs on an external ip address (1.2.2.8), how to remove local ones?
How to remove support?


> 23 May 16:44:07 ntpd[30464]: Listen normally on 1 lo0 127.0.0.1:123
> 23 May 16:44:07 ntpd[30464]: Listen normally on 2 lo1 127.0.1.1:123
> 23 May 16:44:07 ntpd[30464]: Listen normally on 3 lo1 127.0.2.1:123
> 23 May 16:44:07 ntpd[30464]: Listen normally on 4 lo1 127.0.3.1:123


----------



## Jose (May 23, 2021)

Are you trying to set up a public NTP server? Please post your ntp.conf.


----------



## mer (May 23, 2021)

Jose said:


> Are you trying to set up a public NTP server? Please post your ntp.conf.


His second code block has ntp.conf. 

If all he needs is a client, I like using openntpd from ports/packages.  A bit simpler configuration and pretty clear when it's doing client only.

By default base ntpd listens on all interfaces on the machine.  "man ntp.conf" should help I think you want to look at "interface ignore" directives (which you have).
Maybe comment out the "restrict localhost" will disable the listen ports on lo


----------



## bagas (May 23, 2021)

Jose said:


> Are you trying to set up a public NTP server? Please post your ntp.conf.


I only need an ntp client.
Set the correct time on the server.


cat /etc/ntp.conf
interface ignore wildcard
interface listen 1.2.2.8
disable monitor
server 0.ru.pool.ntp.org iburst maxpoll 9
server 1.ru.pool.ntp.org iburst maxpoll 9
server 2.ru.pool.ntp.org iburst maxpoll 9
logfile /var/log/ntp.log
restrict default ignore
restrict 127.0.0.1
restrict 0.ru.pool.ntp.org
restrict 1.ru.pool.ntp.org
restrict 2.ru.pool.ntp.org


----------



## bagas (May 23, 2021)

mer said:


> By default base ntpd listens on all interfaces on the machine. "man ntp.conf" should help I think you want to look at "interface ignore" directives (which you have).


Did not find such a parameter interface ignore.


----------



## mer (May 23, 2021)

bagas said:


> Did not find such a parameter interface ignore.


Your config has "interface ignore wildcard"  that should prevent starting a listening socket on all interfaces.  Then your interface listen 1.2.2.8 should listen on 1.2.2.8.  I was wondering if the "restrict 127.0.0.1" is somehow creating the listening sockets on localhost.

If you only need an ntp client so you sync with other servers, take a look at openntpd port.  It's configuration is simpler.

Here's what I did:
as root
service ntpd stop
pkg install openntpd
edit the /usr/local/etc/ntp.conf (this is the config file for openntpd) to point to different pool if you want
service openntpd start
To check for sync, this may take a minute or two:
ntpctl -s status

Then make sure you do as root:
sysrc ntpd_enable="NO"
sysrc openntpd_enable="YES"


----------



## Alain De Vos (May 23, 2021)

If the time difference it too big the clocks never synchronise.
You can force it by running ntpdate at start.
in /etc/rc.local

```
ntpdate 0.be.pool.ntp.org
```


----------

