Ntp server/chrony

d_G

Member
May 17, 2024
30
1
8
Hi,
on proxmox in a lxc with some containers,
I would add a ntp server for them:
so apt install chrony
Code:
The following packages will be REMOVED:
  systemd-timesyncd

added allow IP/24 to the chrony.conf



but testing it specifying the IP of the lxc and 123 as port it NOT works.
Any idea/suggestion ?

installing ntp:
after apt install ntp
but where is located ntp.conf ?

Thank you!
 
Last edited:
Forget about ntp and stick with chrony

Firewall? If you do ' netstat -plant ' in the container, does it list port 123 as Listening? If not you may have to enable --now the daemon

Do a search for ' install chrony time server on $YOURDISTRO ' and follow a HOWTO
 
Did you do any troubleshooting at all before posting? What is the output of "chronyc sources" for example?

There is a fundamental problem here. Chrony (and NTPd as well) won't serve time if it isn't synced, or rather it will tell clients that it isn't synchronized and they will refuse to use it. But in a container it can't set the clock and therefore can't be synced. The output of "chronyc sources" would have told you that.

You need to either configure chrony on the host as a server (it is probably already installed) or else read the man page to learn about the "local" directive to force chrony to serve unsynchronized time from the container.
 
  • Like
Reactions: Kingneutron
Last edited:
Forget about ntp and stick with chrony

Firewall? If you do ' netstat -plant ' in the container, does it list port 123 as Listening? If not you may have to enable --now the daemon

Do a search for ' install chrony time server on $YOURDISTRO ' and follow a HOWTO
Thank you for your reply !

I tryed to lok for the port 123.. with netstat (but
# netstat -plant
-bash: netstat: command not found
exists instead ss but no 123 port is shown.
Code:
ss -lnup | grep 123
UNCONN 0      0            0.0.0.0:123       0.0.0.0:*    users:(("chronyd",pid=2523347,fd=7))

Does suggest you something ?
 
Ok, my bad:
ALL the following lines are mandatory at the end of the conf file!
local stratum 8
manual
allow IP/24 # change with 192.168.1.0 for example.

So now it works! As I hoped: ntp server avalaible for the lan (from the lxc container).

Of course check all clients with : chronyc -N clients -k
 
Last edited:
  • Like
Reactions: UdoB
Hello, recommendations for running chrony in lxc (correct me if i'm wrong):

1) Setting up chronyc on the pve host correctly ( It is already installed and running for default)

2) Adjust daemon execution to tell that should not adjust the local clock:
nano /etc/default/chrony
DAEMON_OPTS="-x -F 1"

3) systemctl restart chrony

-x
This option disables the control of the system clock. chronyd will not try to make any adjustments of the clock.
 
1) Setting up chronyc on the pve host correctly ( It is already installed and running for default)
This!

(Usually) it makes absolutely no sense to have a different clock in a container (or a VM).

You may have different Timezones, but the "hardware"-time is usually the very same for all guests on a single host - and for all nodes of a cluster.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!