Ntp server configuration in Linux

Source: Internet
Author: User
Ntp server in Linux 1. what is ntp? NetworkTimeProtocol (Network Time Protocol) is a protocol used to synchronize the computer's time. it can synchronize the computer's server or clock source, it provides high-precision time correction. 2. Introduction to the ntp configuration file 1. main configuration files of/etc/ntp. confNTP service, different Li

Ntp server in Linux

1. what is ntp?

Network Time Protocol (NTP) is a Protocol used to synchronize the computer's Time. it can synchronize the computer's server or clock source, it provides high-precision time correction.

2. Introduction to the ntp configuration file

1./etc/ntp. conf
The main configuration file of the NTP service. The directories of different Linux version files may be different.
2./usr/share/zoneinfo
Specifies the time setting file for each major time zone. /Usr/share/zoneinfo/Asia/Shanghai is the time zone setting file for mainland China.
3./etc/sysconfig/clock
Time zone setting file
4./etc/localtime
Local system time setting file

[Root @ tx1 ~] # Grep-v "^ #"/etc/ntp. conf

Restrict default kod nomodify notrap nopeer noquery // reject all operations on the default client

Restrict-6 default kod nomodify notrap nopeer noquery // ipv6 settings

Restrict 127.0.0.1 // allow all operations on the local address

Restrict-6: 1

Server 0.rhel.pool.ntp.org // set the upper-layer server to synchronize IP addresses.

Server 1.rhel.pool.ntp.org

Server 2.rhel.pool.ntp.org

Server 127.127.1.0 // local Address

Fudge 127.127.1.0 stratum 10 // This row is the layer of the time server. If it is set to 0, it is the top level. if you want to update the time to another NTP server, do not set it to 0.

Driftfile/var/lib/ntp/drift // record the time spent connecting the last NTP server to the upper-layer NTP server

Keys/etc/ntp/keys

Parameters:

Ignore: disable all NTP online services.
Nomodify: the client cannot change the time parameter of the server, but the client can perform network calibration on the server.
Notrust: the client source is considered as a untrusted subnet unless it passes authentication.
Noquery: no client time query is provided.

3. specific configuration

[Root @ tx1 ~] # Vim/etc/ntp. conf

3 restrict default kod nomodify notrap nopeer noquery

4 # restrict-6 default kod nomodify notrap nopeer noquery

5 restrict default nomodify

6 restrict 192.168.8.0 mask 255.255.255.0 nomodify

11 restrict 127.0.0.1

18 # server 0.rhel.pool.ntp.org

19 # server 1.rhel.pool.ntp.org

20 # server 2.rhel.pool.ntp.org

21 server 192.168.8.70

31 server 127.127.1.0 # local clock

32 fudge 127.127.1.0 stratum 10


[Root @ tx1 ~] #/Etc/init. d/ntpd restart

Shutting down ntpd: [OK]

Starting ntpd: [OK]

Client Test

Note: the IP address and host name of the ntp server must be added to/etc/hosts on the client.

[Root @ tx2 ~] # Ntpdate 192.168.8.70

2 Mar 00:35:44 ntpdate [11181]: no server suitable for synchronization found

Note: After the ntp service is started on the ntp server, it may take five minutes for the ntp server to synchronize itself or with its server, during this time, when the client runs the ntpdate command for synchronization, the no server suitable for synchronization found error will occur.

View synchronization process

[Root @ tx1 ~] # Watch ntpq-p

Note: The LOCAL ntp server is synchronized with itself. The value of reach increases from 0 after the ntp server service is started. when it increases to 17, it is changed 5 times from 0 to 17, the number of seconds for each poll value, which is the time for 64 seconds * 5 = 320 seconds.
Client Test

[Root @ tx2 ~] # Ntpdate 192.168.8.70

2 Mar 00:40:51 ntpdate [11184]: adjust time server 192.168.8.70 offset-0.000031 sec

[Root @ tx2 ~] # Date

Sat Mar 2 01:00:13 CST 2013

Server

[Root @ tx1 ~] # Date

Sat Mar 2 01:00:15 CST 2013

[Root @ tx1 ~] #

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.