---
title: "Configure time synchronization with an external NTP server"
sidebar_label: "Configure time synchronization with an external NTP server"
sidebar_position: 12
description: "How to configure time synchronization with an external NTP server in Linux (Chrony, ntpd, systemd-timesyncd) and Windows"
toc_max_heading_level: 2
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Configure time synchronization with an external NTP server

Configuring time synchronization via the [NTP](/infrastructure/ntp/about-ntp.mdx) protocol is required when you [prepare your own ISO image for use with the cloud platform](/cloud-servers/images/create-custom-image.mdx).

In [pre-built images](/cloud-servers/images/about-images.mdx#default-images) of cloud servers, all necessary settings for NTP synchronization are already configured.

<Tabs queryString="configure-ntp-sync">
  <TabItem value="linux" default>
    <TabItemLabel>
      Linux
    </TabItemLabel>

    1. [Check the installed utility](#check-installed-service).

    2. [Configure the utility](#configure-service).

    ### 1. Check the installed utility \{#check-installed-service}

    1. [Connect to the server via SSH](/cloud-servers/manage/connect-to-server.mdx#connect-via-ssh).

    2. Check which utility is used on the server:

       ```bash
       systemctl status ntp
       systemctl status chronyd
       systemctl status systemd-timesyncd
       ```

       We recommend using `Chrony`, but you can configure the utility that is already installed on the server.

    3. If you want to switch to `Chrony`, disable and remove the `systemd-timesyncd` and `ntpd` utilities and install `Chrony`:

       ```bash
       systemctl disable <name>
       sudo apt remove <name>
       sudo apt-get install chronyd
       ```

       Specify `<name>` — the name of the utility to remove (`ntp` or `systemd-timesyncd`).

    ### 2. Configure the utility \{#configure-service}

    <Tabs queryString="configure-service">
      <TabItem value="chrony" default>
        <TabItemLabel>
          Chrony
        </TabItemLabel>

        1. Start `Chrony`:

           ```bash
           systemctl start chronyd
           ```

        2. Open the `Chrony` configuration file in the `vi`:

           ```bash
           vi /etc/chrony/chrony.conf
           ```

        3. Add or replace the NTP servers in the file. We recommend replacing the servers in the file with [Selectel NTP servers](/infrastructure/ntp/ntp-servers-list.mdx), but you can specify any available NTP servers.

           ```bash
           server <ntp_server> iburst
           ```

           Specify `<ntp_server>` — the domain name or IP address of the NTP server.

           If you need to specify multiple servers, list each on a separate line, for example:

           ```bash
           server 0.spb.ntp.selectel.ru iburst
           server 1.spb.ntp.selectel.ru iburst
           ```

        4. Exit the `vi` text editor with your changes saved:

           ```bash
           :wq
           ```

        5. Restart the `Chrony`:

           ```bash
           sudo systemctl restart chronyd
           ```

        6. Check the list of NTP servers in use:

           ```bash
           chronyc -N sources
           ```
      </TabItem>

      <TabItem value="ntpd" default>
        <TabItemLabel>
          ntpd
        </TabItemLabel>

        1. Open the `ntpd` configuration file in the `vi`:

           ```bash
           vi /etc/ntp.conf
           ```

        2. Add or replace the NTP servers in the file. We recommend replacing the servers in the file with [Selectel NTP servers](/infrastructure/ntp/ntp-servers-list.mdx), but you can specify any available NTP servers.

           ```bash
           server <ntp_server> iburst
           ```

           Specify `<ntp_server>` — the domain name or IP address of the NTP server.<br />

           If you need to specify multiple servers, list each on a separate line, for example:

           ```bash
           server 0.spb.ntp.selectel.ru iburst
           server 1.spb.ntp.selectel.ru iburst
           ```

        3. Exit the `vi` text editor with your changes saved:

           ```bash
           :wq
           ```

        4. Restart the `ntpd`:

           ```bash
           sudo systemctl restart ntpd
           ```

        5. Check the list of NTP servers in use:

           ```bash
           ntpq -p
           ```
      </TabItem>

      <TabItem value="systemd-timesyncd" default>
        <TabItemLabel>
          systemd-timesyncd
        </TabItemLabel>

        1. Open the `ntpd` configuration file in the `vi`:

           ```bash
           vi /etc/systemd/timesyncd.conf
           ```

        2. In the `NTP` parameter, add or replace the NTP servers. We recommend replacing them with [Selectel NTP servers](/infrastructure/ntp/ntp-servers-list.mdx), but you can specify any available NTP servers.

           ```bash
           NTP=<ntp_server>
           ```

           Specify `<ntp_server>` — the domain name or IP address of the NTP server.<br />

           If you need to specify multiple NTP servers, separate them with spaces, for example:

           ```bash
           NTP=0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru
           ```

        3. Exit the `vi` text editor with your changes saved:

           ```bash
           :wq
           ```

        4. Restart the `systemd-timesyncd`:

           ```bash
           sudo systemctl restart systemd-timesyncd.service
           ```

        5. Verify that the utility is running and the time is being synchronized:

           ```bash
           timedatectl status
           ```

           In the response, the `NTP service` field should show `active`, and the `System clock synchronized` field should show `yes`.
      </TabItem>
    </Tabs>
  </TabItem>

  <TabItem value="windows">
    <TabItemLabel>
      Windows
    </TabItemLabel>

    1. [Connect to the server via RDP](/cloud-servers/manage/connect-to-server.mdx#connect-via-rdp).

    2. Open the CLI.

    3. Stop the Windows Time service:

       ```bash
       net stop w32time
       ```

    4. Specify the NTP servers. We recommend replacing the servers with [Selectel NTP servers](/infrastructure/ntp/ntp-servers-list.mdx), but you can specify any available NTP servers.

       ```bash
       w32tm /config /syncfromflags:manual /manualpeerlist:"<ntp_server>" /update
       ```

       Specify `<ntp_server>` — the domain name or IP address of the NTP server.<br />

       If you need to specify multiple NTP servers, separate them with spaces, for example:

       ```bash
       w32tm /config /syncfromflags:manual /manualpeerlist:"0.spb.ntp.selectel.ru 1.spb.ntp.selectel.ru" /update
       ```

    5. Start the Windows Time service:

       ```bash
       net start w32time
       ```

    6. Check the list of NTP servers in use:

       ```bash
       w32tm /query /peers
       ```
  </TabItem>
</Tabs>

<Formbricks />
