您的位置:首页 > 运维架构 > Linux

配置centos 7 ntp server

2015-12-15 11:49 691 查看
原文地址:7 ntp server">配置centos 7 ntp server作者:仲万江配置centos 7
ntp server

1.关闭防火墙
值得注意的是centos7防火墙在iptables的基础上增加了firewalld,两个都需要关闭或者放行。
2.安装ntp server

使用 rpm -qa
ntp可以查看是否已安装ntp服务,如果已安装则直接跳到步骤3,如果没有参考如下:
1)yum安装
#yum -y install ntp
#
此种安装方式需要连接到互联网。
2)rpm安装
#rpm -ivh
ntp-4.2.2p1-9.el5_4.1.rpm
3)源码安装
#tar -xzvf
ntp-4.2.4p6.tar.gz
#./configure --prefix=/usr/local/ntp &&
make && make install

本次我使用的是第一种安装方式。
3.配置ntp

1)#vi /etc/ntp.conf
2)##########################################
####restrict参数####
kod 使用kod技术防范“kiss of death”攻击
ignore 拒绝任何NTP连接
nomodify 用户端不能使用ntpc,ntpq修改时间服务器参数,但是可以进行网络校时
noquery 用户端不能使用ntpc,ntpq查询时间服务器参数,不可以进行网络校时
notrap 不提供远程日志功能
notrust 拒绝没有认证的客户端
restrict ip 或者 restrict IP地址 + mask + 子网掩码 + 参数 例如:
restrict default nomodify notrap nopeer noquery
#默认拒绝所有访问
restrict 211.71.14.254 mask 255.255.255.0
#添加允许211.71.14.254/24网段访问
restrict 10.111.1.1 mask 255.0.0.0 nomodify
#添加10.0.0.0/8网段访问,不可以修改服务器时间参数

####server 参数####
server + ip 或者 server + hostname
使用prefer参数可以设置优先上级服务器 例如:
server 202.112.128.33 prefer
#默认上级时间服务器为202.112.128.33
server 202.112.10.60
#备用上级时间服务器为202.112.10.60
fudge 127.127.1.0 stratum 3
#设置本地时间级别是3,如果上级时间服务器均失效,对外发布本地时间,时间层级是4。
driftfile /var/lib/ntp/drift
#本地与上层服务器BIOS晶片振荡频率差值保存目录,不需要修改!
keys /etc/ntp/keys
#可以借此来给客户端设置认证信息,不需要修改!
以上ntp配置完成!
4.启动ntp server 服务并在client端测试

1)启动前的准备
#ntpdate 202.112.128.33
#更新系统时间
#hwclock sysctohc
#设置硬件时钟与系统时钟同步
2)启动ntpd
[root@localhost log]# service ntpd start
#启动ntp服务
Redirecting to /bin/systemctl start
ntpd.service
[root@localhost log]# cat /var/log/messages
#查看日志信息
......
Nov 23 21:37:06 localhost systemd: Started Network
Time Service.
3)测试

#ntpdate 211.71.14.159
#在centos测试
除了在linux测试还可以选择在windows测试,本次测试选择的是在windows server 2008 R2
和一台windows
7测试,其中2008的IP 地址是10.x.x.x,windows7是另外一个网段的公网地址,均可以正常使用时间服务.

至于windows7为什么可以我还在找原因,然后来完善!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: