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

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

在公司内网搭建一台ntp时间服务器,供局域网内所有机器平滑同步时间

公司局域网无法连接internet

概念:NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议。

资源:

时间服务器IP:192.168.138.140(ntp server)

需要同步时间的服务器:192.168.138.136 (ntp client)

linux 系统:CentOS release 6.9

配置ntp server

打开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 noquery
restrict -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.1
restrict -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 iburst百思特网
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 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.
#crypto
includefile /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 noquery
restrict -6 default kod nomodify notrap nopeer noquery

上面是配置的说明,下面是配置项,这部分的配置是对客户端(需要同步时间的服务器)的请求的处理策略,默认是拒绝。有-6的那一行是对ipv6的配置。可选的配置如下:

ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能修改服务端的时间参数,但客户端可以同步时间。
notrust :拒绝没有通过认证的客户端机器
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :不提供trap远端登陆
nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟
kod : 访问违规时发送 KoD 包。

把这两行注释掉,然后配置允许哪些机器可以跟ntp server同步时间

可以配置具体的机器,如:

restrict 192.168.138.136 nomodify

可以配置网段,如:mask配置子网掩码

restrict 192.168.0.0 mask 225.225.225.0 nomodify

配置时间源

如果可以连接internet,可以配置internet上的时间源,internet上的ntp服务器有很多,可以去搜一下。

如果不能连接internet,则把本机作为时间源即可,配置如下:

server 127.127.1.0
fudge 127.127.1.0 stratum 10

时间源可以配置多个,先使用最上面的机器,如果这个机器不可用(比如网络连不上),则会逐下使用。

启动或重启ntp服务

查看ntp服务运百思特网行状态:

/etc/init.d/ntpd status

启动ntp服务

/etc/init.d/ntpd start

客户端同步时间

使用ntpdate命令同步时间,ntpdate ntp_server_ip

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时间服务器

版权声明:本文图片和内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送联系客服 举报,一经查实,本站将立刻删除,请注明出处:https://www.4kpp.com/3612.html

(0)
漫空客漫空客
上一篇 2023年4月23日
下一篇 2023年4月23日

相关推荐

  • ps图片大小怎么调整(适合ps的新手做的图)

    Photoshop简称PS,是我们日常办公中必备软件,虽然大部分用户不可能达到专业设计的程度,但日常的污点修复、尺寸修改和格式转换等技能几乎人人必备。不久前笔者在转换图片的时候本意…

    2023年4月23日
    2450
  • 游戏笔记本推荐榜的简单介绍

    今天就给大家介绍一下游戏笔记本的推荐清单以及相应的知识点。希望对你有帮助,也别忘了收藏这个站点。 游戏笔记本性价比排名2022 1.预兆暗影精灵8 预兆暗影精灵8沿用了之前非常成熟…

    投稿 2023年4月23日
    1460
  • 动量和动量定理(高中物理74个二级结论)

    动量和百思特网动量定理百思特网(高中物理7百思特网4个二级结论)

    2023年4月22日
    1000
  • 辽阔无垠的意思(辽阔无垠的意思和无边无垠中的垠意思一样吗)

    今天我就来介绍一下浩瀚的含义以及相应的知识点。希望对你有帮助,也别忘了收藏这个站点。 你说巨大是什么意思? 浩瀚【拼音】:Liáoku wúyín【词性】:中性词浩瀚到看不到边界。…

    投稿 2023年4月23日
    1450
  • 航速一节是多少(航速一节是多少公里)

    今天小编给各位分享航速一节是多少(航速一节是多少公里),如果能碰巧解决你现在面临的问题,别忘了关注小站,我们一起开始吧! 每小时的速度是多少? 这艘船的速度等于每小时1.852公里…

    投稿 2023年4月23日
    2070
  • 欲如潮水(欲如水不遏则滔天什么意思)

    今天给大家介绍一下什么叫如潮,什么叫如潮对应的知识点。希望对你有帮助,也别忘了收藏这个站点。 “思念如潮”是什么意思? “思念如潮”是指在一些外界因素的干扰下,导致思念的情绪像潮水…

    投稿 2023年4月23日
    1110
  • 新政府会计制度对事业单位财务核算的影响(双原则)

    但是传统的财务会计制度已经不能适应实行“双原则”后事业单位发展的需要,因此,审计师应从公共机构财务核算中汲取经验。在预算管理中,会计分录和财务报表能清晰而全面地反映预算管理中的所有…

    投稿 2023年4月23日
    1260
  • 我国海拔最低的湖(我国海拔最低的湖在哪)

    今天小编给各位分享我国海拔更低的湖(我国海拔更低的湖在哪),如果能碰巧解决你现在面临的问题,别忘了关注小站,我们一起开始吧! 世界上更低的湖是什么湖? 扩展信息 死海不仅是更低的湖…

    投稿 2023年4月23日
    1670
  • 路虎是哪个国家的(路虎是印度还是英国的)

    你知道路虎是哪国车吗?我们就来分享一下。 路虎是印度Tata集团旗下的品牌。路虎最早英国罗孚汽车公司一个汽车品牌,但整体表现不怎么好,中间被宝马接手过一段时间,但不久就转手卖给了美…

    2023年4月23日
    850
  • 女性吃石榴对子宫好处

    今天给大家分享一个关于石榴对女性子宫好处的问题。以下是这个问题的总结。让我们来看看。 石榴对女性子宫的好处。 石榴是一种营养丰富的水果。它的黄红色果实鲜艳美丽,富含维生素和矿物质,…

    投稿 2023年4月23日
    980

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注