linux時(shí)間同步ntp服務(wù)的安裝與配置

安裝NTP(server client)

yum install ntp -y

Server機(jī)器修改NTP配置文件,添加NTP服務(wù)器的網(wǎng)絡(luò)位置 vi /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.
#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).
#注釋掉自帶的時(shí)間同步
#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
#用本地時(shí)間做為服務(wù)器時(shí)間
server 172.16.177.128
fudge 172.16.177.128 stratum 8
#開(kāi)放172.16.0.0 整個(gè)網(wǎng)段,即在這個(gè)網(wǎng)段的所有機(jī)器都可以使用 172.16.177.128 作為時(shí)間同步服務(wù)端
restrict 172.16.0.0 mask 255.255.255.0 nomodify notrap
#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

設(shè)置完成退出保存涡上,然后啟動(dòng)ntp服務(wù)

systemctl start ntpd.service  #啟動(dòng)服務(wù)
systemctl enable ntpd.service #設(shè)置為開(kāi)機(jī)啟動(dòng)

Client機(jī)器修改NTP配置文件,添加NTP服務(wù)器的網(wǎng)絡(luò)位置 vi /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.
#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).
#注釋掉自帶的時(shí)間同步
#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
#增加172.16.177.128作為時(shí)間服務(wù)器即可
server 172.16.177.128
#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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末具壮,一起剝皮案震驚了整個(gè)濱河市匾旭,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖甫男,帶你破解...
    沈念sama閱讀 212,542評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件且改,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡板驳,警方通過(guò)查閱死者的電腦和手機(jī)又跛,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,596評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)若治,“玉大人慨蓝,你說(shuō)我怎么就攤上這事《擞祝” “怎么了礼烈?”我有些...
    開(kāi)封第一講書(shū)人閱讀 158,021評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)婆跑。 經(jīng)常有香客問(wèn)我此熬,道長(zhǎng),這世上最難降的妖魔是什么滑进? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,682評(píng)論 1 284
  • 正文 為了忘掉前任犀忱,我火速辦了婚禮,結(jié)果婚禮上扶关,老公的妹妹穿的比我還像新娘峡碉。我一直安慰自己,他們只是感情好驮审,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,792評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布鲫寄。 她就那樣靜靜地躺著,像睡著了一般疯淫。 火紅的嫁衣襯著肌膚如雪地来。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 49,985評(píng)論 1 291
  • 那天熙掺,我揣著相機(jī)與錄音未斑,去河邊找鬼。 笑死币绩,一個(gè)胖子當(dāng)著我的面吹牛蜡秽,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播缆镣,決...
    沈念sama閱讀 39,107評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼芽突,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了董瞻?” 一聲冷哼從身側(cè)響起寞蚌,我...
    開(kāi)封第一講書(shū)人閱讀 37,845評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤田巴,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后挟秤,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體壹哺,經(jīng)...
    沈念sama閱讀 44,299評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,612評(píng)論 2 327
  • 正文 我和宋清朗相戀三年艘刚,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了管宵。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,747評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡攀甚,死狀恐怖箩朴,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情云稚,我是刑警寧澤隧饼,帶...
    沈念sama閱讀 34,441評(píng)論 4 333
  • 正文 年R本政府宣布,位于F島的核電站静陈,受9級(jí)特大地震影響燕雁,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜鲸拥,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,072評(píng)論 3 317
  • 文/蒙蒙 一拐格、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧刑赶,春花似錦捏浊、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,828評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至牵敷,卻和暖如春胡岔,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背枷餐。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,069評(píng)論 1 267
  • 我被黑心中介騙來(lái)泰國(guó)打工靶瘸, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人毛肋。 一個(gè)月前我還...
    沈念sama閱讀 46,545評(píng)論 2 362
  • 正文 我出身青樓怨咪,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親润匙。 傳聞我的和親對(duì)象是個(gè)殘疾皇子诗眨,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,658評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容