安装配置NTP服务器

S端:

192.168.1.193

[root@ntpserver ~]# yum install ntp -y &>/dev/null
[root@ntpserver ~]# rpm -ql ntp
/etc/dhcp/dhclient.d
/etc/dhcp/dhclient.d/ntp.sh
/etc/ntp.conf                        #主配置文件
/etc/ntp/crypto
/etc/ntp/crypto/pw
/etc/rc.d/init.d/ntpd                #启动脚本
/etc/sysconfig/ntpd
/usr/bin/ntpstat
/usr/sbin/ntp-keygen
/usr/sbin/ntpd
/usr/sbin/ntpdc
/usr/sbin/ntpq                        #-q可以查看和上层服务器的联机结果
/usr/sbin/ntptime
/usr/sbin/tickadj
/usr/share/doc/ntp-4.2.4p8
/usr/share/doc/ntp-4.2.4p8/COPYRIGHT
/usr/share/doc/ntp-4.2.4p8/ChangeLog
/usr/share/doc/ntp-4.2.4p8/NEWS
/usr/share/man/man5/ntp.conf.5.gz
/usr/share/man/man5/ntp_acc.5.gz
/usr/share/man/man5/ntp_auth.5.gz
/usr/share/man/man5/ntp_clock.5.gz
/usr/share/man/man5/ntp_misc.5.gz
/usr/share/man/man5/ntp_mon.5.gz
/usr/share/man/man8/ntp-keygen.8.gz
/usr/share/man/man8/ntpd.8.gz
/usr/share/man/man8/ntpdc.8.gz
/usr/share/man/man8/ntpq.8.gz
/usr/share/man/man8/ntpstat.8.gz
/usr/share/man/man8/ntptime.8.gz
/usr/share/man/man8/tickadj.8.gz
/var/lib/ntp
/var/lib/ntp/drift
/var/log/ntpstats                #以列出我们的 NTP 服务器是否和上层联机
[root@ntpserver ~]# sed '{/^$/d;/#/d}' /etc/ntp.conf 
driftfile /var/lib/ntp/drift                          #预设时间差异分析文件
restrict default kod nomodify notrap nopeer noquery   #拒绝 IPv4 的用户
restrict -6 default kod nomodify notrap nopeer noquery#拒绝 IPv6 的用户
restrict 127.0.0.1 
restrict 218.75.4.130                                 #允许ntp.api.bz
restrict 202.112.10.36                                #允许cn.pool.ntp.org
restrict 192.168.1.0 mask 255.255.255.0 noquery       #允许192.168.1.0/24所有主机
restrict -6 ::1
server 218.75.4.130 prefer                            #默认上层ntp服务器
server 202.112.10.36                                  #次上层ntp服务器
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
[root@ntpserver ~]#/etc/init.d/ntpd start && chkconfig ntpd on

C端:

192.168.1.9

[root@ntpclient ~]#yum install ntpdate -y &>/dev/null
[root@ntpclient ~]#ntpdate 192.168.1.9 && hwclock -w
[root@ntpclient ~]#echo '(* */1 * * * root /usr/sbin/ntpdate 192.168.1.193;/sbin/hwclock -w) &>/dev/null'>>/etc/crontab


你可能感兴趣的:(ntp,安装配置)