linux 内网时间同步配置
在工作中,内网环境机器的时间会有所差异,在某些测试环境下需要一毫秒都不允许出现误差,但又不想同步外网时间,那我们可以选择一台机器作为时间服务器来供其他机器进行时间同步,例如每隔1分钟同步一次时间。
一、环境
系统:Centos 6.5
ntp_client IP:192.168.0.117
ntp_server IP:192.168.0.124
二、安装ntp服务
root@fenfa ~]# yum install ntp -y
[root@fenfa ~]# chkconfig --add ntpd
[root@fenfa ~]# chkconfig ntpd on
三、配置/etc/ntp.conf文件:
server:
[root@fenfa ~]# vim /etc/ntp.conf # For more information about this file, see the man pages
# ntp.conf(), ntp_acc(), ntp_auth(), ntp_clock(), ntp_misc(), ntp_mon(). 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 #默认的client拒绝所有的操作
restrict - 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 - :: # Hosts on local network are less restricted.
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap #允许集群192.1680.0网段连接同步时间,拒绝client修改服务器时间
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
22 #server 0.centos.pool.ntp.org iburst #默认配置,同步网络时间
23 #server 1.centos.pool.ntp.org iburst
24 #server 2.centos.pool.ntp.org iburst
25 #server 3.centos.pool.ntp.org iburst 27 server 127.127.1.0 #本地时间
28 fudge 127.127.1.0 stratum 1 #时间服务器的层次。设为0则为顶级 #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 # Specify the key identifier to use with the ntpdc utility.
#requestkey # Specify the key identifier to use with the ntpq utility.
#controlkey # Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
注:红色字体的地方为新增或修改的部分
client:
[root@nfs ~]# vim /etc/ntp.conf # For more information about this file, see the man pages
# ntp.conf(), ntp_acc(), ntp_auth(), ntp_clock(), ntp_misc(), ntp_mon(). 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 - 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 - :: # Hosts on local network are less restricted.
restrict 192.168.0.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 .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst server 192.168.0.124 profer #时间服务器地址
#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 # Specify the key identifier to use with the ntpdc utility.
#requestkey # Specify the key identifier to use with the ntpq utility.
#controlkey # Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstat
四、设置client主机与时间服务器时间的同步
- serverd端从启ntp服务
- client端更改系统时间
- 执行同步命令:ntpdate -u 192.168.0.124
[root@fenfa x86_64]# service ntpd restart
关闭 ntpd: [确定]
正在启动 ntpd: [确定]
[root@nfs ~]# date
2019年 08月 19日 星期一 :: CST
[root@nfs ~]# date -s --
2018年 08月 19日 星期日 :: CST
[root@nfs ~]# date
2018年 08月 19日 星期日 :: CST
[root@nfs ~]# ntpdate -u 192.168.0.124
Aug :: ntpdate[]: step time server 192.168.0.124 offset 31614767.907398 sec
[root@nfs ~]# date
2019年 08月 19日 星期一 :: CST
可以在client机器上编写一个定时脚本:
[root@nfs ~]# crontab -l
####ntpd Synchronize every minute
-/ * * * * /usr/sbin/ntpdate -u 192.168.0.124 >/dev/null >&
修改/etc/ntp/stpe-tickers文件,内容如下(当ntpd服务启动时,会自动与该文件中记录的上层NTP服务进行时间校对
[root@nfs ~]# cat /etc/ntp/step-tickers
# List of servers used for initial synchronization.
server 192.168.0.124 prefer
ntp服务,默认只会同步系统时间。如果想要让ntp同时同步硬件时间,可以设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样,就可以让硬件时间与系统时间一起同步。
linux 内网时间同步配置的更多相关文章
- Linux内网渗透
Linux虽然没有域环境,但是当我们拿到一台Linux 系统权限,难道只进行一下提权,捕获一下敏感信息就结束了吗?显然不只是这样的.本片文章将从拿到一个Linux shell开始,介绍Linux内网渗 ...
- FtpServer穿透内网访问配置踩笔记
FtpServer穿透内网访问配置踩笔记 引言 FtpServer是服务器文件远程管理常用方式. 以前在局域网配置Ftp服务器以及使用公网上的Ftp服务均未碰到问题,固未对Ftp传输进行深入了解. 然 ...
- Linux内网时钟同步问题(ntp和chrony)
我们都知道时钟同步可以使用外网服务器,在内网内不能连接外网的时候也需要时钟同步,那怎么进行呢? 选择内网的一台稳定的服务器作为时钟源,然后让其他机器都来同步这台机器即可. 注:其实ntp服务和chro ...
- Linux内网环境DNS修改域名指向,JAVA应用程序能否实时切换的问题总结
公司内网环境中许多调用资源(数据库.web接口等)都是通过内网DNS服务来进行域名-IP的映射. 但经常出现DNS映射修改完毕后,应用中连接的资源迟迟没有变更. 以前一直笼统的认为是linux的dns ...
- 记录一次坎坷的linux内网渗透过程瞎折腾的坑
版权声明:本文为博主的原创文章,未经博主同意不得转载. 写在前面 每个人都有自己的思路和技巧,以前遇到一些linux的环境.这次找来一个站点来进行内网,写下自己的想法 目标环境 1.linux 2. ...
- 配置B类内网 和 配置A类内网
首先 A 类网 对应的 子网掩码是255.0.0.0 B 类网 对应的 子网掩码是255.255.0.0 C 类网 对应的 子网掩码是255.255.255.0 一般来说 10 开头的都是 A 类网 ...
- CentOS7设置内网时间同步
1.yum 安装 NTP服务器 [root@master ~]# yum -y install ntp 2.启动ntpd服务 [root@master ~]# systemctl start ntpd ...
- linux内网机器访问外网代理设置squid
公司一般出于安全考虑, 在同一局域网中只有一台机器可以访问外网,运维进行了整体的限制, 但是在后面的工作中,需要在机器上安装一些软件,及命令,所以其他的机器需要访问外网来简化工作, 但又不能打乱原有运 ...
- frp内网穿透配置
frps配置 --------------------------------------------------------------------------------------------- ...
随机推荐
- ARM USB 通信(转)
ARM USB 通信 采用ZLG的动态链接库,动态装载. ARM是Context-M3-1343. 在C++ Builder 6 中开发的上位机通信软件. USB通信代码如下: //--------- ...
- Python - Django - AJAX 实现 POST 请求
index.html: <input type="text" id="i1">+ <input type="text" i ...
- [转]npm 遇到 write access的问题怎么办
ubuntu下使用 npm install -g 可能会遇到这个问题. 链接地址:https://www.jianshu.com/p/31744aa44824
- LODOP条码二维码简短问答及相关博文
LODOP如何输出条码 条码输出 参考样例11 http://www.c-lodop.com/demolist/PrintSample11.html超文本表格中的条码参考样例47 http://www ...
- SpringBoot 跨域 Access-Control-Allow-Origin
跨域(CORS)是指不同域名之间相互访问. 跨域,指的是浏览器不能执行其他网站的脚本,它是由浏览器的同源策略所造成的,是浏览器对于JavaScript所定义的安全限制策略. 只要协议,子域名,主域名, ...
- 基于thinkphp5框架做一个可以区别开发、测试、生产三种环境的配置加载
在日常的开发测试中我们经常会遇到本地开发和测试或者线上配置参数不同的场景,必要你要是使用一个三方的支付,它的本地测试和线上的key值或者账号存在不同.最基本的做法是本地用测试参数,提交到测试的时候再改 ...
- QT QML 在qml中自定义信号
服从真理,就能征服一切事物. -- 塞涅卡 实例: 自定义文件 MoveYou.qml: import QtQuick 2.5 import QtQuick.Controls 1.4 import Q ...
- Word样式教程
目录 写在前面 样式可以解决什么问题? 本文适合于 快速入门 一切皆样式 样式与格式的关系 如何修改样式 建立新的样式 样式的匹配和更新 根据样式更新所选段落 根据所选段落更新样式 小结 进一步了解 ...
- 最简单的Python3多线程实现
最简单的实现了一下Python的多线程: import threading def write_dbs(i): print(i) if __name__ == '__main__': for i in ...
- 谈nginx配置
近日看<许式伟的架构课>中一段关于系统分解的描述所有思考,略记于此. 原文片段如下: 系统设计,简单来说就是 "对系统进行分解" 的能力.这个阶段核心要干的事情,就是明 ...