1.安装ntp服务
    首先检查是否已安装ntp服务,如果未安装,请先安装;可以使用命令安装或者使用源码编译安装,我是使用源码编译安装的;
    检查安装命令:rpm –qa | grep ntp
    安装命令:apt-get install ntp

源码编译:

首先进入源码目录

./configure
--prefix=/usr \
--bindir=/usr/sbin \
--sysconfdir=/etc \
--enable-linuxcaps \
--with-lineeditlibs=readline \
--enable-all-clocks \
--enable-parse-clocks \
--enable-clockctlmake
make install

2.配置/etc/ntp.conf

2.1时间服务器配置
    配置网络ntp服务器地址使用server关键字,格式:server [ip or hostname] [options...],在server后面写服务器地址(可以使IP或主机名),options这里最长使用的prefer,表示优先使用的服务器。
    
    一定要记得配置下面2行,意思是无法链接网络服务器的情况下,使用本地时间作为时间源

server 127.127.1.0
fudge 127.127.1.0 stratum 6

2.1权限配置
    权限配置使用restrict关键字,格式:restrict [address] mask [mask] [parameter]
    其中parameter的参数主要有:
    ignore:拒绝所有类型的ntp连接
    nomodify:客户端不能使用ntpc与ntpq两支程式来修改服务器的时间参数
    noquery:客户端不能使用ntpq、ntpc等指令来查询服务器时间,等于不提供ntp的网络校时
    notrap:不提供trap这个远程时间登录的功能
    notrust:拒绝没有认证的客户端,要注意,4.2版本以后的ntp不能添加此选项,否则对时会出现no data错误
    nopeer:不与其他同一层的ntp服务器进行时间同步

limited:限制对时频率

一般使用默认配置,不用修改
    
3.启动ntp服务

service ntp start
service ntp restart
service ntp stop

启动后需要过5分钟左右才能正常对时,刚开始会报错
    
4.测试

 ntpdate -d 127.0.0.1

5.附ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for helpdriftfile /var/lib/ntp/ntp.drift# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example
server 127.127.1.0
fudge 127.127.1.0 stratum 8# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#pool 0.debian.pool.ntp.org iburst
#pool 1.debian.pool.ntp.org iburst
#pool 2.debian.pool.ntp.org iburst
#pool 3.debian.pool.ntp.org iburst# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1# Needed for adding pool entries
restrict source notrap nomodify noquery# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

linux下ntp服务配置相关推荐

  1. Linux下LAMP服务配置

    1. httpd-2.2.6.tar.gz  2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 这个版本是已编译好的压缩包,解压后稍做配置即可使用 )  3. p ...

  2. Linux关ntp服务,linux下NTP服务

    1. NTP安装 搭建环境两台redhat6.5主机,通过网络10.83.250.0/23连接互通, server 10.83.250.5 client 10.83.250.4 查询NTP安装版本状态 ...

  3. linux下Samba服务配置

    SMB是基于客户机/服务器型的协议,因而一台Samba服务器既可以充当文件共享服务器,也可以充当一个Samba的客户端,例如,一台在Linux 下已经架设好的Samba服务器,windows客户端就可 ...

  4. Linux下rsh服务配置

    1. rsh和ssh的区别 rsh和ssh它俩之间的区别就是:ssh是使用密钥加密从而实现无密码登录的,具体来说就是在A主机生成一对密钥对,即公钥和私钥,我把公钥传递给B,然后等A链接B的时候,B会随 ...

  5. linux查看nfs服务状态,Linux下NFS服务配置

    NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源.在NFS的应用中,本地NFS的客户端应用可 ...

  6. linux设置ntp后不生效,Linux时间设置与NTP服务配置

    第一部分:时间设置 一.时间和时区 格林威治时间(GMT),是0时区时间.计算机中是UTC.它是Coordinated Universal Time的简写.虽然UTC和GMT的值相等(误差相当之小), ...

  7. linux下启动nfs服务,linux下Samba服务和NFS服务配置的方法

    linux下Samba服务和NFS服务配置 一.Samba服务配置过程 samba的功能很简单,就是为了使linux和windows之间能够实现共享.并且利用samba搭建文件服务器,不仅比windo ...

  8. Linux下DHCP服务的配置相关参数说明

    Linux下DHCP服务的配置相关参数说明 DHCP配置通常包括三部分:parameters.declarations.option. 1. parameters parameters用于说明DHCP ...

  9. linux svn配置提交输入备注,linux下svn服务强制添加备注(注释)提交

    标签: linux下svn服务强制添加备注(注释)提交 Linux版本: line-height: 26px; white-space: normal; background-color: rgb(2 ...

  10. Linux下环境变量配置方法梳理(.bash_profile和.bashrc的区别)

    博客园 首页 新随笔 联系 管理 订阅 <div class="blogStats"><!--done--> 随笔- 556  文章- 38  评论- 77 ...

最新文章

  1. iOS定义静态变量、静态常量、全局变量
  2. python lambda ,map详解
  3. c99变长数组_你学过数组,那你知道柔性数组吗?
  4. 主流路由器固件dd-wrt,tomato,openwrt对比介绍
  5. 数据库-优化-每个字段的说明
  6. python网易云_用python爬虫爬取网易云音乐
  7. 分享我们承建的三篇NAR的数据库
  8. Linux环境下查看IP不显示IPv4地址
  9. git教程(二)--安装和配置git
  10. .Net Mvc Automated Migration 数据迁移
  11. 接口自动化-get/post接口详解
  12. 计算机文化基础(高职高专版 第十一版)第二章答案
  13. 如何让局域网中的其他主机访问虚拟机
  14. c++逆天改命进阶--多态
  15. NEXT社区小课堂 | 第四课:dBFT 2.0详解 | 委托拜占庭容错:技术细节、挑战和前景...
  16. kali安装openvas全过程
  17. MySQL中函数field()的用法
  18. SpringCloud分布式框架
  19. 【SVN】——svn协议和http协议
  20. jquery 简单应用 取出最后一个td tr

热门文章

  1. 创建包含法定节假日、工作日、周末的日历表(mysql、oracle通用)
  2. 您该选择PRINCE2 还是 PMP认证
  3. RadASM 颜色配置
  4. JUnit 5预期异常
  5. 红米note2移动4g在哪里显示无服务器,小米 红米note2(移动版) 解锁教程
  6. cad编程c语言,基于C.NET的AutoCAD二次开发简版.pdf
  7. zktime 协议_中控考勤机对接信呼帮助(中控ZKTime5.0系统软件版)
  8. 塔菲克蓝牙适配器驱动_TAFIQ蓝牙适配器4.0驱动下载
  9. 阿里icon图标库使用说明
  10. [信号]预加重与去加重--转