局域网内配置NTP时钟服务
| 用途 | IP地址 | 系统版本 |
| NTP server | 192.168.78.119 | redhat6.10 |
| NTP client | 192.168.78.120 | redhat6.10 |
| NTP client | 192.168.78.121 | redhat6.10 |
1,server端验证NTP是否已安装
#rpm -qa ntp*ntpdate-4.2.6p5-12.el6_9.2.x86_64ntp-4.2.6p5-12.el6_9.2.x86_64如果没有安装,可以使用rpm或者yum进行安装
2,server端配置ntp.conf文件,添加以下内容
#vi etc/ntp.confserver 127.127.1.0 #local clockfudge 127.127.1.0 stratum 10retrict 192.168.78.120 mask 255.255.255.0 nomodifyretrict 192.168.78.121 mask 255.255.255.0 nomodify注释:如果在不连接上层服务器的情况(即以此台服务器192.168.78.119用做局域网内部时钟服务),需要添加server 127.127.1.0和fudge 127.127.1.0 stratum 10这个配置是让NTP server以自己为上层服务器,内网环境可以选择这样配置)
3,server端启动ntp服务
#service ntpd start查看ntp状态# ntpstatsynchronised to local net at stratum 11time correct to within 11 mspolling server every 64 s# ntpq -premote refid st t when poll reach delay offset jitter==============================================================================*LOCAL(0) .LOCL. 10 l 17 64 377 0.000 0.000 0.000
4,server端设置开机自启动
#chkconfig ntpd on
5,客户端配置(客户端地址为192.168.78.120/192.168.78.121)
# crontab -l*/5 * * * * /usr/sbin/ntpdate 192.168.78.1170 0 * * * usr/sbin/hwclock -w*/5表示每5分钟同步一次时间
参数详解:# vi /etc/ntp.conf#系统时间与BIOS事件的偏差记录driftfile /var/lib/ntp/driftrestrict default kod nomodify notrap nopeer noquery # 拒绝所有IPv4的client连接此NTP服务器restrict -6 default kod nomodify notrap nopeer noquery # 拒绝所有IPv6的client连接此NTP服务器restrict 127.0.0.1 # 放行本机localhost对NTP服务的访问restrict -6 ::1# Hosts on local network are less restricted.#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # 放行192.168.1.0网段主机与NTP服务器进行时间同步# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).server 0.centos.pool.ntp.org iburst # 代表的同步时间服务器server 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst#broadcast 192.168.1.255 autokey # broadcast server#broadcastclient # broadcast client#broadcast 224.0.1.1 autokey # multicast server#multicastclient 224.0.1.1 # multicast client#manycastserver 239.255.254.254 # manycast server#manycastclient 239.255.254.254 autokey # manycast client# Enable public key cryptography.#cryptoincludefile /etc/ntp/crypto/pw# Key file containing the keys and key identifiers used when operating# with symmetric key cryptography.keys /etc/ntp/keys
文章转载自数据管理员,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




