• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to configure NTP server and client in CentOS / RHEL 7

by admin

The example discussed below is for a basic NTP server and client. NTP stands for Network Transport Protocol and it is used to keep the time on the servers synced with each other using a common reliable source to get the time.

NTP Server Configuration

1. Install the required ntp package on the server.

# yum install ntp

2. Ensure the following entries are in ntp configuration file /etc/ntp.conf.

# cat /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
restrict 10.10.10.0 mask 255.255.255.0 nomodify notrap
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

As per the configuration file the NTP servers servers only to the NTP clients in the subnet 10.10.10.0/24. You can get the public NTP servers specific to your region from pool.ntp.org.

In the /etc/ntp.conf file you will have to mention the NTP server(s) in your environment.

3. Now you can start the ntpd service.
For RHEL 5,6:

# service ntpd start

For RHEL 7:

# systemctl start ntpd.service

NTP Client Configuration

1. For client NTP configuration, add the below configuration in the /etc/ntp.conf file.

# cat /etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server ntp.server.com
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

Here, ntp.server.com is the server you configured as NTP server in the example shown at the start of the post. There can be multiple NTP servers for redundancy purpose. Add a new line for each of the NTP servers in the /etc/ntp.conf file.

2. Start the ntpd service on the ntp client server.
For RHEL 5,6:

# service ntpd start

For RHEL 7:

# systemctl start ntpd.service

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Order of environment calls for different OS shells in Linux
  2. Understanding Samba utilities – nmblookup, smbstatus, smbtar, testparm, wbinfo, smbget
  3. How to configure resource groups for MySQL Server running on Linux
  4. groupmems Command Examples in Linux
  5. CentOS / RHEL : How to create new LVM based swap partition
  6. How to allow all traffic from a server using firewalld in CentOS/RHEL
  7. lsattr Command Examples in Linux
  8. CentOS / RHEL : How to restrict SSH login by time of day
  9. How to Migrate CentOS/RHEL 6 iptables Rules to CentOS/RHEL 7 firewalld
  10. CentOS / RHEL 6 : How to boot into rescue mode

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright