CentOS Build NTP server

Source: Internet
Author: User

I. Description

NTP: Time synchronization server

NtpServer ip:192.168.0.128

Client ip:192.168.0.129

Ii. preparatory work

1. Viewing time

[[Email protected] ~]# Date//View system time

Friday, November 13, 2015 15:58:07 CST

[[email protected] ~]# Hwclock//View hardware time

November 13, 2015 Friday 15:59 10 sec -0.016335 seconds

Note : If the time and timezone is found to be incorrect (the correct time zone should be CST), take the following 2-3 steps.

2. Modify Time Zone

[Email protected] ~]# Vim/etc/sysconfig/clock

Zone= "Asia/shanghai"
Utc=true
Arc=false

3. Overwrite the system time file

[Email protected] ~]# cp-a/usr/share/zoneinfo/asia/shanghai/etc/localtime

[[Email protected] ~]# Date//See if Time is right again

Third, the construction of NTP services

1. Installation

[[email protected] ~]# Yum install-y NTP

2. Check whether the upper service is connected

Country-to-time server has 6, you can use the following 3

1.cn.pool.ntp.org

2.cn.pool.ntp.org

ch.pool.ntp.org

[[email protected] ~]# ntpdate-q 1.cn.pool.ntp.org//test the above 3 servers sequentially, the correct result is as follows

Server 202.118.1.130, stratum 2, offset 0.003763, delay 0.06880
Server 202.118.1.81, stratum 2, offset 0.004612, delay 0.06927
Server 202.112.29.82, stratum 2, offset 0.041528, delay 0.14401
Server 202.112.31.197, stratum 0, offset 0.000000, delay 0.00000
16:15:02 ntpdate[3300]: Adjust time server 202.118.1.130 offset 0.003763 sec

3. Proofreading Current time

[Email protected] ~]# ntpdate 1.cn.pool.ntp.org

16:18:35 ntpdate[3332]: The NTP socket is on use, exiting

Note : If the NTPD service is turned on, you need to turn off the NTPD service before you can use

4. Modify the configuration file

[[email protected] ~]# vim/etc/ntp.conf//Add red Section

Restrict default Kod nomodify notrap nopeer noquery//service denies all NTP connections

restrict-6 default Kod nomodify notrap nopeer noquery//Deny IPV6 all NTP connections

Restrict 127.0.0.1
Restrict-6:: 1//Above two means allow native access

Restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

Allow the host of the 192.168.0.0/24 network segment to do the same when the client is not allowed to modify, log on to the NTP server

#Server 0.centos.pool.ntp.org
#Server 1.centos.pool.ntp.org
#Server 2.centos.pool.ntp.org
#Server 3.centos.pool.ntp.org

Server 1.cn.pool.ntp.org
Server 2.cn.pool.ntp.org prefer //prefer First use


Logfile/var/log/ntp.log

5, synchronous update Hwclock

[Email protected] ~]# VIM/ETC/SYSCONFIG/NTPD

Sync_hwclock=yes

6. Start the NTP service

[[Email protected] ~]# service NTPD start

7. View connection status with upper level server

[Email protected] ~]# ntpq-p

    remote           refid      St T when Poll reach   delay   offset  jitter
================================================== ==========

+news.neu.edu.cn 202.118.1.46      2 u   14  128  377   44.480    2.868  31.310
*202.118.1.130   202.118.1.46     2 u   63  128  377    41.726    1.631  21.462
 local (0)         . locl.          l    9   64  377     0.000    0.000   0.001

Description : * Indicates that the upper ntp,+ currently in use indicates a standby server that has been wired to provide time updates

8. Confirm that synchronization is in progress

[[email protected] ~]# Ntpstat//Display the following time takes several minutes

Synchronised to NTP server (202.118.1.130) at Stratum 3
Time correct to within
Polling server every S

9. Join the boot start

[Email protected] ~]# chkconfig ntpd on

Iv. Client Settings

1. Synchronization Time

[Email protected] ~]# ntpdate 192.168.0.128
16:41:52 ntpdate[3293]: Adjust time server 192.168.0.128 offset 0.003880 sec

2. Join the Mission plan

[[email protected] ~]# CRONTAB-E//Daily One o'clock in the morning sync

0 1 * * */usr/sbin/ntpdate 192.168.0.128

This article is from the "M April Days" blog, please be sure to keep this source http://msiyuetian.blog.51cto.com/8637744/1712561

CentOS Build NTP server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.