
Maintaining accurate system time is absolutely critical for reliable logging, secure transactions, and the proper functioning of network services. Setting up a local Network Time Protocol (NTP) server allows devices on your network to synchronize their clocks reliably with a central source, ensuring consistency across your infrastructure. On Debian 10 Buster, this process is straightforward using the ntpd daemon.
The first step is to ensure you have the necessary package installed. Open your terminal and run the following command to install the ntp software:
sudo apt update
sudo apt install ntp
Once the installation is complete, the ntpd service will start automatically. However, you will likely want to configure it to use specific upstream time servers. The main configuration file for ntpd is located at /etc/ntp.conf. You can edit this file using your preferred text editor, such as nano or vim:
sudo nano /etc/ntp.conf
Inside this file, you will find existing configurations, including default upstream servers provided by Debian. You should typically comment out or remove the default pool or server lines and add your preferred time sources. These can be public NTP servers, servers from your organization, or even hardware clock sources. A common practice is to use pool directives, which automatically provide a dynamic set of servers. For example:
pool 0.debian.pool.ntp.org iburst
pool 1.debian.pool.ntp.org iburst
pool 2.debian.pool.ntp.org iburst
pool 3.debian.pool.ntp.org iburst
The iburst option helps synchronize the clock faster upon startup.
After making changes to /etc/ntp.conf, you need to restart the ntpd service for the changes to take effect:
sudo systemctl restart ntp
It’s also recommended to enable the service to start automatically on boot:
sudo systemctl enable ntp
To verify that your NTP server is running and synchronizing correctly, you can check its status:
sudo systemctl status ntp
Look for the active (running) state. To see which upstream servers your ntpd is connected to and their synchronization status, use the ntpq command with the -p option:
ntpq -p
This command shows the synchronization peers. A server marked with an asterisk (*) is the one currently being used for synchronization.
Finally, if you have a firewall enabled on your server, you must allow incoming connections on UDP port 123 from the clients that will use this server for time synchronization. How you do this depends on your firewall software (e.g., ufw or iptables).
By following these steps, you will have a robust and reliable NTP server running on your Debian 10 system, providing accurate time to all devices on your network and enhancing the stability and security of your infrastructure.
Source: https://kifarunix.com/setup-ntp-server-using-ntpd-on-debian-10-buster/