在linux系统中,为了制止主机时间因为长日子运作下所导致的岁月不是,实行时间同步(synchronize)的干活是充裕要求的。linux系统下,一般采纳ntp服务来一同分歧机器的时刻。NTP是网络时间讨论(Network Time Protocol)的简称,就是通过网络协议使总计机之间的日子同步化。

  在linux系统中,为了幸免主机时间因为长日子运作下所导致的小时不是,进行时间同步(synchronize)的干活是不行要求的。linux系统下,一般采取ntp服务来一块差异机器的时日。NTP是网络时间研究(Network Time Protocol)的简称,就是经过互联网协议使计算机之间的光阴同步化。

在Linux系统中,为了制止主机时间因为长日子运作下所造成的时刻不是,实行时间同步(synchronize)的工作是相当需求的。Linux系统下,一般接纳ntp服务来一同分化机器的光阴。NTP是网络时间研究(Network
Time Protocol)的简称,就是经过互联网协议使计算机之间的时光同步化。

ntp服务配置,详解!,ntp服务配置详解

  在linux系统中,为了防止主机时间因为长日子运作下所造成的光阴不是,举办时间同步(synchronize)的行事是丰盛要求的。linux系统下,一般采用ntp服务来一同不相同机器的大运。NTP是网络时间钻探(Network
Time Protocol)的简称,正是经过互联网协议使总结机之间的岁月同步化。

 

安装NTP包

检查是或不是安装了ntp相关包。就算设置ntp相关包,使用rpm只怕yum安装,非凡简单。

[[email protected]
~]# rpm -qa |grep ntp

fontpackages-filesystem-1.41-1.1.el6.noarch

ntp服务配置,NTP服务配置详解。ntpdate-4.2.6p5-10.el6.centos.2.i686

ntp-4.2.6p5-10.el6.centos.2.i686

 

NTP的配置

A.配置/etc/ntp.conf

  NTP
server的重庆大学配备文件为/etc/ntp.conf,没有改动过的ntp。conf文件内同如下:

[[email protected]
~]# more /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

 

# 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

 

# 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 0.rhel.pool.ntp.org iburst

server 1.rhel.pool.ntp.org iburst

server 2.rhel.pool.ntp.org iburst

server 3.rhel.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

  1)设定NTP主机来源(在那之中prefer表示优先主机),192.168.66.131是当地的NTP服务器,所以优先钦命从该主机同步时间

server 192.168.66.131 prefer

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

  2)限制你允许的那么些服务器的拜会类型,在那一个例子中的服务器是不容许修改运营时安顿或然查询您的linux
ntp服务器

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

上述的掩码地址扩充为255,因而从192.168.1.1-192.168.1.254的服务器都能够采取大家的NTP服务器来二只时间

#安装暗中认可策略为允许别的主机举办时间同步

 restrict default ignore

  3)确认保证localhost有丰硕权限,使用没有其余限制重点词的语法

    restrict 127.0.0.1

restrict -6 ::1

 

B.配置/etc/ntp/step-tickers文件

修改/etc/ntp/step-tickers文件,内容如下(当ntp服务运行时,会活动与该文件中记录的上层NTP服务拓展时间核查)

[[email protected]
~]# more /etc/ntp/step-tickers

# List of servers used for initial synchronization.

server 192.168.66.131 prefer

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

上述是由此了vi修改

 

C.配置/etc/sysconfig/ntpd文件

ntp服务,私下认可智慧共同系统时间。要是让ntp同时一起硬件时间,能够设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中增加,SYNC_HWCLOCK=yes这样,就足以让硬件时间与系统时间同步共同。

 

IPTABLES配置

出于ntp服务必要接纳到UDP端口号为123,所以当系统的防火墙(iptables)运转的动静下,必须开放UDP端口号123

 

启动NTP服务

service ntpd status

service ntpd start

netstat -lntup|grep ntp

检查ntp是还是不是开机运营:[[email protected]
~]# chkconfig –level 35 ntpd on

 

 

 

 

