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

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

# Configure time synchronization with an external NTP server on the server

In [OS images for installation on dedicated servers](/dedicated/manage/os-images.mdx) provided by Selectel, all necessary settings for [NTP](/infrastructure/ntp/about-ntp.mdx) are already configured. You need to configure NTP in the server OS if you [install the OS manually from your own image](/dedicated/manage/install-os-from-image.mdx).

<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](/dedicated/manage/connect-to-server.mdx#connect-via-ssh) or via [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Check which utility is used on the server:

       ```sh
       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`:

       3.1. Disable and remove the `systemd-timesyncd` and `ntpd` utilities:

       ```sh
       systemctl disable <name>
       sudo apt remove <name>
       ```

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

       3.2. Install `Chrony`:

       ```bash
       sudo apt-get install chronyd
       ```

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

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

        1. Start `Chrony`:

           ```sh
           systemctl start chronyd
           ```

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

           ```sh
           vi /etc/chrony/chrony.conf
           ```

        3. Add or replace 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.

           ```sh
           server <domain> iburst
           ```

           Specify `<domain>` — the domain name or the address of the pool or server.

           If you need to specify multiple servers, provide each on a new line, for example:

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

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

           ```sh
           :wq
           ```

        5. Restart the `Chrony` utility:

           ```sh
           sudo systemctl restart chronyd
           ```

        6. Check the list of NTP servers used:

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

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

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

           ```sh
           vi /etc/ntp.conf
           ```

        2. Add or replace 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.

           ```sh
           server <domain> iburst
           ```

           Specify `<domain>` — the domain name or the address of the pool or server.

           If you need to specify multiple servers, provide each on a new line, for example:

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

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

           ```sh
           :wq
           ```

        4. Restart the `ntpd` utility:

           ```sh
           sudo systemctl restart ntpd
           ```

        5. Check the list of NTP servers used:

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

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

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

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

        2. In the `NTP` parameter, add or replace 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.

           ```sh
           NTP=<domain>
           ```

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

           If you need to specify multiple NTP servers, enter them separated by a space, for example:

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

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

           ```sh
           :wq
           ```

        4. Restart the `systemd-timesyncd` utility:

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

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

           ```sh
           timedatectl status
           ```

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

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

    1. [Connect to the server via RDP](/dedicated/manage/connect-to-server.mdx#connect-via-rdp) or via [KVM console](/dedicated/manage/connect-to-server.mdx#connect-via-kvm-console).

    2. Open cmd.

    3. Stop the Windows Time service:

       ```sh
       net stop w32time
       ```

    4. Specify 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.

       ```sh
       w32tm /config /syncfromflags:manual /manualpeerlist:"<domain>" /update
       ```

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

       If you need to specify multiple NTP servers, enter them separated by a space, for example:

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

    5. Start the Windows Time service:

       ```sh
       net start w32time
       ```

    6. Check the list of NTP servers used:

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

<Formbricks />
