Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Configure an NTP Server on Linux

Network Time Protocol (NTP) is crucial for synchronizing the clocks of computers over a network. Accurate timekeeping is essential for various applications, including logging events, security protocols, and data consistency. This article will guide you through configuring an NTP server on a Linux system, ensuring your network devices maintain accurate time.

Examples:

  1. Installing NTP Package

    Before configuring the NTP server, you need to install the NTP package. Open a terminal and execute the following command:

    sudo apt-get update
    sudo apt-get install ntp

    For Red Hat-based distributions, use:

    sudo yum install ntp
  2. Configuring NTP Server

    After installing the NTP package, you need to configure the NTP server. The main configuration file is located at /etc/ntp.conf. Open this file with your preferred text editor:

    sudo nano /etc/ntp.conf

    Add or modify the following lines to specify the NTP servers you want to synchronize with:

    server 0.pool.ntp.org iburst
    server 1.pool.ntp.org iburst
    server 2.pool.ntp.org iburst
    server 3.pool.ntp.org iburst

    The iburst option speeds up the initial synchronization.

  3. Allowing NTP Service Through Firewall

    If you have a firewall enabled, you need to allow NTP traffic. For example, using ufw:

    sudo ufw allow 123/udp

    For firewalld:

    sudo firewall-cmd --permanent --add-service=ntp
    sudo firewall-cmd --reload
  4. Starting and Enabling NTP Service

    Start the NTP service and enable it to start on boot:

    sudo systemctl start ntp
    sudo systemctl enable ntp

    For Red Hat-based distributions:

    sudo systemctl start ntpd
    sudo systemctl enable ntpd
  5. Verifying NTP Synchronization

    To verify that your NTP server is synchronizing correctly, use the following command:

    ntpq -p

    This command will display a list of NTP servers and their synchronization status.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.