在 linux
系统中,为了制止主机时间因为长日子运作下所造成的光阴不是,实行时间同步(
synchroni…

 

 

安装NTP包

安装NTP包

安装NTP包

自小编批评是还是不是安装了ntp相关包。假若设置ntp相关包,使用rpm大概yum安装,非凡容易。

检查是还是不是安装了ntp相关包。假设设置ntp相关包,使用rpm或然yum安装,格外不难。

反省是或不是安装了ntp相关包。借使设置ntp相关包,使用rpm恐怕yum安装,分外简单。

[root@localhost ~]# rpm -qa |grep ntp

[root@localhost ~]# rpm -qa |grep ntp

[root@localhost ~]# rpm -qa |grep ntp

fontpackages-filesystem-1.41-1.1.el6.noarch

fontpackages-filesystem-1.41-1.1.el6.noarch

fontpackages-filesystem-1.41-1.1.el6.noarch

ntpdate-4.2.6p5-10.el6.CentOS.2.i686

ntpdate-4.2.6p5-10.el6.centos.2.i686

ntpdate-4.2.6p5-10.el6.centos.2.i686

ntp-4.2.6p5-10.el6.centos.2.i686

ntp-4.2.6p5-10.el6.centos.2.i686

ntp-4.2.6p5-10.el6.centos.2.i686

NTP的配置

 

 

A.配置/etc/ntp.conf

NTP的配置

NTP的配置

NTP
server的根本布局文件为/etc/ntp.conf,没有改动过的ntp。conf文件内同如下:

A.配置/etc/ntp.conf

A.配置/etc/ntp.conf

[root@localhost ~]# more /etc/ntp.conf

  NTP server的严重性布局文件为/etc/ntp.conf,没有改动过的ntp。conf文件内同如下:

  NTP server的首要布局文件为/etc/ntp.conf,没有改动过的ntp。conf文件内同如下:

# For more information about this file, see the man pages

[root@localhost ~]# more /etc/ntp.conf

[root@localhost ~]# more /etc/ntp.conf

# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5),
ntp_mon(5).

# For more information about this file, see the man pages

# For more information about this file, see the man pages

driftfile /var/lib/ntp/drift

# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5),
ntp_mon(5).

# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5),
ntp_mon(5).

# Permit time synchronization with our time source, but do not

 

 

# permit the source to query or modify the service on this system.

driftfile /var/lib/ntp/drift

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

 

 

restrict -6 default kod nomodify notrap nopeer noquery

# Permit time synchronization with our time source, but do not

# Permit time synchronization with our time source, but do not

# Permit all access over the loopback interface.  This could

# permit the source to query or modify the service on this system.

# permit the source to query or modify the service on this system.

# be tightened as well, but to do so would effect some of

restrict default kod nomodify notrap nopeer noquery

restrict default kod nomodify notrap nopeer noquery

# the administrative functions.

restrict -6 default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

 

 

restrict -6 ::1

# Permit all access over the loopback interface.  This could

# Permit all access over the loopback interface.  This could

# Hosts on local network are less restricted.

# be tightened as well, but to do so would effect some of

# be tightened as well, but to do so would effect some of

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# the administrative functions.

# the administrative functions.

# Use public servers from the pool.ntp.org project.

restrict 127.0.0.1

restrict 127.0.0.1

# Please consider joining the pool ().

restrict -6 ::1

restrict -6 ::1

server 0.rhel.pool.ntp.org iburst

 

 

server 1.rhel.pool.ntp.org iburst

# Hosts on local network are less restricted.

# Hosts on local network are less restricted.

server 2.rhel.pool.ntp.org iburst

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

server 3.rhel.pool.ntp.org iburst

 

 

#broadcast 192.168.1.255 autokey        # broadcast server

# Use public servers from the pool.ntp.org project.

# Use public servers from the pool.ntp.org project.

#broadcastclient                        # broadcast client

# Please consider joining the pool ().

# Please consider joining the pool ().

#broadcast 224.0.1.1 autokey            # multicast server

server 0.rhel.pool.ntp.org iburst

server 0.rhel.pool.ntp.org iburst

#multicastclient 224.0.1.1              # multicast client

server 1.rhel.pool.ntp.org iburst

server 1.rhel.pool.ntp.org iburst

#manycastserver 239.255.254.254        # manycast server

server 2.rhel.pool.ntp.org iburst

server 2.rhel.pool.ntp.org iburst

#manycastclient 239.255.254.254 autokey # manycast client

server 3.rhel.pool.ntp.org iburst

server 3.rhel.pool.ntp.org iburst

# Enable public key cryptography.

 

 

#crypto

 

 

includefile /etc/ntp/crypto/pw

#broadcast 192.168.1.255 autokey        # broadcast server

#broadcast 192.168.1.255 autokey        # broadcast server

# Key file containing the keys and key identifiers used when operating

#broadcastclient                        # broadcast client

#broadcastclient                        # broadcast client

# with symmetric key cryptography.

#broadcast 224.0.1.1 autokey            # multicast server

#broadcast 224.0.1.1 autokey            # multicast server

keys /etc/ntp/keys

#multicastclient 224.0.1.1              # multicast client

#multicastclient 224.0.1.1              # multicast client

# Specify the key identifiers which are trusted.

#manycastserver 239.255.254.254         # manycast server

#manycastserver 239.255.254.254         # manycast server

#trustedkey 4 8 42

#manycastclient 239.255.254.254 autokey # manycast client

#manycastclient 239.255.254.254 autokey # manycast client

# Specify the key identifier to use with the ntpdc utility.

 

 

#requestkey 8

# Enable public key cryptography.

# Enable public key cryptography.

# Specify the key identifier to use with the ntpq utility.

#crypto

#crypto

#controlkey 8

 

 

# Enable writing of statistics records.

includefile /etc/ntp/crypto/pw

includefile /etc/ntp/crypto/pw

#statistics clockstats cryptostats loopstats peerstats

 

 

1)设定NTP主机来源(当中prefer表示优先主机),192.168.66.131是地面包车型大巴NTP服务器,所以优先钦定从该主机同步时间

