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 time server

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. NTP time server:

NTP is the Network time Protocol (Network Time Protocol), which is used to synchronize the time of each computer in the network.

NTP server is used for time synchronization of LAN servers, which can ensure that the time of all servers in LAN is consistent with that of time servers. Some applications that require high real-time performance of time must unify time.

Based on Client/server mode, udp123 port

2. Installation steps:

2.1. Server side:

If the NTP server listens to port 123 of UDP, you need to enable the running client access port 123 at the local firewall. Add the following rules for vi / etc/sysconfig/iptables:

-An INPUT-m state-- state NEW-m udp-pudp-- dport 123-j ACCEPT

2.1.1. First turn off the firewall: / etc/init.d/iptables stop

Or shut down the Selinux software service: Setenforce 0 temporarily shuts down

2.1.2, [root@haikang~] # yum install ntp*-y / / install ntp software

[root@haikang ~] # cp / etc/ntp.conf/etc/ntp.conf.bak / / backup ntp main configuration file

[root@haikang ~] # vi / etc/ntp.conf / / modify ntp main configuration file

[root@haikang~] # cat / etc/ntp.conf / / View the main configuration file

Driftfile / var/lib/ntp/drift

/ / the time spent contacting the superior time server is recorded in the file after the driftfile parameter

Restrictdefault kod nomodify notrap nopeer noquery

/ / allow all to synchronize with me

Restrict 127.0.0.1 / / enable internal recursive network interface lo

Restrict 192.168.1.0 mask255.255.255.0 nomodify notrap

/ / define accessible internal subnet clients, but cannot modify the time parameters of the NTP server.

Server 0.centos.pool.ntp.org iburst

/ / superior time server

Server 127.127.1.0 # local clock// setting synchronizes the clock with the native ntp

[root@haikang~] # / etc/init.d/ntpd start

/ / start the ntp service, it will take several minutes for the client to synchronize, otherwise an error will be prompted.

[root@haikang ~] # netstat-nulp | grep ntp / / check whether there is a ntp process

[root@haikang ~] # ntpq-p / / View the parent server of the ntp server or

[root@haikang] # watch ntpq-p

Remote refid st t when poll reach delay offset jitter

=

Ntp1.ams1.nl.le 130.133.1.10 2 u 1564 153 337.087-705047 7050475

Note: remote-the ip or hostname of the native and upper ntp. "+" indicates priority, and "*" indicates secondary priority.

Refid-refer to the upper layer ntp host address

St-stratum class

When-how many seconds ago have you synchronized the time

Poll-how many seconds after the next update

Reach-the number of updates that have been requested from the upper ntp server

Delay-Network delay

Offset-time compensation

Jitter-time difference between system time and bios

2.2. Client:

[root@localhost ~] # ntpdate172.16.30.12 / / synchronize with NTP

30 May 01:15:35 ntpdate [1096]: adjust timeserver 172.16.30.12 offset 0.003669 sec

Note: if the client does not have ntpdate, you can yum-y install ntp!

Client creates scheduled tasks:

Crontab-e creates clients to synchronize periodically, and you need to create scheduled tasks.

For example, add a row to synchronize with the time synchronization server at 06:10 every day

10 (min) 06 (hour) * (day) * (month) * (week) / ip of usr/sbin/ntpdate ntp-server (172.16.30.10) > > / usr/local/logs/crontab/ntpdate.log

Crontab-l / / View scheduled tasks

Note: if the client does not have crontab, you can yum install cron*-y.

Crontab is mainly used to create scheduled tasks

2.3.The solution to errors in ntp client synchronization:

[root@localhost~] # ntpdate 172.16.30.12

30 May11:50:29 ntpdate [1136]: no server suitable for synchronization found

Client uses [root@localhost~] # ntpdate-d 172.16.30.12

Error 1.Serverdropped: no data

Turn off the firewall or join the rules-AINPUT-m state-- state NEW-m udp-p udp-- dport 123-j ACCEPT

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

Servers

Wechat

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

12
Report