Centos 7.4 升級 NTP 到 4.2.8p12 版本

????升級ntp主要是為了解決系統(tǒng)安全問題:

? ? ? ? ? ? ? ? ? ? 因?yàn)? ? centos7.4系統(tǒng)中默認(rèn)安裝的是 ntp 4.2.6p5版本,但是此版本漏洞很多双饥,很容易被攻擊導(dǎo)致無法提供服務(wù)等等問題。下面的鏈接是ntp 4.2.6p5版本漏洞詳細(xì):

? ??????????????????????????????????http://www.reibang.com/p/a6a761617736

查看當(dāng)前系統(tǒng)版本:

? ? ? ? ? cat /etc/system-release

當(dāng)前系統(tǒng)版本

查看當(dāng)前 ntpd 版本:

? ? ? ? ? ?ntpd --version

當(dāng)前 ntpd 版本

一趴生、?系統(tǒng)與軟件版本**

? ? ? ? ? 系統(tǒng)版本:

? ? ? ? ? ? ? ? ?CentOS7.4

? ? ? ? ? ntpd軟件版本:

? ? ? ? ? ? ? ? ? ?ntp-4.2.8p12

? ? ? ? ? 下載地址:

? ? ? ? ? ? ? ? ??Windows下載地址:http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p12.tar.gz

? ? ? ? ? ? ? ? ? Linux 下載地址:wget?http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p12.tar.gz

二、安裝準(zhǔn)備

? ? ? ? ? ? 安裝依賴包:

? ? ? ? ? ? ? ? ? ? yum install gcc gcc-c++ openssl-devel libstdc++* libcap*

? ? ? ? ? ? 備份舊版本的配置文件:(不需要備份的話請?zhí)^)

????????????建議備份因?yàn)樵创a安裝不會生成配置文件如果不備份的話我會在下面貼出配置文件的內(nèi)容

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cp -ar /etc/ntp /etc/ntp.bak

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

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cp /etc/init.d/ntpd /etc/init.d/ntpd.bak

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cp /etc/sysconfig/ntpd /etc/sysconfig/ntpd.bak

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cp /etc/sysconfig/ntpdate /etc/sysconfig/ntpdate.bak

? ? ? ? ? ? 卸載yum安裝的ntpd服務(wù):

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? yum remove ntp ntpdate

成功卸載

? ? ? ? ? ? 解壓 ntp 壓縮文件:


三刘急、編譯安裝ntp-4.2.8p9

? ? ? ? ? ? 解壓源碼壓縮文件:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tar -zxvf ntp-4.2.8p12.tar.gz???

解壓生成的文件夾

? ? ? ? ? ? 進(jìn)入解壓生成的ntp-4.2.8p9文件夾:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? cd ntp-4.2.8p12/

? ? ? ? ? ? 編譯安裝ntpd:

./configure \

--prefix=/usr \

--bindir=/usr/sbin \

--enable-all-clocks \

--enable-parse-clocks \

--docdir=/usr/share/doc/ntp-4.2.8p12

????????????????命令詳解:

????????????????????????????????--prefix=安裝的目錄? ?

? ??????????????????????????????--bindir=會將主程序放置到這個文件夾

? ??????????????????????????????--docdir=doc文檔的存放目錄

? ? ? ? ? ? ? ? 查看運(yùn)行是否有錯誤:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 執(zhí)行:? echo $?

返回 0 表示沒有錯誤

? ? ? ? ? ? ? 編譯并安裝:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? make && make install

? ? ? ? ? ? ? ?創(chuàng)建軟鏈接:

????????????????????????????????????ln -s /usr/local/ntp-4.2.8p12 /usr/local/ntp

? ? ? ? ? ? ? ? 查看 ntp 版本:

? ? ????????????????????????????????????ntpd --version

成功編譯安裝

配置 ntp :

? ? ? ? ? ? ? ? 執(zhí)行 vim /etc/ntp.conf

? ? ? ? ? ? ? ? 這個配置文件是將此節(jié)點(diǎn)配置成本地服務(wù) server 端:

本地其他機(jī)器可以使用命令:????????ntpdate mongodb04? ? ? ? ? ? 來和此節(jié)點(diǎn)同步時間

添加以下配置:

# 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.215.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

server 127.127.1.0? # local clock

fudge 127.127.1.0 stratum 10

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

? ? ? ? ? ? ? ? ? ? 然后就是啟動 ntp 服務(wù)了:

? ? ? ? ? ? ? ? ? ? ?????????????????????????????????????????/usr/sbin/ntpd -c /etc/ntp.conf

? ? ? ? ? ? ? ? ? ? 查看 ntp 服務(wù)是否啟動:

? ??????????????????????????????????????????????????????????ps -ef | grep ntpd

已經(jīng)成功啟動了

? ? ? ? ? ? ? ? ? ? ?查看 ntp 服務(wù)端口:

? ??????????????????????????????????????????????????netstat -tunlp | grep 123

????????????????????????檢查同步情況:

? ??????????????????????????????????????????????watch ntpq -p

在啟動之后短時間內(nèi)可能無法和此節(jié)點(diǎn)同步時間可能會出現(xiàn)下面的問題:

? ????????????? 執(zhí)行同步命令:????ntpdate mongodb04

????????????????????????????????31 Aug 00:34:43 ntpdate[18417]: no server suitable for synchronization found

稍微等一會在進(jìn)行同步:

? ? ? ? ? ? ? ? 執(zhí)行同步命令:????ntpdate mongodb04

????????????????????????????????31 Aug 00:39:20 ntpdate[18684]: adjust time server 192.168.215.184 offset -0.111364 sec

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末民轴,一起剝皮案震驚了整個濱河市球订,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌冒滩,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件开睡,死亡現(xiàn)場離奇詭異,居然都是意外死亡篇恒,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進(jìn)店門胁艰,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人腾么,你說我怎么就攤上這事〗馐” “怎么了?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵于宙,是天一觀的道長。 經(jīng)常有香客問我限煞,道長,這世上最難降的妖魔是什么署驻? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮旺上,結(jié)果婚禮上瓶蚂,老公的妹妹穿的比我還像新娘宣吱。我一直安慰自己,他們只是感情好征候,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著疤坝,像睡著了一般。 火紅的嫁衣襯著肌膚如雪跑揉。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天历谍,我揣著相機(jī)與錄音,去河邊找鬼望侈。 笑死,一個胖子當(dāng)著我的面吹牛脱衙,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播岂丘,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼奥帘!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起寨蹋,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎已旧,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體运褪,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡玖瘸,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年檀咙,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片弧可。...
    茶點(diǎn)故事閱讀 40,015評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖棕诵,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情校套,我是刑警寧澤,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布搔确,位于F島的核電站灭忠,受9級特大地震影響膳算,放射性物質(zhì)發(fā)生泄漏弛作。R本人自食惡果不足惜涕蜂,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一映琳、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧萨西,春花似錦、人聲如沸谎脯。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至废麻,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間烛愧,已是汗流浹背油宜。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留顶吮,地道東北人。 一個月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓悴了,卻偏偏與公主長得像,于是被迫代替她去往敵國和親违寿。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,969評論 2 355