成都网站建设设计

将想法与焦点和您一起共享

linux命令ntpdc的简单介绍

Linux系统下的NTP配置

第一步,选择最好的NTP服务地址

永胜网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联公司从2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

具体命令为ntpdate -q IP地址或域名

广东地区NTP优选结果如下:

①time4.cloud.tencent点抗

②server time.asia.apple点抗

③server cn.ntp.org点吸烟

④server ntp.aliyun点抗

⑤server cn.pool.ntp.org

检查BIOS主板时间的命令

hwclock -r

NTP服务启停命令

sudo systemctl start/stop ntpd

检查查看ntp服务器有无和上层ntp连通

ntpstat

查看ntp服务器与上层ntp的状态

ntpq -pn

===server选项格式===

server host  [ key n ] [ version n ] [ prefer ] [ mode n ] [ minpoll n ] [ maxpoll n ] [ iburst ]

其中host是上层NTP服务器的IP地址或域名,随后所跟的参数解释如下所示:

◆ key: 表示所有发往服务器的报文包含有秘钥加密的认证信息,n是32位的整数,表示秘钥号。

◆ version: 表示发往上层服务器的报文使用的版本号,n默认是3,可以是1或者2。

◆ prefer: 如果有多个server选项,具有该参数的服务器优先使用。

◆ mode: 指定数据报文mode字段的值。

◆ minpoll: 指定与查询该服务器的最小时间间隔为2的n次方秒,n默认为6,范围为4-14。

◆ maxpoll:  指定与查询该服务器的最大时间间隔为2的n次方秒,n默认为10,范围为4-14。

◆ iburst: 当初始同步请求时,采用突发方式接连发送8个报文,时间间隔为2秒。

===同步硬件时钟===

ntp服务,默认只会同步系统时间。

如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件,

在/etc/sysconfig/ntpd文件中,添加【SYNC_HWCLOCK=yes】这样,就可以让硬件时间与系统时间一起同步。

允许BIOS与系统时间同步,也可以通过hwclock -w 命令。

hwclock命令用来查询和设置硬件时钟。

hwclock -r 读取并打印硬件时钟

hwclock -s 将硬件时钟同步到系统时钟

hwclock -w  将系统时钟同步到硬件时钟

系统时钟与硬件时钟

在Linux中有硬件时钟与系统时钟等两种时钟。硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS画面设定的时钟。系统时钟则是指kernel中的时钟。当Linux启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。所有Linux相关指令与函数都是读取系统时钟的设定。

参考文档:

Linux服务器NTP客户端配置——

NTP服务、客户端配置详解——

linux怎么添加ntp服务器

个人linux系统比如ubuntu、deepin等都已经安装了,只需要勾选同步网络时间即可。

如果是服务器可以参考:

[root@localhost /]# yum install ntp -y

2.修改NTP配置文件,添加NTP服务器的网络位置 /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 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 ::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 ().

server 192.168.1.1 iburst #目标服务器网络位置

#server 1.CentOS.pool.ntp.org iburst #一下三个是CentOS官方的NTP服务器,我们注释掉

#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

# Disable the monitoring facility to prevent amplification attacks using ntpdc

# monlist command when default restrict does not include the noquery flag. See

# CVE-2013-5211 for more details.

# Note: Monitoring will not be disabled with the limited restriction flag.

disable monitor

保存退出

3.启动服务并设置开启自启

[root@localhost /]# systemctl start ntpd.service#启动服务

[root@localhost /]# systemctl enable ntpd.service#设置为开机启动

linux时间同步命令

linux时间同步命令的方法:

可以使用ntpdate命令。ntpdate命令使用网络时间协议(NTP)设置日期和时间,通过轮询指定的确定正确时间的NTP服务器来设置本地日期和时间。它从指定的每个服务器获得了一些样本,并应用标准NTP时钟过滤器和选择算法来选择最好的样本。命令格式:ntpdate时间服务器。


网页名称:linux命令ntpdc的简单介绍
浏览路径:http://chengdu.cdxwcx.cn/article/ddjhhhc.html