RHEL6下NTP服務器的配置

RHEL6下NTP服務器的配置
實驗環境:
[root@desktop2 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.0 (Santiago)
[root@desktop2 ~]# uname -r
2.6.32-71.el6.x86_64
一、NTP服務的原理
1、原理
NTP(Network Time Protocol,網絡時間協議)是用來使計算機時間同步化的一種協議,它可以使計算機對其服務器或時鐘源(如石英鐘,GPS等等)做同步化,它可以提供高精準度的時間校正(LAN上與標準間差小於1毫秒,WAN上幾十毫秒),且可介由加密確認的方式來防止惡毒的協議***。
2、端口
UDP 123
二、NTP服務的配置
1、安裝NTP軟件包
[root@desktop2 ~]# yum -y install ntp
2、NTP服務的配置
[root@desktop2 ~]# grep -v "^#" /etc/ntp.conf 
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 
restrict -6 ::1
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 192.168.0.254
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
logfile /var/log/ntp
[root@desktop2 ~]# cat /etc/ntp/step-tickers //當NTP服務啓動時,會自動與該文件中的記錄的上層NTP服務進行時間校對
# List of servers used for initial synchronization.
192.168.0.254
[root@desktop2 ~]# cat /etc/sysconfig/ntpd //允許BIOS與系統時間同步
# Drop root to id 'ntp:ntp' by default.
SYNC_HWCLOCK=yes
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
3、啓動NTP服務
[root@desktop2 ~]# service ntpd start
[root@desktop2 ~]# chkconfig ntpd on
4、NTP的測試
[root@desktop2 ~]# ntpstat 
synchronised to NTP server (192.168.0.254) at stratum 12 //進行時間校對的NTP服務器
   time correct to within 958 ms //本地與上層NTP服務器的時間差
   polling server every 64 s //下次同步時間
[root@desktop2 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*instructor.exam LOCAL(0)        11 u   26   64  377    0.807    0.030   0.219
 LOCAL(0)        .LOCL.          10 l   27   64  377    0.000    0.000   0.000
三、客戶端的訪問
1、Windows平臺
雙擊任務欄右下角的時鐘,選擇Internet時間
 
2、Linux平臺
 
或者ntpdate 192.168.0.2
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章