配置內(nèi)網(wǎng)ntp服務(wù)

一 . 內(nèi)網(wǎng)NTP-Server(192.168.1.12)

備份配置文件

cp /etc/ntp.conf /etc/ntp.conf.bak

改配置文件

vim /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.
# 允許網(wǎng)段訪問

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).

# 注釋掉
# 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

#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

# 下面2行, 以本地時(shí)間作為時(shí)間服務(wù)
server 127.127.1.0 

fudge 127.127.1.0 stratum 10


開啟服務(wù)端口:

firewall-cmd  --zone=public --add-port=123/udp --permanent
firewall-cmd --reload

start啟動(dòng)服務(wù),enable 開機(jī)啟動(dòng), status查看狀態(tài)。


systemctl start ntpd.service
systemctl enable ntpd.service
systemctl status ntpd.service

查看ntpd端口情況

[root@node1 ~]# ss -tlunp |grep ntp
udp    UNCONN     0      0      192.168.1.12:123                   *:*                   users:(("ntpd",pid=114741,fd=19))
udp    UNCONN     0      0      127.0.0.1:123                   *:*                   users:(("ntpd",pid=114741,fd=18))
udp    UNCONN     0      0         *:123                   *:*                   users:(("ntpd",pid=114741,fd=16))
udp    UNCONN     0      0      fe80::8c4a:435d:d7ec:6826%ens33:123                  :::*                   users:(("ntpd",pid=114741,fd=21))
udp    UNCONN     0      0       ::1:123                  :::*                   users:(("ntpd",pid=114741,fd=20))
udp    UNCONN     0      0        :::123                  :::*                   users:(("ntpd",pid=114741,fd=17))

ntpq -p 查看網(wǎng)絡(luò)中的NTP服務(wù)器,同時(shí)顯示客戶端和每個(gè)服務(wù)器的關(guān)系

# ntpq -p

改時(shí)間

date -s 18:00:00

二 . 內(nèi)網(wǎng)NTP-Clients(192.168.1.13)

備份配置文件

cp /etc/ntp.conf /etc/ntp.conf.bak

改配置文件

vim /etc/ntp.conf  

#改成相對(duì)應(yīng)的服務(wù)器,把下面的注釋掉

server 192.168.1.12 iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

多臺(tái)ntp的情況

客戶端配置
driftfile /var/lib/ntp/drift
server 192.168.8.102 prefer
server 192.168.8.101
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

start啟動(dòng)服務(wù),enable 開機(jī)啟動(dòng), status查看狀態(tài)。

systemctl start ntpd.service
systemctl enable ntpd.service
systemctl status ntpd.service

查看時(shí)間

date

查看網(wǎng)絡(luò)中的NTP服務(wù)器

ntpq -p
[root@node2 /etc]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*node1           LOCAL(0)        11 u   62   64   77    2.050   -2.689   2.395

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、項(xiàng)目目標(biāo) 搭建一個(gè)高可用web集群網(wǎng)站 二、項(xiàng)目規(guī)劃 2.1 ip地址規(guī)劃 2.2 拓?fù)鋱D 2.3 相關(guān)說明 ...
    夏日之光閱讀 4,293評(píng)論 0 1
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,688評(píng)論 19 139
  • 本人陸陸續(xù)續(xù)接觸了ELK的1.4,2.0,2.4,5.0,5.2版本,可以說前面使用當(dāng)中一直沒有太多感觸,最近使用...
    三杯水Plus閱讀 4,272評(píng)論 0 12
  • 我和東野圭吾的戀愛狀態(tài)已經(jīng)持續(xù)了四年,這是我的“初戀”,這種感覺是夢(mèng)幻的,美妙又令人陶醉。讓我深陷其中而不能自拔,...
    殘花人閱讀 347評(píng)論 0 0
  • 運(yùn)動(dòng)我喜歡流汗的感覺,特別是大汗淋漓的樣子。每次運(yùn)動(dòng)完流了汗,神清氣爽。 運(yùn)動(dòng),不是別人說跑步好就去跑步,要找到自...
    華花HY閱讀 323評(píng)論 0 4

友情鏈接更多精彩內(nèi)容