How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

Setup Timezone and NTP on CentOS 6

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
10
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Prerequisites
  3. Step 1: Set the timezone
  4. Step 2: Upgrade NTP
  5. Step 3: Configure ntp
  6. Step 4: Configure the firewall
  7. Want to contribute?


Introduction

For server administrators, it’s important to set and maintain the time on servers correctly. Wrongly configured time will cause chaos within the server environment, such as data inconsistency, data synchronization failures, and job scheduling problems.

To avoid these undesirable issues, first, you need to set a reasonable time zone on your server, giving your server a relatively precise local time. Second, for communication purposes, you can also use NTP (Network Time Protocol) to synchronize the time of your servers and remote NTP servers, keeping the time on your machines in perfect order.

In this article, I will show you how to set the time zone and how to synchronize the time using NTP on a CentOS 6 x64 server.

Prerequisites

I assume that you have deployed a CentOS 6 x64 Vultr server instance from scratch and have logged in as root.

Step 1: Set the timezone

Input the following command in your terminal:

date

As you see, the Vultr CentOS 6 x64 OS uses the UTC time by default. You can modify it to any time zone as you wish, but using the local timezone of the server’s physical location is a best practice.

If our server was running in China, then we would use the “Asia/Shanghai” time zone:

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

You can navigate to the directory /usr/share/zoneinfo to find the appropriate time zone. There is an excellent resource on Wikipedia for timezone listings.

Input date again, you will find that the local system time has changed to CST (China Standard Time) GMT+0800.

Next, we will write the system time info into the hardware clock.

vi /etc/sysconfig/clock

Modify the content of this file as below.

ZONE="Asia/Shanghai"
UTC=false
ARC=false

Save and quit.

:wq

Write the system time into the hardware clock.

hwclock --systohc --localtime

Input hwclock to see the result.

Step 2: Upgrade NTP

By default, the ntp daemon program has been installed and set up to run on the Vultr CentOS 6 x64 server instance. For security purposes, the first thing that we should do is to upgrade it to the latest version.

To see the ntpd version:

ntpd --version

At the time of writing, the default installed version is “4.2.6p5”.

Stop the ntpd service:

service ntpd stop

Download the latest version of the ntp program from its official website:

wget http://archive.ntp.org/ntp4/ntp-4.2/ntp-4.2.8p2.tar.gz

Unzip and go into the newly created directory:

tar -zxvf ntp-4.2.8p2.tar.gz
cd ntp-4.2.8p2

Install the necessary components for our installation:

yum -y install gcc libcap-devel

Because we are going to upgrade the existing ntpd program, we need to determine the owner and group info:

cat /etc/group
cat /etc/passwd

As you see, the ntp program belongs to the owner ntp (uid=38) and the group ntp (gid=38).

For security purposes, update the configuration of the ntp user account:

usermod -c "Network Time Protocol" -d /var/lib/ntp -u 38 -g ntp -s /bin/false ntp

Compile and install the ntp program:

./configure --prefix=/usr --bindir=/usr/sbin --sysconfdir=/etc --enable-linuxcaps --with-lineeditlibs=readline --docdir=/usr/share/doc/ntp-4.2.8p2 && make
make install && install -v -o ntp -g ntp -d /var/lib/ntp

Once the installation has completed, you can check the ntpd version again:

ntpd --version

As you see, the ntp program has been upgraded to the latest version “4.2.8p2”.

Step 3: Configure ntp

For better performance and security, we need to modify the default configuration:

vi /etc/ntp.conf

In the ntp.conf configuration file, you can find the ntp servers like:

server 1.time.constant.com
server 2.time.constant.com
server 3.time.constant.com

For faster synchronization speed, you can change these servers to the ones in the region or even in the country of your datacenter. For example, in United States, you can use:

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

More NTP pool time servers can be found on the NTP support website.

For security purposes, we should restrict permissions. While still in the ntp.conf configuration file, find the following two rows:

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

Modify them as below:

restrict default limited kod nomodify notrap nopeer noquery
restrict -6 default limited kod nomodify notrap nopeer noquery

Additionally, we need to add the following two rows:

pidfile   /var/run/ntpd.pid
leapfile  /etc/ntp.leapseconds

Save and quit:

:wq

Reboot the system:

reboot

Step 4: Configure the firewall

Add the following sentence to the iptable configuration file /etc/sysconfig/iptables:

-A  INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT

Restart the firewall.

service iptables restart

At this point, NTP is fully configured. The ntpd program will continually adjust the time of your server.

If needed, you can check the time synchronization status with the following command:

ntpstat

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

How to Install OpenLiteSpeed and PHP 7 on CentOS 7

How to Setup OpenZFS on CentOS 7

How to Install Directus 6.4 CMS on a CentOS 7 LAMP VPS

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Add HTTP2 Support to Nginx on Debian

3 years ago

Setup MySQL Master-Slave Replication on Debian/Ubuntu

3 years ago
How to Manage a Web Server and Install the IIS WWW Service Module

How to Manage a Web Server and Install the IIS WWW Service Module

4 years ago

Install MariaDB on CentOS 7

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.