配置实例:
(1)设定时间服务器:
#touch /etc/ntp.conf 生成配置文件ntp.conf
===================== ntp.conf ===============
server 202.197.89.0
fudge 202.197.89.0 stratum 10
driftfile /etc/ntp.drift
broadcast 202.197.89.255
#touch /etc/ntp.drift 生成ntp.drift文件
#ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid 启动时间daemon
(2)客户端的配置
#touch /etc/ntp.conf
================ /etc/ntp.conf ==============
server the_time_server
driftfile /etc/ntp.drift
#touch /etc/ntp.drift
#ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid start the Network Time Protocol daemon
(3)将某计算机作为Internet标准时间服务器的客户端,以便得到准确的时间,同时又将其作为局域网内的标准时间源、时间服务器,向网络提供标准时间
#touch /etc/ntp.conf
================= /etc/ntp.conf ==============
server time.nist.gov
server ntp.ise.canberra.edu.au
server 202.197.89.0
fudge 202.197.89.0 stratum 10
driftfile /etc/ntp.drift
broadcast 202.197.89.255
#touch /etc/ntp.drift
保存退出后。启动NTP服务
service ntpd start
如果想每次系统启动,NTP服务自动启动,请输入下面命令: chkconfig -level 35 ntpd on 注意:
1.NTP服务的端口是123,使用的是udp协议,所以NTP服务器的防火墙必须对外开放udp 123这个端口。
2.Ntpd启动的时候通常需要一段时间进行时间同步,所以在ntpd刚刚启动的时候还不能正常提供时钟服务,最长大概有5分钟吧,如果超过了这个时间请检查一下您的配置文件。