内网搭建一台NTP时间服务器 时间服务器ip


内网搭建一台NTP时间服务器 时间服务器ip

文章插图
时间服务器ip(在intranet中设置NTP时间服务器)
在公司内网设置一个ntp时间服务器,让内网所有机器都能顺利同步时间 。
公司局域网无法连接到互联网 。
概念:NTP是网络时间协议,是用来同步网络中计算机时间的协议 。
资源:
服务器IP:192.168.138.140(ntp服务器)
需要同步时间的服务器:192.168.138.136 (ntp客户端)
Linux系统:CentOS版本6.9
配置ntp服务器信息资源网络
打开192.168.138.140机器的/etc/ntp.conf 。
该文件的内容如下:
# For more information about this file, see the man pages# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).driftfile /var信息资源网/lib/ntp/drift# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.restrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noquery# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.restrict 127.0.0.1restrict -6 ::1# Hosts on local network are less restricted.#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap# 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 iburstserver 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 2信息资源网24.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# Specify the key identifiers which are trusted.#trustedkey 4 8 42# Specify the key identifier to use with the ntpdc utility.#requestkey 8# Specify the key identifier to use with the ntpq utility.#controlkey 8# Enable writing of statistics records.#statistics clockstats cryptostats loopstats peerstats配置权限
在文档中
# Permit time synchronization with our time source, but do not# permit the source to query or modify the service on this system.restrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noquery以上是配置的描述,以下是配置项 。这一部分的配置是对来自客户端(需要同步时间的服务器)的请求的处理策略,默认是拒绝 。带-6的那一行是ipv6的配置 。可选配置如下:
ignore :关闭所有的 NTP 联机服务nomodify:客户端不能修改服务端的时间参数,但客户端可以同步时间 。notrust :拒绝没有通过认证的客户端机器noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器notrap :不提供trap远端登陆nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟kod : 访问违规时发送 KoD 包 。注释掉这两行,然后配置允许哪些机器与ntp服务器同步时间 。
您可以配置特定的机器,例如:
restrict 192.168.138.136 nomodify您可以配置网段,如mask来配置子网掩码 。
restrict 192.168.0.0 mask 225.225.225.0 nomodify配置时间源
如果您可以连接到互联网,则可以在互联网上配置时间源 。网上有很多ntp服务器,可以搜一下 。
如果不能联网,就用本机做时间源,配置如下:
server 127.127.1.0fudge 127.127.1.0 stratum 10可以配置多个时间源 。第一,用顶机 。如果这台机器不可用(比如网络连不上),就一个一个用 。
或者重新启动ntp服务 。
检查ntp服务运行状态:
/etc/init.d/ntpd status启动ntp服务
/etc/init.d/ntpd start客户端同步时间
使用ntpdate命令同步时间
ntpdate 192.168.138.140在linux系统上,客户端的ntp服务不能启动,否则会报错:
ntpdate[88383]: the NTP socket is in use , exiting停止ntp服务
/etc/init.d/ntpd stop如果希望每隔一段时间同步一次时间,可以配置crontab计划任务,比如每小时检查一次时间 。
* */1 * * * root /usr/sbin/ntpdate 192.168.138.140 >/dev/null 2>&1注意事项:
注意防火墙的问题,不能同步就检查防火墙 。
【内网搭建一台NTP时间服务器 时间服务器ip】
简谱吧


    推荐阅读