1、在ntp的官网上下载源码包wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p8.tar.gz
2、解压源码包编译安装tar zxvf ntp-4.2.8p8.tar.gzcd ntp-4.2.8p8./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocksmake && make install
3、修改ntp.conf配置文件vi /etc/ntp.conf第一种配置:允许任何IP的客户机都可以进行时间同步将“restrict default nomodify notrap noquery”这行修改成:restrict default nomodify
4、第二种配置:只允许192.168.150.***网段的客户机进行时间同步在restrict default nomodify notrap noquery(表示默鹚剖蛲蛋认拒绝所有IP的时间同步)之后增加一行:restrict 192.168.150.0 mask 255.255.255.0 nomodify
5、启动ntpd/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
6、在客户机上使用ntpdate 192.168.150.39同步时间,192.168.150.39就是刚才搭建的ntp服务器的IP地址。如果出现“no server suitable for synchronization found”,将ntp服务器上的服务重启下