首页 > 编程知识 正文

配置ntp客户端,linux重启ntp服务命令

时间:2023-05-04 01:22:40 阅读:16799 作者:405

在Linux系统中,为了避免长时间运行导致的主机时间偏移,需要进行时间同步(synchronize )的作业。 在Linux系统上,通常使用ntp服务同步不同计算机上的时间。 NTP是网络时间协议的简称,它有什么用呢? 就是通过网络协议同步计算机之间的时间。

安装NTP软件包

检查是否安装了ntp相关软件包。 如果未安装ntp相关软件包,则使用rpm或yum进行安装也非常简单和方便。

复制代码

代码为以下:

[root@localhost ~]# rpm -qa | grep

NTP ntpdate-4.2.6 P5-1.el6.x86 _ 64

字体包文件系统- 1.41-1.1.el6.noarch

ntp-4.2.6p5-1.el6.x86_64

NTP配置

答:配置/etc/ntp.conf

NTP服务器的主要配置文件为/etc/ntp.conf,未更改的ntp.conf文件内容如下: 配置选项包含注释信息。 (Linux版本为redhatenterpriselinuxserverrelease 6.6 ) )。

复制代码

代码为以下:

[ root @ localhost~] # more/etc/NTP.conf

# formoreinformationaboutthisfile,see the man pages

#NTP.conf(5,ntp_acc(5) 5,ntp_auth(5) 5,ntp_clock(5) 5,ntp_misc(5) 5,ntp_mon(5) 5

差速文件/var/lib/NTP /差速

# permittimesynchronizationwithourtimesource,but do not

# permitthesourcetoqueryormodifytheserviceonthissystem。

restrictdefaultkodnomodifynotrapnopeernoquery

restrict-6 defaultkodnomodifynotrapnopeernoquery

# permitallaccessovertheloopbackinterface.this could

# be tightened as well,but to do so would effect some of

# the管理员tive functions。

restrict 127.0.0.1

restrict -6 :1

# hostsonlocalnetworkarelessrestricted。

# restrict 192.168.1.0 mask 255.255.255.0否修改说明

# usepublicserversfromthepool.NTP.org project。

# please consider连接the pool (。

server0. rhel.pool.NTP.org I burst

server1. rhel.pool.NTP.org I burst

server2. rhel.pool.NTP.org I burst

server3. rhel.pool.NTP.org I burst

# broadcast 192.168.1.255 autokey # broadcast服务器

# broadcast客户端# broadcast客户端

# broadcast 224.0.1.1 autokey #多服务器

#多客户端224.0.1.1 #多客户端

# manycastserver 239.255.254.254 # manycastserver

# manycastclient 239.255.254.254 autokey # manycastclient

# enable公共密钥复制图形。

#crypto

包含文件/etc/NTP/crypto/pw

# keyfilecontainingthekeysandkeyidentifiersusedwhenoperating

# with系统密钥复制图形。

keys /etc/ntp/keys

# specifythekeyidentifierswhicharetrusted。

#可信密钥4842

# specifythekeyidentifiertousewiththentpdcutility。

#请求密钥8

# specifythekeyidentifiertousewiththentpqutility。

#controlkey 8

#启用writingofstatisticsrecords。

# statisticsclockstatscryptostatsloopstatspeerstats

[ root @ localhost~] # more/etc/NTP.conf

# formoreinformationaboutthisfile,see the man pages

#NTP.conf(5,ntp_acc(5) 5,ntp_auth(5) 5,ntp_clock(5) 5,ntp_misc(5) 5,ntp_mon(5) 5

差速文件/var/lib/NTP /差速

# permittimesynchronizationwithourtimesource,but do not

# permitthesourcetoqueryormodifytheserviceonthissystem。

restrictdefaultkodnomodifynotrapnopeernoquery

restrict-6 defaultkodnomodifynotrapnopeernoquery

# permitallaccessovertheloopbackinterface.this could

# be tightened as well,but to do so would effect some of

# the管理员tive functions。

restrict 127.0.0.1

restrict -6 :1

# hostsonlocalnetworkarelessrestricted。

# restrict 192.168.1.0 mask 255.255.255.0否修改说明

# usepublicserversfromthepool.NTP.org project。

# please consider连接the pool (。

server0. rhel.pool.NTP.org I burst

server1. rhel.pool.NTP.org I burst

server2. rhel.pool.NTP.org I burst

server3. rhel.pool.NTP.org I burst

# broadcast 192.168.1.255 autokey # broadcast服务器

# broadcast客户端# broadcast客户端

# broadcast 224.0.1.1 autokey #多服务器

#多客户端224.0.1.1 #多客户端

# manycastserver 239.255.254.254 # manycastserver

# manycastclient 239.255.254.254 autokey # manycastclient

# enable公共密钥复制图形。

#crypto

包含文件/etc/NTP/crypto/pw

# keyfilecontainingthekeysandkeyidentifiersusedwhenoperating

# with系统密钥复制图形。

keys /etc/ntp/keys

# specifythekeyidentifierswhicharetrusted。

#可信密钥4842

# specifythekeyidentifiertousewiththentpdcutility。

#请求密钥8

# specifythekeyidentifiertousewiththentpqutility。

#controlkey 8

#启用writingofstatisticsrecords。

# statisticsclockstatscryptostatsloopstatspeerstats

每个选项信息:

#系统时间和BIOS事件偏差记录

差速文件/etc/NTP /差速

restrict控制相关权限。

语法是restrict IP地址掩码的参数

其中,IP地址可以是default,default是指所有IP

参数如下:

ignore :关闭所有NTP在线服务

nomodify :客户端无法更改服务端的时间参数,但客户端可以通过服务端进行网络校准。

notrust客户端的源被视为不可信的子网,除非客户端经过验证

noquery :不提供客户端时间查询:客户端不能使用ntpq、ntpc等命令查询ntp服务器

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。