# Key file containing the keys and key identifiers used when operating

# Key file containing the keys and key identifiers used when operating

server 192.168.66.131 prefer

# with symmetric key cryptography.

# with symmetric key cryptography.

server 0.centos.pool.ntp.org iburst

keys /etc/ntp/keys

keys /etc/ntp/keys

server 1.centos.pool.ntp.org iburst

 

 

server 2.centos.pool.ntp.org iburst

# Specify the key identifiers which are trusted.

# Specify the key identifiers which are trusted.

server 3.centos.pool.ntp.org iburst

#trustedkey 4 8 42

#trustedkey 4 8 42

2)限制你同意的那个服务器的走访类型,在那个事例中的服务器是不容许修改运转时安顿也许查询您的linux
ntp服务器

 

 

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Specify the key identifier to use with the ntpdc utility.

# Specify the key identifier to use with the ntpdc utility.

上述的掩码地址扩大为255,因而从192.168.1.1-192.168.1.254的服务器都能够运用大家的NTP服务器来一同时间

#requestkey 8

#requestkey 8

#设置暗中同意策略为允许别的主机进行时间一起

 

 

restrict default ignore

# Specify the key identifier to use with the ntpq utility.

# Specify the key identifier to use with the ntpq utility.

3)确认保障localhost有丰盛权限,使用没有其他限制重点词的语法

#controlkey 8

#controlkey 8

restrict 127.0.0.1

 

 

restrict -6 ::1

# Enable writing of statistics records.

# Enable writing of statistics records.

B.配置/etc/ntp/step-tickers文件

#statistics clockstats cryptostats loopstats peerstats

#statistics clockstats cryptostats loopstats peerstats

修改/etc/ntp/step-tickers文件,内容如下(当ntp服务运维时,会自动与该文件中记录的上层NTP服务开始展览时间查对)

  1)设定NTP主机来源(个中prefer表示优先主机),192.168.66.131是当地的NTP服务器,所以优先钦点从该主机同步时间

  1)设定NTP主机来源(个中prefer表示优先主机),192.168.66.131是地点的NTP服务器,所以优先内定从该主机同步时间

[root@localhost ~]# more /etc/ntp/step-tickers

server 192.168.66.131 prefer

server 192.168.66.131 prefer

# List of servers used for initial synchronization.

server 0.centos.pool.ntp.org iburst

server 0.centos.pool.ntp.org iburst

server 192.168.66.131 prefer

server 1.centos.pool.ntp.org iburst

server 1.centos.pool.ntp.org iburst

server 0.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

server 1.centos.pool.ntp.org iburst

server 3.centos.pool.ntp.org iburst

server 3.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

  2)限制你同意的这一个服务器的造访类型,在这些事例中的服务器是不容许修改运营时布置也许查询您的linux ntp服务器

  2)限制你同意的这个服务器的造访类型,在那几个事例中的服务器是不容许修改运营时计划大概查询您的linux ntp服务器

server 3.centos.pool.ntp.org iburst

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

如上是经过了vi修改

以上的掩码地址扩充为255,因而从192.168.1.1-192.168.1.254的服务器都足以行使大家的NTP服务器来一同时间

