• 服务器端配置
    • 允许这些IP向自己同步时间

      restrict x.x.x.x mask x.x.x.x nomodiy notrap

    • 当前定义的所有server服务器无法同步后,和自身同步

server 127.127.1.0

fudge 127.127.1.0 stratum 10

  • 局域网内的上层时间服务器

    server 192.168.1.117

  • 客户端配置

    创建自动任务计划

    crontab -e

    * 2 * * * /usr/sbin/ntpdate 192.168.x.x

    #分 时 日 月 星期 命令位置

  • 故障排除
    • 故障信息:

      #[root@localhost ~]# ntpdate 192.168.70.52

      #27 Sep 05:22:11 ntpdate[2392]: no server suitable for synchronization found

    • 防火墙问题

    • NTP服务器和/etc/ntp.conf

    • 3.3.bug版本

  • 配置说明
    • Linux默认的/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 #系统时间与BlOS时间的偏差记录

# 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.rhel.pool.ntp.org iburst #互联网时间服务器地址

server 1.rhel.pool.ntp.org iburst

server 2.rhel.pool.ntp.org iburst

server 3.rhel.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

  • restrict 命令说明

#restrict 控制相关权限---语法为: restrict IP地址 mask 子网掩码 参数

其中IP地址也可以是default ,default 就是指所有的IP

参数有以下几个:

ignore :关闭所有的 NTP 联机服务

nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。

notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网

noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器

notrap :不提供trap远端登陆:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。

nopeer :用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟

kod : 访问违规时发送 KoD 包。

restrict -6 表示IPV6地址的权限设置。

Linux_NTP的更多相关文章

随机推荐

  1. Navigation DialogFragment展示dialog

    如果按照一般fragment的写法: 在nav_config中 <fragment android:id="@+id/fragment_crime_detail" andro ...

  2. 行者APP适配国外环境问题解决

    (本文1151字,阅读约5分钟) 玩骑行的同伴都知道,长途骑行,第一需要好的硬件,如大腿发动机.车子.装备等:二是需要好的软件,如意志.有氧能力.骑行app等. 到雅加达后,才发现在国内用了几年的黑鸟 ...

  3. C# 移除字符串头尾指定字符

    1 private void button1_Click(object sender, EventArgs e) 2 {//去掉字符串头尾指定字符 3 string MyInfo= "--中 ...

  4. 重新整理 .net core 实践篇—————3种配置验证[十四]

    前言 简单整理一些配置的验证. 正文 配置的验证大概分为3类: 直接注册验证函数 实现IValidteOptions 使用Microsoft.Extensions.Options.DataAnnota ...

  5. 从C到C++过渡的3个原因

    从C到C++过渡的3个原因 3 reasons to transition from C to C++ 几十年来,嵌入式软件工程师们一直在争论他们是否应该使用C或C++.根据2019年嵌入式市场调查, ...

  6. 工作流中容器化的依赖注入!Activiti集成CDI实现工作流的可配置型和可扩展型

    Activiti工作流集成CDI简介 activiti-cdi模块提供activiti的可配置型和cdi扩展 activiti-cdi的特性: 支持 @BusinessProcessScoped be ...

  7. 前端 JS 之 AJAX 简介及使用

    概述 AJAX 是一个缩写,它的全名是 Asynchronous JavaScript and XML,意思就是异步 JavaScript 和 XML,即用JavaScript执行异步网络请求. AJ ...

  8. jdk,jre.jvm三者的关系

    jdk>jre>jvm jdk=jre+java的开发工具(包括java.exe,javac.exe.javadoc.exe) jre=jvm+java核心类库

  9. .NET Core/.NET5/.NET6 开源项目汇总1:常用必备组件

    系列目录     [已更新最新开发文章,点击查看详细] 开源项目是众多组织与个人分享的组件或项目,作者付出的心血我们是无法体会的,所以首先大家要心存感激.尊重.请严格遵守每个项目的开源协议后再使用.尊 ...

  10. 『言善信』Fiddler工具 — 16、使用Fiddler抓取移动端App请求

    目录 1.抓取Android移动端App请求 2.抓取IOS移动端App请求 3.总结: 1.抓取Android移动端App请求 前提: 因为Fiddler抓包的原理就是通过代理,所以确保被测终端要和 ...