Linux NTP时间同步服务搭建
ntp常用到的命名
查看ntp服务器同步状态 : ntpstat
与ntp服务器时间同步: ntpdate -u 192.168.1.21
查看时间同步状态: ntpq -p
NTP服务器部署安装
1. NTP服务器安装
[root@ntp-server ~]# rpm -qa ntp
[root@ntp-server ~]# yum install -y ntp
[root@ntp-server ~]# rpm -qa ntp
ntp-4.2.6p5-28.el7.centos.x86_64
[root@ntp-server ~]#
2. 配置NTP服务
#系统时间与BIOS事件的偏差记录
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery # 拒绝所有IPv4的client连接此NTP服务器
restrict -6 default kod nomodify notrap nopeer noquery # 拒绝所有IPv6的client连接此NTP服务器
restrict 127.0.0.1 # 放行本机localhost对NTP服务的访问
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # 放行192.168.1.0网段主机与NTP服务器进行时间同步
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst # 代表的同步时间服务器
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
-------------参数解释--------------------------
◆ 利用restrict来管理权限控制
===restrict选项格式===
restrict [ 客户端IP ] mask [ IP掩码 ] [参数]
default则表示对所有的计算机进行控制
gnore:拒绝连接到NTP服务器
nomodiy: 客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
noquery: 不提供客户端的时间查询