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

How to configure ntp server in linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article Xiaobian introduces in detail "how to configure ntp server in linux", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to configure ntp server in linux" can help you solve your doubts.

one。 Install ntp softwar

1. Check to see if ntp related packages are installed.

Rpm-qa | grep ntp

two。 Install the ntp software.

Yum-y install ntp

two。 Parameter explanation

Ignore: turn off all ntp online services

Nomodify: the client cannot change the time parameter of the server, but the client can calibrate the time on the network through the server.

Notrust: unless the client is authenticated, the client source will be considered an untrusted subnet

Noquery: no client time query: the client cannot use commands such as ntpq,ntpc to query the ntp server

Notrap: does not provide trap remote login: refuses to provide mode 6 control message trap service for matching hosts. Trap service is a subsystem of ntpdq control message protocol and is used for remote event loggers.

Nopeer: used to prevent hosts from trying to peer with the server and to allow fraudulent servers to control the clock

Kod: sends kod packets when access violations occur.

three。 Modify the configuration file

1. View unmodified configuration fil

# grep ^ [^ #] / etc/ntp.conf driftfile / var/lib/ntp/driftrestrict default nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict:: 1server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburstincludefile / etc/ntp/crypto/pwkeys / etc/ntp/keysdisable monitor

1. The setting allows any ip client to synchronize time (modified profile)

# grep ^ [^ #] / etc/ntp.conf driftfile / var/lib/ntp/driftrestrict default nomodify notraprestrict 127.0.0.1restrict:: 1server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburstincludefile / etc/ntp/crypto/pwkeys / etc/ntp/keysdisable monitor

two。 Only allow time synchronization for clients on the 192.168.1.0 network segment (modified configuration file)

# grep ^ [^ #] / etc/ntp.conf driftfile / var/lib/ntp/driftrestrict default nomodify notrap nopeer noqueryrestrict 127.0.0.1restrict:: 1restrict 192.168.1.0 mask 255.255.255.0 nomodify notrapserver 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.ntp.org iburstserver 3.centos.pool.ntp.org iburstincludefile / etc/ntp/crypto/pwkeys / etc/ntp/keysdisable monitor

four。 Start the ntp service and firewall

Systemctl start ntpd

Systemctl enable ntpd

Iptables-an input-p udp-I eno16777736-s 192.168.1.0 dport 24-- dport 123-j accept

Setsebool-p ntp_disable_trans 1#selinux Settings

Vi / etc/sysconfig/ntpd# allows bios to synchronize with system time, add the following line.

Sync_hwclock=yes

five。 Detect ntp

1. Detect whether the ntp service is running

# netstat-tlunp | grep ntpudp 0 0192.168.1.101grep ntpudp 123 0.0.0.0.0 2563/ntpd udp 0 127.0.0.1 grep ntpudp 0.0.0.0 2563/ntpd udp 000.0.0.0.0 grep ntpudp 123 0.0.0.0 * 2563/ntpd udp6 0 0 fe80::20c:29ff:fe7b:123: * 2563/ntpd udp6 0 0 2563/ntpd: 1 2563/ntpd udp6 0 0 2563/ntpd udp6: *

two。 Check to see if the ntp server is connected to the upper ntp

# ntpstatsynchronised to ntp server (120.25.108.11) at stratum 3 time correct to within 99 ms polling server every 64 s

3. Check the status of the ntp server and the upper ntp

# ntpq-p remote refid st t when poll reach delay offset jitter==== news.neu.edu.cn .init. 16 u-64 0 0.000 0.000 0.000x202.118.1.130 202.118.1.47 2 u 7 64 377 153.659 9.605 19.941*time4.aliyun.co 10.137.38.86 2 u 10 64 377 39.666-47.66115.944remote-ip or hostname of the native and upper ntp, "+" indicates priority "*" indicates second priority refid-refer to the upper layer ntp host address st-stratum hierarchy when-how many seconds ago have synchronized time poll-how many seconds after the next update reach-the number of updates requested from the upper ntp server delay-network delay offset-time compensation jitter-time difference between system time and bios time

six。 Configure time synchronization client

1. Execute the ntpdate command:

Ntpdate 192.168.1.101 # 192.168.1.101 is the ip address of the ntp server

two。 Write to bios

Hclock-w

3.crond service

Vi / etc/crontab

308 * root / usr/sbin/ntpdate 192.168.1.101; / sbin/hwclock-w

4. Restart the crond service

Service crond restart

After reading this, the article "how to configure ntp server in linux" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report