2024年3月25日发(作者:)

linux ntp时间同步

一、搭建时间同步服务器

1、编译安装ntp server

rpm -qa | grep ntp

若没有找到,则说明没有安装ntp包,从光盘上找到ntp包,使用

rpm -Uvh ntp***.rpm

进行安装

2、修改配置文件

vi /etc/

①、第一种配置:允许任何IP的客户机都可以进行时间同步

将“restrict default nomodify notrap noquery”这行修改成:

restrict default nomodify notrap

配置文件示例:/etc/

②、第二种配置:只允许192.168.211.***网段的客户机进行时间同步

在restrict default nomodify notrap noquery(表示默认拒绝所有IP的时间同

步)之后增加一行:

restrict 192.168.211.0 mask 255.255.255.0 nomodify notrap

3、启动ntp服务

service ntpd start

开机启动服务

chkconfig ntpd on

4、ntpd启动后,客户机要等几分钟再与其进行时间同步,否则会提示“no server

suitable for synchronization found”错误。

二、配置时间同步客户机

手工执行 ntpdate 来同步

或者利用crontab来执行

crontab -e