linux的ntp配置总结

上传人:小** 文档编号:87289425 上传时间:2019-03-31 格式:DOCX 页数:8 大小:96.74KB
返回 下载 相关 举报
linux的ntp配置总结_第1页
第1页 / 共8页
linux的ntp配置总结_第2页
第2页 / 共8页
linux的ntp配置总结_第3页
第3页 / 共8页
linux的ntp配置总结_第4页
第4页 / 共8页
linux的ntp配置总结_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《linux的ntp配置总结》由会员分享,可在线阅读,更多相关《linux的ntp配置总结(8页珍藏版)》请在金锄头文库上搜索。

1、Linux的NTP配置总结2015-08-20 12:29 by 潇湘隐者,4678阅读,2评论,收藏,编辑在Linux系统中,为了避免主机时间因为在长时间运行下所导致的时间偏差,进行时间同步(synchronize)的工作是非常必要的。Linux系统下,一般使用ntp服务来同步不同机器的时间。NTP 是网络时间协议(Network Time Protocol)的简称,干嘛用的呢?就是通过网络协议使计算机之间的时间同步化。安装NTP包检查是否安装了ntp相关包。如果没有安装ntp相关包,使用rpm或yum安装,安装也非常简单方便。rootlocalhost # rpm -qa | grep n

2、tpntpdate-4.2.6p5-1.el6.x86_64fontpackages-filesystem-1.41-1.1.el6.noarchntp-4.2.6p5-1.el6.x86_64NTP的配置A: 配置/etc/ntp.confNTP Server的主要配置文件为/etc/ntp.conf ,没有修改过的ntp.conf文件内容如下所示,配置选项都有相关注释信息(Linux 版本为Red Hat Enterprise Linux Server release 6.6 )rootlocalhost # more /etc/ntp.conf# For more information

3、 about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var/lib/ntp/drift# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.restrict default kod nomodify n

4、otrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict 127.0.0.1 restrict -6 :1# Hosts on local network are less restricted.#

5、restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http:/www.pool.ntp.org/join.html).server 0.rhel.pool.ntp.org iburstserver 1.rhel.pool.ntp.org iburstserver 2.rhel.pool.ntp.org iburstserver 3.rhel.pool.ntp.or

6、g 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

7、 public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography. keys /etc/ntp/keys# Specify the key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpd

8、c utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statistics clockstats cryptostats loopstats peerstats各个选项信息:#系统时间与BIOS事件的偏差记录driftfile /etc/ntp/driftrestrict 控制相关权限。语法为: restrict IP地址 mask 子网掩码 参数其中IP地址也可以是default

9、,default 就是指所有的IP参数有以下几个:ignore :关闭所有的 NTP 联机服务nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。nopeer :用于阻止主机尝试与服务器对等,并允许欺诈服务器控制时钟kod : 访问违

10、规时发送 KoD 包。restrict -6 表示IPV6地址的权限设置。1:设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。server 192.168.7.49 prefer server 0.rhel.pool.ntp.org iburstserver 1.rhel.pool.ntp.org iburstserver 2.rhel.pool.ntp.org iburstserver 3.rhel.pool.ntp.org iburst2:限制你允许的这些服务器的访问类型,在这个例子中的服务器是不容许修改运行时

11、配置或查询您的Linux NTP服务器restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap在上例中,掩码地址扩展为255,因此从192.168.0.1-192.168.0.254的服务器都可以使用我们的NTP服务器来同步时间#此时表示限制向从192.168.0.1-192.168.0.254这些IP段的服务器提供NTP服务。restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap noquery#设置默认策略为允许任何主机进行时间同步restrict

12、default ignore3:确保localhost(这个常用的IP地址用来指Linux服务器本身)有足够权限.使用没有任何限制关键词的语法:restrict 127.0.0.1restrict -6 :1B:配置/etc/ntp/stpe-tickers文件修改/etc/ntp/stpe-tickers文件,内容如下(当ntpd服务启动时,会自动与该文件中记录的上层NTP服务进行时间校对)rootlocalhost ntp# more /etc/ntp/step-tickers # List of servers used for initial synchronization.rootl

13、ocalhost ntp# vi /etc/ntp/step-tickers # List of servers used for initial synchronization.server 192.168.7.49 preferserver 0.rhel.pool.ntp.orgserver 1.rhel.pool.ntp.org server 2.rhel.pool.ntp.org server 3.rhel.pool.ntp.org 关于ntp.conf and step-tickers区别:step-tickers is used by ntpdate where as ntp.co

14、nf is the configuration file for the ntpd daemon. ntpdate is initially run to set the clock before ntpd to make sure time is within 1000 sec. ntp will not run if the time difference between the server and client by more then 1000 sec ( or there about). The start up script will read step-tickers for

15、servers to be polled by ntpdate.C:配置/etc/sysconfig/ntpd文件ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样,就可以让硬件时间与系统时间一起同步。#允许BIOS与系统时间同步,也可以通过hwclock -w 命令SYNC_HWCLOCK=yesIPTABLES 配置由于NTP服务需要使用到UDP端口号123,所以当系统的防火墙(Iptables)启动的情况下,必须开放UDP端口号123。rootlocalhost # /etc/init.d/iptables statusTable: filterChain INPUT (policy ACCEPT)num target pr

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号