时间服务器同步设置ntp

来源:互联网 发布:mac打字左下角 编辑:程序博客网 时间:2024/05/17 15:18

时间服务器同步设置:【yum ntp 端口:123】【/usr/sbin/ntpdate-u pool.ntp.org(阿里云)

上海电信授时中心:/usr/sbin/ntpdate -u ntp.api.bz-u参数可以越过防火墙与主机同步

00 1 * * * root  ntpdate -untp.api.bz【crontab -e,每天凌晨1点运行命令】

配置文件:vi /etc/ntp.conf

restrict 192.168.56.12      <---------客户端需要同步的ip,有多少个客户端,添加多     

restrict 127.0.0.1         <---------允许本地同步,便于本地监控、配置

server 192.168.56.200      <---------需要同步的上层服务器

fudge 192.168.56.200 stratum 8   <-------同步上层服务器的stratum 大小不能超过或等于16

另一种设置:

restrict default  nomodifynotrap      <-----      允许所有ip,省去设置麻烦   

lsof -i:123   查看123端口             ntpq -p        查看服务器同步状态

客户端设置

ntpdate -d 192.168.56.11  查看原因

ntpdate -u 192.168.56.11

【通常启动NTP服务5分钟后,计算机才能成功连接到外网的NTP服务器进行时间同步】     

注意:

1:本身主机设置成ntp服务器:

2:客户端手工设置ntpdate时,需要stop 客户端的ntpd服务 

 

ntpdate -d IP 报错:Server dropped: no data

(1)可能是server的防火墙屏蔽了upd 123端口。

vi /etc/sysconfig/iptables

添加增加端口: -A RH-Firewall-1-INPUT -p udp --dport 123 -j ACCEPT  

(2)ntpq -c version 查看版本,4.2以上把notrust去掉

0 0
原创粉丝点击