搭建内网的NTP服务器
在内容网通不通的情况下都可以
[root@super63 ~]# ping www.baidu.com
ping: unknown host www.baidu.com[root@super63 ~]# ping www.baidu.com
ping: unknown host [www.baidu.com](http://www.baidu.com)
查看ntp端口:
[root@super63 ~]# grep ntp /etc/services
安装ntp服务器(默认已经安装)
[root@super63 ~]# rpm -ivh /mnt/Packages/ntp-4.2.6p5-1.el6.x86_64.rpm
配置ntp服务器配置文件:
[root@super63 ~]# vim /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0 #允许的网段
server 127.127.1.0 local clock #本地作为服务器,可以写外网的服务器但必须要能上网
fudge 127.127.1.0 stratum 10
重启服务:
[root@super63 ~]# service ntpd start
查看:
[root@super63 ~]# ntpstat
synchronised to local net at stratum 11
time correct to within 7948 ms
polling server every 64 s
[root@super63 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
================================================================
*LOCAL(0) .LOCL. 10 l 23 64 1 0.000 0.000 0.000
Ntp服务器需要等待一会才可以同步
测试:
[root@super64 ~]# ntpdate 192.168.1.63
7 Aug 22:48:05 ntpdate[3216]: adjust time server 192.168.1.63 offset -0.004701 sec
[root@super64 ~]# ntpdate 192.168.1.63
7 Aug 22:48:14 ntpdate[3217]: adjust time server 192.168.1.63 offset -0.000245 sec
[root@super64 ~]# ntpdate 192.168.1.63
7 Aug 22:48:16 ntpdate[3218]: adjust time server 192.168.1.63 offset 0.000083 sec
同步完成
同步外网的ntp服务器
(机器要能上网)
vim /etc/ntp.conf
server ntpdate cn.pool.ntp.org