每次时间同步都是连接外网,最近公司架构调整,服务器不能上网,就做了台内网ntp服务器,做下笔记!
//安装ntp服务 [root@localhost ~]# yum install ntp //允许BIOS与系统时间同步 [root@localhost ~]# vim /etc/sysconfig/ntpd SYNC_HWCLOCK=yes [root@localhost ~]# grep -Ev '^#|^$' /etc/ntp.conf driftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery //允许本地所有操作 restrict 127.0.0.1 server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst //允许的局域网络段 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 如果无法与上层ntp server通信以本地时间为标准时间 server 127.127.1.0 fudge 127.127.1.1 stratum 8 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys 详解 restrict <IP 地址> <子网掩码> |<网段> <子网掩码> [ignore|noquery|notrap|nomodiy|notrust|nokod] ignore :关闭所有ntp服务 noquery:不提供ntp服务 notrap:不提供trap远程事件登录的功能 nomodiy:表示客户端不能更改ntp服务器的时间参数,但可以通过ntp服务器进行时间矫正 notrust:拒绝没有通过认证的客户端 nokod:kod技术可以组织一种dos*** //服务端执行,知道何时ntp server完成了和自身同步的过程 [root@localhost ~]# watch ntpd -p //客户端排错可以用这 [root@localhost ~]# ntpdate -d 192.168.1.204 12 Dec 13:45:02 ntpdate[7735]: ntpdate 4.2.6p5@1.2349-o Sat Nov 23 18:21:48 UTC 2013 (1) Looking for host 192.168.1.204 and service ntp host found : localhost transmit(192.168.1.204) receive(192.168.1.204) transmit(192.168.1.204) receive(192.168.1.204) transmit(192.168.1.204) receive(192.168.1.204) transmit(192.168.1.204) receive(192.168.1.204) server 192.168.1.204, port 123 stratum 6, precision -23, leap 00, trust 000 refid [192.168.1.204], delay 0.02608, dispersion 0.00003 transmitted 4, in filter 4 reference time: d834ff41.01e47d7f Fri, Dec 12 2014 13:44:33.007 originate timestamp: d834ff5e.9ab47225 Fri, Dec 12 2014 13:45:02.604 transmit timestamp: d834ff5e.6fa7c51a Fri, Dec 12 2014 13:45:02.436 filter delay: 0.02626 0.02634 0.02644 0.02608 0.00000 0.00000 0.00000 0.00000 filter offset: 0.167760 0.167849 0.167936 0.167741 0.000000 0.000000 0.000000 0.000000 delay 0.02608, dispersion 0.00003 offset 0.167741 12 Dec 13:45:02 ntpdate[7735]: adjust time server 192.168.1.204 offset 0.167741 sec 问题:no server suitable for synchronization found 安装好ntp后,但是客户端不同步时间,报错,刚开始认为是防火墙,防火墙关了,selinux也关了,还是报错 最后在配置文件中添加上这行才搞定 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
转载于:https://blog.51cto.com/kingtigerhu/1589281