Configure time synchronization with an external NTP server
In ready images of cloud servers, all necessary settings for NTP are done. Customization is needed if you are preparing your ISO image to work with the cloud platform.
- Linux
- Windows
1. Check the installed utility
-
Connect to the server via SSH or via console in the control panel.
-
Check which utility is being used on the server:
systemctl status ntp
systemctl status chronyd
systemctl status systemd-timesyncdWe recommend using
Chrony
, but you can customize whichever utility is already installed on the server. -
If you want to switch to
Chrony
, disable and uninstall thesystemd-timesyncd
andntpd
utilities and installChrony
:systemctl disable <name>
sudo apt remove <name>
sudo apt-get install chronydSpecify
<name>
is the name of the utility to be removed (ntp
orsystemd-timesyncd
).
2. Customize the utility
- Chrony
- ntpd
- systemd-timesyncd
-
Start `Chrony':
systemctl start chronyd
-
Open the
Chrony
configuration file in thevi
text editor:vi /etc/chrony/chrony.conf
-
Add or replace the NTP servers in the file. We recommend replacing the servers in the file with Selectel NTP servers, but you can specify any.
server <domain> iburst
Specify
<domain>
— the domain name or address of the pool or server.If you need to specify multiple servers, specify each on a separate line, for example:
server 0.spb.ntp.selectel.ru iburst
server 1.spb.ntp.selectel.ru iburst -
Exit the
vi
text editor with the changes saved::wq
-
Restart the `Chrony' utility:
sudo systemctl restart chronyd
-
Check the list of NTP servers in use:
chronyc -N sources
-
Open the
ntpd
configuration file in a text editorvi
:vi /etc/ntp.conf
-
Add or replace the NTP servers in the file. We recommend replacing the servers in the file with Selectel NTP servers, but you can specify any.
server <domain> iburst
Specify
<domain>
— the domain name or address of the pool or server.If you need to specify multiple servers, specify each on a separate line, for example:
server 0.spb.ntp.selectel.ru iburst
server 1.spb.ntp.selectel.ru iburst -
Exit the
vi
text editor with the changes saved::wq
-
Restart the
ntpd
utility:sudo systemctl restart ntpd
-
Check the list of NTP servers in use:
ntpq -p
-
Open the
ntpd
configuration file in a text editorvi
:vi /etc/systemd/timesyncd.conf
-
In the
NTP
parameter, add or replace NTP servers. We recommend replacing the servers with Selectel NTP servers, but you can specify any.NTP=<domain>
Specify
<domain>
— the domain name or address of the NTP server.If you need to specify multiple NTP servers, enter them separated by a space, for example:
NTP=0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru
-
Exit the
vi
text editor with the changes saved::wq
-
Restart the
systemd-timesyncd
utility:sudo systemctl restart systemd-timesyncd.service
-
Check that the utility is running and the time is synchronized:
timedatectl status
The response should show
active
in theNTP service
field andyes
in theSystem clock synchronized
field.
-
Open cmd.
-
Stop the Windows time service:
net stop w32time
-
Specify the NTP servers. We recommend replacing the servers with Selectel NTP servers, but you can specify any.
w32tm /config /syncfromflags:manual /manualpeerlist:"<domain>" /update
Specify
<domain>
— the domain name or address of the NTP server.If you need to specify multiple NTP servers, enter them separated by a space, for example:
w32tm /config /syncfromflags:manual /manualpeerlist: "0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru" /update
-
Start the Windows Time Service:
net start w32time
-
Check the list of NTP servers in use:
w32tm /query /peers