CentOS7 NTP服务器搭建,服务端地址172.19.44.7 客户端地址172.19.44.8
NTP服务端
安装
rpm -q ntp yum install -y ntp
配置
vim /etc/ntp.conf 添加NTP日志文件 # NTP logfile logfile /var/log/ntpd.log 授权仅172.19.44.0网段同步时间 restrict 172.19.44.0 mask 255.255.255.0 nomodify notrap 注释掉原有系统自带NTP服务器地址 #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst 添加亚洲NTP服务器地址 server 0.asia.pool.ntp.org iburst server 1.asia.pool.ntp.org iburst server 2.asia.pool.ntp.org iburst server 3.asia.pool.ntp.org iburst 添加字段,当外部时间不可用时,使用本地时间 server 172.19.44.7 iburst fudge 127.0.0.1 stratum 10 添加字段,允许NTP服务器自动修改本机时间 restrict 0.asia.pool.ntp.org nomodify notrap noquery restrict 1.asia.pool.ntp.org nomodify notrap noquery restrict 2.asia.pool.ntp.org nomodify notrap noquery
开启服务
systemctl enable ntpd systemctl enable ntpdate systemctl is-enabled ntpd
开启同步
ntpdate -u 1.asia.pool.ntp.org systemctl start ntpdate systemctl start ntpd
写入硬件时间
ss -tlunp | grep ntp ntpq -p hwclock -w
NTP客户端
安装
yum install -y ntp
配置
vim /etc/ntp.conf 添加 server 172.19.44.7
systemctl restart ntpd systemctl enable ntpd.service crontab -e 添加 0 0 * * * /usr/sbin/sntp -P no -r 172.19.44.7;hwclock -w
ntpq -p
更新日期: 2019年03月26日
文章标签: Linux
文章链接: https://www.vos.cn/os/292.html
版权说明:如非注明,本站文章均为vOS原创,转载请注明出处和附带本文链接。
文章标签: Linux
文章链接: https://www.vos.cn/os/292.html
版权说明:如非注明,本站文章均为vOS原创,转载请注明出处和附带本文链接。