时间服务器端口协议,ntp时间服务器

2023-05-16

前言

ntp(Network Time protocol)是网络时间协议,是用来使网络中的各个计算机时间同步的一种协议。

ntp配置

1)ntp是由ntp软件提供,如果没有可以使用yum进行安装

2)ntp配置文件介绍:/etc/ntp.conf

利用restrict来管理权限控制;语法格式:restrict IP mask MASK [parameter]

常用的parameter有以下几类:

ignore:拒绝所类型的ntp连接

nomodify:客户端只能通过此服务器进行时间同步;不能使用ntpc或ntpq这两种方式来修改时间;

noquery:不提供网络时间校验功能

notrap:不支持远程登录的时间戳

notust:拒绝认证不通过的客户端

注意:如果parameter没有任何参数,表示来接受自任何网络的时间同步请求

利用server定义上层ntp服务器;语法格式 server SERVER_IP [prefer];prefer表示首先使用此服务器地址

利用driftfile记录时间差异;默认记录位置是/var/lib/ntp/drift;

注意:若果要修改保存路径,要确保ntpd用户对目标文件有写入权限

利用key提高安全性;语法格式: key  key_file

3)配置实例:

# vim /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 \\拒绝所有ipv4用户

restrict -6 default kod nomodify notrap nopeer noquery \\拒绝所有ipv6用户

# 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  202.120.2.101  \\放行来自202.120.2.101地址进入本服务器

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

restrict 172.16.2.0 mask 255.255.255.0 nomodify \\放行本地局域网络进入本机

# 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  \\默认自带,注释掉

server 202.120.2.101 prefer   \\定义此服务器为首先使用的时间服务器

server s1b.time.edu.cn      \\定义备用的时间服务器

server s1c.time.edu.cn      \\定义备用的时间服务器

#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

4)启动ntpd服务;查看监听端口

# service ntpd start

#netstat -upln

Proto Recv-Q Send-Q Local Address   Foreign Address      State       PID/Program name

udp   0    0   172.16.2.13:123    0.0.0.0:*                        11303/ntpd

udp   0    0      0.0.0.0:123     0.0.0.0:*                 11303/ntpd

5)等待大约15分钟左右,使用ntpstat查看,自己定义的ntp服务器已经开始与网络时间服务器进行同步

# ntpstat

synchronised to NTP server (202.120.2.101) at stratum 4

time correct to within 176 ms

polling server every 64 s

6)  使用ntpq -p可以查看ntp服务器状态

# ntpq -p

remote          refid    st t when poll reach   delay   offset  jitter

==================================================================================================

*dns.sjtu.edu.cn 202.118.1.130 3  u  60  64  275   34.939   -5.211   4.329

ntpa.nic.edu.cn  .STEP.   16 u  -  1024   0    0.000    0.000   0.000

202.112.7.150   .STEP.   16 u  -  1024   0    0.000    0.000   0.000

remote: ntp服务器的上层服务器;如果前面有*代表是正在使用的ntp服务器,+代表ntp服务端已连接,可做为备用ntp服务器

refid:上层ntp服务器的校准服务器

st:NTP上层服务器的级别

when: 多少秒之前与上层服务器同步过时间

poll:多长时间之后与上层服务器再次进程同步时间

reach:已经向上层ntp服务器同步的次数

delay:时延;单位 10^(-3)秒

offset:时间补偿的结果;单位与 10^(-3)秒

jitter:linux系统时间与BIOS硬件的差异时间;单位与10^(-3)秒

详情请参考:http://linux.vbird.org/linux_server/0440ntp.php

原创文章,作者:马行空,如若转载,请注明出处:http://www.178linux.com/5569

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

