Setting up NTP in CentOS 7

Prerequisites Step 1: Endure you are in the correct time zone

# timedatectl
      Local time: Wed 2018-09-12 13:48:31 +08
  Universal time: Wed 2018-09-12 05:48:31 UTC
        RTC time: Wed 2018-09-12 05:48:31
       Time zone: Asia/Singapore (+08, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

Prerequisites Step 2: List Time Zone

# timedatectl list-timezones

Prerequisites Step 3: Set Time Zone

# timedatectl set-timezone Asia/Singapore


Step 1: Yum Install

NTP can be installed from the CentOS repositories with yum

# yum install ntp

Step 2: Edit the Public Time Servers

Once you have installed ntp package, go to official NTP Public Pool Time Servers . For Singapore, you can use this specific pool zone, add the following to your ntp.conf file:

server iburst
server iburst
server iburst
server iburst

Step 3: Allow the clients from the network to sync with this server

Restrict which clients from which network is allowed to query and sync time

restrict netmask nomodify notrap

Step 4: Record all NTP server issues into one dedicated log file. Edit /etc/ntp.conf

logfile /var/log/ntp.log

Step 5: Add Firewall Rule and Start Services

# firewall-cmd --add-service=ntp --permanent
# firewall-cmd --reload
# systemctl start ntpd
# systemctl enable ntpd
# systemctl status ntpd

Step 6: Verify Time Sync

# ntpq -p
# date -R

Or query or synchronize against a selected pool of time servers

# ntpdate -q


  1. Setting Up “NTP (Network Time Protocol) Server” in RHEL/CentOS 7 (by

Set hostname using hostnamectl for CentOS 7

1. Listing hostname using “hostnamectl” or “hostnamectl status”

[root@localhost ~]# hostnamectl
Static hostname:
Icon name: computer-server
Chassis: server
Machine ID: aaaaaaaaaaaaa
Boot ID: ddddddddddd
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64

2.Setting static host-name using hostnamectl

# hostnamectl set-hostname "" --static

3. Delete static host-nameusing hostnamectl

# hostnamectl set-hostname "" --static