---
title: "centos 5 .6安装NTP服务器"
author: "wiseboyloves"
date: "2012-08-21T22:30:48Z"
tags: []
categories: ["操作系统"]
slug: "centos-5-6-ntp"
draft: false
lastmod: "2012-08-21T22:30:48Z"
id: 1651270
url: "https://wiseboyloves.iteye.com/blog/1651270"
---

为有些服务和实验需要多台机器的时间同步，所以就有了搭建NTP的前提条件了，具体步骤如下：

1，安装ntp服务

yum install ntp.i* -y

2,修改/etc/ntp.conf

restrict default kod nomodify notrap nopeer noquery   #  
restrict -6 default kod nomodify notrap nopeer noquery  #针对ipv6设置

#这是ntp的默认设置

\# 允许本地所有操作  
restrict 127.0.0.1  
restrict -6 ::1

\# 允许的局域网络段  
restrict 10.0.0.0 mask 255.0.0.0 nomodify motrap  
restrict 192.168.0.0 mask 255.255.0.0 nomodify motrap

\# 使用上层的internet ntp服务器  
restrict 207.46.232.182 mask 255.255.255.255 nomodify notrap noquery  
server 207.46.232.182

\# 如果无法与上层ntp server通信以本地时间为标准时间  
server    127.127.1.0    # local clock  
fudge    127.127.1.0 stratum 10   

\# 计算本ntp server 与上层ntpserver的频率误差  
driftfile /var/lib/ntp/drift

\# Key file containing the keys and key identifiers used when operating  
\# with symmetric key cryptography.  
keys /etc/ntp/keys  
#日志文件  
logfile /var/log/ntp.log

 

#说明：

restrict &lt;IP 地址&gt; &lt;子网掩码&gt; |&lt;网段&gt; &lt;子网掩码&gt; \[ignore|noquery|notrap|nomodiy|notrust|nokod]

ignore :关闭所有ntp服务

noquery：不提供ntp服务

notrap：不提供trap远程事件登录的功能

nomodiy：表示客户端不能更改ntp服务器的时间参数，但可以通过ntp服务器进行时间矫正

notrust：拒绝没有通过认证的客户端

nokod：kod技术可以组织一种dos攻击

 

 

2，在修改/etc/ntp/step-tickers文件

207.46.232.182

127.127.1.0

#当ntp服务器启动时自动与这个文件中的记录ip进行时间校对

 

3，修改/etc/sysconfig/ntpd

SYNC\_HWCLOCK=YES #允许BIOS与系统时间同步

 

4，客户端设置略。