上述的掩码地址扩张为255,由此从192.168.1.1-192.168.1.254的服务器都得以利用大家的NTP服务器来一同时间

C.配置/etc/sysconfig/ntpd文件

#设置默许策略为允许任何主机进行时间同步

#安装默许策略为允许别的主机实行时间同步

ntp服务,私下认可智慧共同系统时间。若是让ntp同时一起硬件时间,能够设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中加上,SYNC_HWCLOCK=yes那样,就足以让硬件时间与系统时间一起一起。

 restrict default ignore

 restrict default ignore

IPTABLES配置

  3)确定保证localhost有丰裕权限,使用没有别的限制重点词的语法

  3)确认保证localhost有丰裕权限,使用没有此外限制重点词的语法

由于ntp服务供给使用到UDP端口号为123,所以当系统的防火墙(iptables)运营的状态下,必须开放UDP端口号123

    restrict 127.0.0.1

    restrict 127.0.0.1

启动NTP服务

restrict -6 ::1

restrict -6 ::1

service ntpd status

 

 

service ntpd start

B.配置/etc/ntp/step-tickers文件

B.配置/etc/ntp/step-tickers文件

netstat -lntup|grep ntp

修改/etc/ntp/step-tickers文件,内容如下(当ntp服务运转时,会自动与该公文中著录的上层NTP服务开展时间查对)

修改/etc/ntp/step-tickers文件,内容如下(当ntp服务运维时,会自动与该文件中记录的上层NTP服务开始展览时间核对)

检查ntp是不是开机运营:[root@localhost ~]# chkconfig –level 35 ntpd on

[root@localhost ~]# more /etc/ntp/step-tickers

[root@localhost ~]# more /etc/ntp/step-tickers

愈多NTP时间服务器相关学科见以下内容

# List of servers used for initial synchronization.

# List of servers used for initial synchronization.

开源软件包的设置及ntp时间服务器简析 
http://www.linuxidc.com/Linux/2017-02/140342.htm

server 192.168.66.131 prefer

server 192.168.66.131 prefer

Linux时间一起NTP服务的设置与布置
http://www.linuxidc.com/Linux/2016-10/135945.htm

server 0.centos.pool.ntp.org iburst

server 0.centos.pool.ntp.org iburst

如何在 CentOS 中搭建 NTP 服务器 
http://www.linuxidc.com/Linux/2015-06/118480.htm

server 1.centos.pool.ntp.org iburst

server 1.centos.pool.ntp.org iburst

教您怎么飞快搭建NTP时间服务器 
http://www.linuxidc.com/Linux/2017-02/140875.htm

server 2.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

CentOS 7 中采用NTP进行时间一起 
http://www.linuxidc.com/Linux/2015-11/124911.htm

server 3.centos.pool.ntp.org iburst

server 3.centos.pool.ntp.org iburst

Linux之使用NTP服务管理/同步服务器时间 
http://www.linuxidc.com/Linux/2016-03/129277.htm

上述是通过了vi修改

如上是透过了vi修改

Linux下搭建NTP服务器 
http://www.linuxidc.com/Linux/2016-03/129126.htm

 

 

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-08/146188.htm

C.配置/etc/sysconfig/ntpd文件

C.配置/etc/sysconfig/ntpd文件

澳门金沙国际 1

ntp服务,暗中同意智慧共同系统时间。倘诺让ntp同时三头硬件时间,能够设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中丰盛,SYNC_HWCLOCK=yes那样,就能够让硬件时间与系统时间共同一起。

ntp服务,暗许智慧共同系统时间。要是让ntp同时二头硬件时间,能够设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中加上,SYNC_HWCLOCK=yes那样,就足以让硬件时间与系统时间共同联合。

 

 

IPTABLES配置

IPTABLES配置

鉴于ntp服务须要运用到UDP端口号为123,所以当系统的防火墙(iptables)运营的景况下,必须开放UDP端口号123

出于ntp服务要求运用到UDP端口号为123,所以当系统的防火墙(iptables)运维的景观下,必须开放UDP端口号123

 

 

启动NTP服务

启动NTP服务

service ntpd status

service ntpd status

service ntpd start

service ntpd start

netstat -lntup|grep ntp

netstat -lntup|grep ntp

反省ntp是还是不是开机运行:[root@localhost ~]# chkconfig –level 35
ntpd on

自我批评ntp是不是开机运转:[root@localhost ~]# chkconfig –level 35
ntpd on

 

 

 

 

 

 

 

 

相关文章