日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux下ntp服务器搭建方法

發(fā)布時間:2025/7/25 linux 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux下ntp服务器搭建方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

環(huán)境

軟件:fedora14,裝在virtualbox虛擬機上
硬件:x86

具體步驟

檢查是否安裝了ntp

運行如下命令:

rpm -qa | grep ntp

如果有如下輸出,表示有安裝ntp 服務(wù)器

ntp-4********

如果有如下輸出,表示有安裝ntp客戶端

ntpdate-******

如果沒有安裝,執(zhí)行 yum -y install ntp

修改ntp的配置文件

用文件ntp.conf替換掉/etc/ntp.conf文件,ntp.conf內(nèi)容如下

# 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.# rongp comment#restrict default kod nomodify notrap nopeer noquery#restrict -6 default kod nomodify notrap nopeer noqueryrestrict 192.168.1.94restrict 192.168.1.0 mask 255.255.255.0 nomodify# Permit all access over the loopback interface. This could# be tightened as well, but to do so would effect some of# the administrative functions.# rongp comment# 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 notrapserver ntp.amnic.net preferserver time.windows.com preferserver time-nw.nist.gov preferserver time.nist.gov preferrestrict ntp.amnic.netrestrict time.windows.comrestrict time-nw.nist.govrestrict time.nist.gov prefer# Use public servers from the pool.ntp.org project.# Please consider joining the pool (http://www.pool.ntp.org/join.html).# rongp comment# server 0.fedora.pool.ntp.org iburst# server 1.fedora.pool.ntp.org iburst# server 2.fedora.pool.ntp.org iburst# server 3.fedora.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# 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 clockfudge 127.127.1.0 stratum 10# Enable public key cryptography.#cryptoincludefile /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

重啟ntp服務(wù)器

執(zhí)行命令: service ntpd restart

檢查是否正常開啟ntp服務(wù)器

執(zhí)行命令: ps -ef | grep ntpd | grep -v grep

如果有輸出表示已開啟,然后用客戶端進一步測試能否正常同步到該ntp服務(wù)器,用另外一臺電腦(需要安裝ntpdate),執(zhí)行ntpdate ntp服務(wù)器地址 eg: ntpdate 192.168.1.94

如果有如下類似輸出:

28 May 17:33:39 ntpdate[29134]: step time server 192.168.1.94 offset 3.174187 sec

表示同步成功。

注意:剛開啟的ntp服務(wù)器需要過幾分鐘后客戶端才能夠去同步,因為ntp服務(wù)器本身要和遠程ntp服務(wù)器同步需要時間,因此可能會遇到如下出錯信息:

28 May 17:32:00 ntpdate[29104]: no server suitable for synchronization found

這種情況,過幾分鐘后再試試,這個情況還可能是其他原因?qū)е?#xff0c;這里不再描述。

附錄

配置文件說明:

restrict開頭的行,表示設(shè)置客戶端連接到本ntp服務(wù)器的權(quán)限
server開頭的行,表示設(shè)置本ntp服務(wù)器連接到遠程ntp服務(wù)器的地址
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

上面兩行的意思是如果server指定的服務(wù)器連接失敗,采用本地的時間來同步時間

完!
2012年6月

轉(zhuǎn)載于:https://www.cnblogs.com/rongpmcu/p/7662141.html

總結(jié)

以上是生活随笔為你收集整理的linux下ntp服务器搭建方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。