时间服务器端口协议,ntp时间服务器 的相关文章

  • 授时服务器 微软,Windows10搭建NTP授时服务器

    1 先打开注册表 xff0c win 43 r 然后输入regedit 1 先打开注册表 xff0c win 43 r 然后输入 regedit2 打开注册表中 HKEY LOCAL MACHINE SYSTEM CurrentContro
  • Linux时间延迟平滑对时方案的分析-Ntp和Chrony的不同表现

    系列文章目录 文章目录 系列文章目录前言一 环境信息二 ntpd模式 2 1 版本信息2 2 配置ntpd对时源 2 2 1 配置ntpd服务配置 xff0c 启动ntpd服务2 3 2 查看对时情况2 3 配置ntpd客户端 2 3 1
  • centos6.7搭建局域网ntp服务器

    修改 etc ntp conf文件 restrict xxx nomodify notrap nopeer noquery xxx 此处配置本地IP地址 restrict 127 0 0 1 restrict xxx mask 255 25
  • Ubuntu20.04部署ntp服务

    1 前期准备 系统版本 ip地址 Ubuntu20 04镜像 服务端Ubuntu20 0410 1 0 55ubuntu 20 04 5 live server amd64客户端Ubuntu20 0410 1 0 56ubuntu 20 0
  • 配置NTP服务

    设置时区为 Asia Shanghai 设置时区 xff1a timedatectl set timezone Asia Shanghai 查看时区 xff1a timedatectl 有两种情况 一 外网环境 xff0c 向互联网的NTP
  • linux ntp时间立即同步命令_linux时间同步,ntpd、ntpdate

    linux时间同步 xff0c ntpd ntpdate 2010 10 13 09 01 02 阅读1043 评论0字号 xff1a 大中小订阅 在Windwos中 xff0c 系统时间的设置很简单 xff0c 界面操作 xff0c 通俗
  • NTP服务器

    1 NTP服务器 NTP协议是网络时间协议 Network Time Protocol xff0c 它是用来同步网络中各个计算机的时间的协议 它的用途是把计算机的时钟同步到世界协调时UTC xff0c 其精度在局域网内可达0 1ms xff
  • centos6.7搭建局域网ntp服务器

    修改 etc ntp conf文件 restrict xxx nomodify notrap nopeer noquery xxx 此处配置本地IP地址 restrict 127 0 0 1 restrict xxx mask 255 25
  • 云原生之使用docker部署NTP时间服务器

    云原生之使用docker部署NTP时间服务器 一 chrony介绍 二 容器镜像介绍 三 检查本地docker状态 四 下载ntp镜像 五 部署ntp服务器 1 创建ntp容器 2 查看ntp容器状态 六 检查ntp服务器的时间源 七 客户
  • Linux基础 - NTP时间同步

    博客主页 Passerby Wang的博客 CSDN博客 系统运维 云计算 Linux基础领域博主 所属专栏 Linux基础 上期文章 Linux基础 DNS服务进阶 如觉得博主文章写的不错或对你有所帮助的话 还望大家多多支持呀 关注 点赞
  • ntp服务器是什么,有什么用?

    https www idcbest com servernews 11002256 html ntp服务器隶属于小众时间频率行业 对于初次接触者和未涉猎此行业的人群来说 就会有很大的疑问 ntp服务器能做什么 为什么会需要ntp服务器 本文
  • 国内可用的ntp服务器地址

    ntp sjtu edu cn 202 120 2 101 上海交通大学网络中心NTP服务器地址 s1a time edu cn 北京邮电大学 s1b time edu cn 清华大学 s1c time edu cn 北京大学 s1d ti
  • centos 修改时间

    文章目录 centos 修改时间 1 查询时间常用命令 2 修改时区 3 修改时间 3 1 手动修改时间 3 2 联网修改时间 centos 修改时间 Centos系统时间分为系统时间和硬件时间 二者必须都修改 重启系统才会永久生效 背景
  • 如何以编程方式将 GPO 设置为未配置或禁用

    我正在寻找一种编程解决方案 其效果与在 GPOE 中设置 配置 Windows NTP 客户端 状态相同Administrative Templates gt System gt Windows Time Service gt Time P
  • 如何使用 C# 查询 NTP 服务器?

    我需要的只是一种使用 C 查询 NTP 服务器的方法 以获取返回的 NTP 服务器的日期时间string或作为DateTime 这怎么可能以最简单的形式实现呢 由于旧的接受答案已被删除 这是一个不再存在的 Google 代码搜索结果的链接
  • 将 Linux 系统时钟同步到 Windows NTP 服务

    我有一台 Linux PC 作为时钟客户端 我想使用 ntpdate 将此 PC 的时间与同一网络上同一空间中的 Windows PC 同步 我无法找到如何做到这一点 尽管我认为 Windows 时间服务是一个 NTP 服务器 但这并不像调
  • .Net API 获取互联网时间服务器的准确时间

    我需要知道是否存在任何 NET API 可以从 Internet 时间服务器获取当前时间 以便更改客户端的系统时间不会影响我的应用程序的完整性 你有几个选项 尽管没有内置的 http dotnet snippets com dns simp
  • iPhone 的网络时间协议

    我正在编写一个需要精确计时的应用程序 问完后这个问题 https stackoverflow com questions 2264197 how to accurately sync time between iphones 我决定使用 N
  • 如何用C语言将NTP时间转换为Unix纪元时间(Linux)

    几个月来我一直在尝试创建一个基于 SNTP 的简单客户端 服务器RFC5905 https www rfc editor org rfc rfc5905 最后我设法让它工作 至少我认为它工作正常 但是当我尝试针对真实的 NTP 服务器 例如
  • 为什么ntpd服务重启后没有自动启动? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我安装后ntpd via yum我运行命令systemctl enable ntpd service并重新启动计算机 得到 shell 提

随机推荐