Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

NTP configuration under Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "NTP configuration under Linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "NTP configuration under Linux".

Installation environment:

Red Hat Enterprise Linux Server release 6.7 (Santiago)

1. Check whether the ntp package on the server and client has been installed. It is installed by default:

Rpm-qa | grep ntp

Rpm-Q ntp

II. Server side

1. Edit the configuration file / etc/ntp.conf for the ntp server:

Server 127.127.1.0 # use this machine as a ntp server

Fudge 127.127.1.0 stratum 0 # this line is the time server hierarchy. Set to 0 as the top level. If you want to update the time to another NTP server, please do not set it to 0

two。 Restart the ntp service:

Service ntp restart (Ubuntu)

Service ntpd restart (CentOS, linux)

Systemctl restart ntpd (CentOS7.X, redhat linux 7 or above)

The firewall of the 3.ntp server releases port 123 of ntp: (it is not necessary if the iptable firewall is turned off, just skip it)

/ sbin/iptables-I INPUT-p udp-- dport 123-j ACCEPT

/ etc/init.d/iptables status

Netstat-tlunp | grep ntp

4. Check whether the ntp service is powered on and set it to boot

Chkconfig-list ntpd

Chkconfig-level 345 ntpd on

3. Client ntp client

1. Edit the configuration file / etc/ntp.conf for the ntp client and add server_ip:

Server server_ip

two。 After startup, it usually takes about 5-10 minutes to start synchronizing time with the external time server. You can query the NTPD service through the command.

Service ntpd restart

-- View status:

Ntpq-p

Or

Watch "ntpq-p"

-- check whether the ntp server is connected to the upper ntp:

Ntpstat

-- if you need to synchronize manually, you need to stop the ntp service of client first:

Servict ntpd stop

Ntpdate ntpserver_ip

3. Check whether the ntp service is powered on and set it to boot

Chkconfig-list ntpd

Chkconfig-level 345 ntpd on

Example:

Client:

[root@one ~] # grep-v ^ # / etc/ntp.conf

Driftfile / var/lib/ntp/drift

Restrict default kod nomodify notrap nopeer noquery

Restrict-6 default kod nomodify notrap nopeer noquery

Restrict 127.0.0.1

Restrict-6:: 1

Server 192.168.56.20 prefer

Includefile / etc/ntp/crypto/pw

Keys / etc/ntp/keys

[root@one ~] #

[root@one] # ntpq-p

Remote refid st t when poll reach delay offset jitter

=

192.168.56.20 .LOCL. 1 u 27 64 177 0.167 2100350 8577226

[root@one ~] #

[root@one ~] # ntpstat

Synchronised to unspecified at stratum 2

Time correct to within 14779 ms

Polling server every 64 s

[root@one ~] #

Server side server_ip side:

[root@slient ~] # grep-v ^ # / etc/ntp.conf

Driftfile / var/lib/ntp/drift

Restrict default kod nomodify notrap nopeer noquery

Restrict-6 default kod nomodify notrap nopeer noquery

Restrict 127.0.0.1

Restrict-6:: 1

Includefile / etc/ntp/crypto/pw

Keys / etc/ntp/keys

Server 127.127.1.0

Fudge 127.127.1.0 stratum 0

[root@slient ~] #

Thank you for reading, the above is the content of "NTP configuration under Linux". After the study of this article, I believe you have a deeper understanding of the NTP configuration under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report