您的位置:首页 > 编程语言 > PHP开发

ntp服务器

2016-02-25 15:12 549 查看
主页:http://www.ntp.org/

安装:yum install ntp 或 apt-get install ntp

ntp使用UDP协议,使用123端口

配置:

ntp只有一个配置文件:/etc/ntp.conf

1. 权限设置

restrict … noquery: 拒绝客户端校时请求

restrict IP地址:放行该IP地址的服务器端,可以操作本服务器

restrict IP地址 mask 子网掩码 nomodify:放行局域网客户端校时请求

一般的

restrict default kod nomodify notrap nopeer noquery:先拒绝所有IPV4用户

restrict -6 default kod nomodify notrap nopeer noquery:拒绝所有IPV6用户

restrict 127.0.0.1

restrict -6::1 : 放行本机来源

restrict 220.130.158.71 : 放行上游时间服务器

restrict 192.168.1.0 mask 255.255.255.255.0 nomodify:放行局域网客户端

2.上游服务器设置

server IP地址或hostname [prefer]: 设置上游服务器,prefer为优先使用

3.时间差记录

driftfile 文件的绝对路径

启动服务端:service ntpd on 或 /etc/init.d/ntpd start

设置开机自启动:chkconfig ntpd on

查看ntp状态:ntpstat 或 watch ntpq -p

更改时区:

centos:

时区文件在目录/usr/share/zoneinfo/文件夹下,更改时区时,先在该目录找到相应的时区文件,比如/usr/share/zoneinfo/Asia/Shanghai,然后编辑/etc/sysconfig/clock文件,ZONE=“Asia/Shanghai”即可。

更改时间:

date:显示系统时间

date mmddhhmmyyyy:更改系统时间,格式月日时分年

hwclock -r:读取硬件时

hwclock -w:将系统时写入BIOS

ntpdate -dv IP或主机名:客户端网络校时

ntpd 是逐渐调整时间,ntpdate是立即校时。建议首次用ntpdate,之后用ntpd。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: