FreeBSD NTP服务器配置笔记

一组服务器里面配置一台NTP服务器也是必要的,可以让所有服务器的时间同步。

一、配置NTP服务器

vi /etc/rc.conf

ntpd_enable="YES"

vi /etc/ntp.conf

server www.freebsd.org prefer
server time.windows.com
server 127.127.1.0
fudge 127.127.0.1 stratum 5

restrict default ignore
restrict 127.0.0.0 mask 255.0.0.0
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

driftfile /var/db/ntp.drift

启动NTP服务:

/etc/rc.d/ntpd start

二、客户端配置

vi /root/scripts/synctime.sh

#!/bin/sh
/usr/sbin/ntpdate 192.168.0.100 #内网NTP服务器地址

chmod +x /root/scripts/synctime.sh
crontab -e

*/30 * * * * cd /root/scripts;./synctime.sh

这样客户端服务器每半小时就会和NTP服务器同步一次。

发表评论

电子邮件地址不会被公开。 必填项已用*标注