NTP时间服务器哈~~
装包:
[root@localhost Packages]# rpm -ivh ntp*
warning: ntp-4.2.4p8-2.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEYPreparing... ########################################### [100%] package ntpdate-4.2.4p8-2.el6.i686 is already installed package ntp-4.2.4p8-2.el6.i686 is already installed2配置主配置文件:
编辑配置文件/etc/ntp.conf
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap[手动添加,定义允许使用这台服务器的网络]
server 192.168.146.225[定义上级服务器]
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10[这两行默认是注释的,意思是当上级的时间服务器不能使用时,使用本地时间为网络中的客户端同步时间]
注释:
restrict、default定义默认访问规则
nomodify禁止远程主机修改本地服务器配置
notrap拒绝特殊的ntpdq捕获消息
noquery拒绝btodq/ntpdc查询
防火墙配置:
iptables -t filter -A INPUT -p udp --dport 123 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --sport 123 -j ACCEPT //NTP使用的是udp的123端口
配置客户端:
ntpdate //NTP服务器的ip地址
/etc/ntp/step-tickers[设置从哪个ntp服务器同步时间,格式为0.station.example.com
如果提示是:no server suitable for synchronization found //需要等待哈~这是个同步的过程
如果提示:the NTP socket is in use, exiting //是xntpd正在扫描这个端口,利用lsof -i :123,找到那个进程kill掉就OK了!
如果提示:time server ...这个就正常了哈。。!