feora12 上配置NTP服务器

feora12 上配置NTP服务器

有时候应用软件客户端和服务器端时间不一致,导致客户端无法登陆情况的发生,也会出现其它一些问题。为此有时候我们需要架设内部的时间服务器。

如下图就是因为client端和server端时间不一致,导致无法登陆系统的情况

 

在Linux下架设NTP服务器,需要了解一些相关基础知识,以及会问一些常见问题

Server端和网络标准时间如何同步
Client端和Server端时间如何同步

 

大概流程如下

1.主机启用服务
2.Client向NTP Server发送调校时间的请求
3.NTP Server 发送当前时间给Client
4.Client根据发送来的时间调整自己的系统时间

 

在Linux下系统时间与硬件时间(BIOS)不一样,Server端ntpd与ntpdate不能同时启用。需要使用计划进行定期的同步。

 

本机10.1.18.34 为10.0.0.0  255.255.255.0网段 提供时间服务

 

安装

yum install 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 kod nomodify notrap nopeer noquery   //关于权限问题
//restrict -6 default kod nomodify notrap nopeer noquery
//nomodify :用户端不能更改NTP的时间参数,用户端不能使用ntpc,ntpq 修改服务器。但可以连接来进行时间校验
//notrap :不提供trap远程登录的功能
//noquery:不提供NTP网络校时
# 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
restrict server 0.fedora.pool.ntp.org
restrict server 1.fedora.pool.ntp.org
restrict server 2.fedora.pool.ntp.org
restrict 10.0.0.0 mask 255.255.255.0 nomodify

# 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).
//Fedora12 默认的网络服务器

server 0.fedora.pool.ntp.org
server 1.fedora.pool.ntp.org
server 2.fedora.pool.ntp.org

#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

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0     # local clock
fudge  127.127.1.0 stratum 10

# 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

修改/etc/sysconfig/ntpd 文件使BIOS时间也改变
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
SYNC_HWCLOCK=yes 这一行是自己添加的

 

重新启动NTP服务器

service ntpd restart

 

 

查看是否UDP 端口123打开

[root@linux etc]#netstat -tlunp                    

udp        0      0 ::1:123                     :::*                                    3455/ntpd
udp        0      0 :::123                      :::*                                    3455/ntpd

检测是否和上层NTP服务器连线
[root@linux etc]# ntpstat
synchronised to NTP server (218.75.4.130) at stratum 11
   time correct to within 949 ms
   polling server every 64 s

 

显示NTP与上层NTP的状态
[root@linux etc]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+211.160.78.27   158.43.128.66    3 u    1   64  377   79.118    4.097   2.386
+221.7.129.79    200.54.149.19    2 u    1   64  377  205.727   27.609   0.726
*218.75.4.130    216.218.192.202  2 u    1   64  377   15.291  -17.356   0.920
 LOCAL(0)        .LOCL.          10 l   61   64  377    0.000    0.000   0.002

 

 在Linux上防火墙上开启端口123,协议UPD

 

windows 客户端设置

图解如下

 

 

 

修改默认的校验时间

Windwos 2000 和XP,系统默认时间同步间隔是7天,可以通过修改注册表来修改间隔的
同步时间:
开始-》运行-》Regedit
找到 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/W32Time/TimeProviders/NtpClient下的
SpecialPollInterval 右键修改==选择“十进制” 604800 为秒 既7天时间

默认的604800就是由7(天)×24(时)×60(分)×60(秒)计算来的

 

 

 

如下是我本机的同步信息:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值