ntpd服务器搭建

670阅读 0评论2018-11-29 sxm5211258
分类:系统运维

一、服务端配置192.168.199.125:

点击(此处)折叠或打开

  1. NTP服务器监听端口为UDP的123,需要在本地防火墙开启运行客户端访问123端口;
  2. echo '-A INPUT -m state --state NEW -m udp -p udp --deport 123 -j ACCEPT'>> /etc/sysconfig/iptables
  3. ntp服务安装与配置
  4. yum install ntp ntpdate -y
  5. /etc/init.d/ntpd restart
  6. 同步nptd时间服务器时间
  7. ntpd -p
  8. 同步/etc/ntp.conf中的外网时间服务器
  9. /etc/init.d/ntpd stop
  10. ntpdate pool.ntp.org
  11. 29 Nov 01:42:23 ntpdate[2115]: adjust time server 85.199.214.101 offset 0.015287 sec

二、客户端配置:

点击(此处)折叠或打开

  1. #安装ntpdate
  2. yum -y install ntp
  3. #编辑计划任务
  4. crontab -e
  5. 0 0 * * * /usr/sbin/ntpdate 192.168.199.125 >>/var/log/ntpstats/ntp.log 2>&1
  6. #编辑/etc/ntp.conf配置
  7. vim /etc/ntp.conf
  8. driftfile /var/lib/ntp/drift
  9. restrict default kod nomodify notrap nopeer noquery
  10. restrict -6 default kod nomodify notrap nopeer noquery
  11. #开启内部递归网络接口lo
  12. restrict 127.0.0.1
  13. restrict -6 ::1
  14. #上级时间服务器
  15. server 192.168.199.125
  16. fudge 192.168.199.125 stratum 10
  17. includefile /etc/ntp/crypto/pw
  18. keys /etc/ntp/keys

  1. ntpdate 192.168.199.125
  2. 29 Nov 01:42:23 ntpdate[2115]: adjust time server 85.199.214.101 offset 0.015287 sec

上一篇:python管理mysql
下一篇:LAMP+Discuz搭建论坛