This article describes the steps how to set up a NTP Server on your Local Network on RedHat, CentOS & Oracle Linux.
Table of contents:
– Network Time Protocol :
– Set UP NTP Server configuration:
– Set UP NTP Client configuration:
1. Network Time Protocol:
Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. NTP is intended to synchronize all participating computers to within a few milliseconds of Coordinated Universal Time (UTC), for more info.
Setting up NTP is by installing the ntp package which contains utilities and daemons.
The ntp package includes ntpd (a daemon which continuously adjusts system time) and ntpdate (a program for retrieving the date and time from remote machines via a network).
To install the NTP package (on both NTP Client & Server side):
# yum install ntp # chkconfig ntpd on
Note: Installing packages with YUM using DVD image.
Verify the NTPD Sysconfig configuration:
# cat /etc/sysconfig/ntpd OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"
2. Set UP Local NTP Server:
Step 1: Add your Local Network.
My local network is 172.16.1.0/24, then adjust the network within the configuration file of the ntp server.
# vi /etc/ntp.conf ........ restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap ......
Step2: Setting the Pool.ntp.org
Note: The NTP server is also a NTP Client of the pool.ntp.org, which is a big virtual cluster of timeservers providing reliable easy to use NTP service for millions of clients.
# vi /etc/ntp.conf ........ # Use public servers from the pool.ntp.org project. server 0.rhel.pool.ntp.org server 1.rhel.pool.ntp.org server 2.rhel.pool.ntp.org ........
Step 3 :To Synchronize our NTP Server with the pool.ntp.org, we can use the tool ntpdate directly or while the Linux server start will automatically synchronize his date if there are an internet connection:
# ntpdate -u 0.rhel.pool.ntp.org 31 Aug 10:32:47 ntpdate[3391]: adjust time server 41.231.53.4 offset -0.000237 sec
Step 4: Update your Firewall:
Update your firewall, the port number of the NTP Server is 123 while using the UDP protocol.
# iptables -A INPUT -s 172.16.1.0/24 -m state --state NEW -p udp --dport 123 -j ACCEPT # iptables-save
2. Set UP NTP Client:
Step 1: Editing the file /etc/ntp.conf to add the NTP Server IP address.
# vi /etc/ntp.conf ........ # Use public servers from the pool.ntp.org project. server 172.16.1.123 ........
Step 2: To synchronize immediatelly, we can use the tool ntpdate:
# ntpdate -u 172.16.1.123 31 Aug 10:38:54 ntpdate[2778]: adjust time server 172.16.1.123 offset -0.001602 sec
Note: By enabling the service ntpd, then the Linux Server will update the date automatically while starting.
Conclusion:
This article describes the steps how to create a local NTP Server and to configure NTP clients.