<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    wang123

    使用NTP網絡時間協(xié)議同步你的網絡

    NTP協(xié)議全稱網絡時間協(xié)議(Network Time Procotol)。它的目的是在國際互聯(lián)網上傳遞統(tǒng)一、標準的時間。具體的實現方案是在網絡上指定若干時鐘源網站,為用戶提供授時服務,并且這些網站間應該能夠相互比對,提高準確度。

    NTP 最早是由美國Delaware大學的Mills教授設計實現的,從1982件最初提出到現在已發(fā)展了將近20年,2001年最新的NTPv4精確度已經達到了200毫秒。對于實際應用,又有確保秒級精度的SNTP(簡單的網絡時間協(xié)議)。

    NTP是一個跨越廣域網或局域網的復雜的同步時間協(xié)議,它通常可獲得毫秒級的精度。RFC2030[Mills 1996]描述了SNTP(Simple Network Time Protocol),目的是為了那些不需要完整NTP實現復雜性的主機,它是NTP的一個子集。通常讓局域網上的若干臺主機通過因特網與其他的NTP主機同步時鐘,接著再向局域網內其他客戶端提供時間同步服務。

    NTP協(xié) 議是OSI參考模型的高層協(xié)議,符合UDP傳輸協(xié)議格式,擁有專用端口123。

    隨著時間的推移, 計算機的時鐘會傾向于漂移。 網絡時間協(xié)議 (NTP) 是一種確保您的時鐘保持準確的方法。它為路由器、交換機、工作站和服務器之間提供了一種時間同步的機制。所以NTP Server經常應用于一些有時間同步要求的IT系統(tǒng)環(huán)境中。

    一、服務端設置

    Mac OS X Server似乎默認就有了,只說一下Linux下如何設置。
    在Ubuntu Linux中應用NTP Server非常方便:
    1. 安裝
    sudo apt-get install ntp  


    2. 配置
    配置文件是/etc/ntp.conf

    a. 找到server一項,添加你喜歡的Time Server
    server time.asia.apple.com  iburst dynamic  

    b. 設置權限,我的所有restrict條目如下
     
    1. restrict -4 default kod notrap nomodify nopeer noquery   
    2. restrict -6 default kod notrap nomodify nopeer noquery   
    3.   
    4. # Local users may interrogate the ntp server more closely.   
    5. restrict 127.0.0.1   www.5a520.cn
    6. restrict ::1  
    7.   
    8. # Clients from this (example!) subnet have unlimited access, but only if  
    9. # cryptographically authenticated.   
    10. #restrict 192.168.123.0 mask 255.255.255.0 notrust   
    11. restrict 192.168.0.0 mask 255.255.255.0  


    3. 重啟ntp服務器
    /etc/init.d/ntp restart

    4. 查看服務器是否工作正常
    在服務器運行
    Java代碼 復制代碼
    1. ntpq -p  


    二、工作站同步

    好了,測試一下吧,假設你的新服務器IP地址為192.168.0.7。在客戶端運行如下命令:
    ntpdate -u 192.168.0.7

    同步成功后,將會顯示如下:
    6 Mar 15:44:24 ntpdate[9921]: adjust time server 192.168.0.7 offset -0.007277 sec

    三、交換機同步

    Cisco IOS
    Java代碼 復制代碼
    1. ciscorouter> enable   
    2. password: *********   
    3. ciscorouter# config t   
    4. ciscorouter(config)# ntp update-calendar   
    5. ciscorouter(config)# ntp server 192.168.0.4  
    6. ciscorouter(config)# ntp server 192.168.0.7  
    7. ciscorouter(config)# exit   
    8. ciscorouter# wr mem  


    Dell 6248
    Java代碼 復制代碼
    1. dell6248-corner>en   
    2. dell6248-corner#configure    
    3. dell6248-corner(config)#sntp server 192.168.0.7  
    4. dell6248-corner(config)#  


    四、一些常見的時間服務器

    210.72.145.44  ── (國家授時中心服務器IP地址)
    133.100.11.8  ── 日本 福岡大學
    time-a.nist.gov 129.6.15.28 ── NIST, Gaithersburg, Maryland
    time-b.nist.gov 129.6.15.29 ── NIST, Gaithersburg, Maryland
    time-a.timefreq.bldrdoc.gov 132.163.4.101 ── NIST, Boulder, Colorado
    time-b.timefreq.bldrdoc.gov 132.163.4.102 ── NIST, Boulder, Colorado
    time-c.timefreq.bldrdoc.gov 132.163.4.103 ── NIST, Boulder, Colorado
    utcnist.colorado.edu 128.138.140.44 ── University of Colorado, Boulder
    time.nist.gov 192.43.244.18 ── NCAR, Boulder, Colorado
    time-nw.nist.gov 131.107.1.10 ── Microsoft, Redmond, Washington
    nist1.symmetricom.com 69.25.96.13 ── Symmetricom, San Jose, California
    nist1-dc.glassey.com 216.200.93.8 ── Abovenet, Virginia
    nist1-ny.glassey.com 208.184.49.9 ── Abovenet, New York City
    nist1-sj.glassey.com 207.126.98.204 ── Abovenet, San Jose, California
    nist1.aol-ca.truetime.com 207.200.81.113 ── TrueTime, AOL facility, Sunnyvale, California
    nist1.aol-va.truetime.com 64.236.96.53 ── TrueTime, AOL facility, Virginia


    五、使用Python腳本來獲取時間

    Java代碼 復制代碼
    1. #!/usr/bin/python   
    2. from socket import *   
    3. import struct,os,time,sys   
    4.   
    5. # Script to set Linux hardware clock (/usr/sbin/hwclock) from an NTP   
    6. # time server.   Run as "setclock.py" to simply print the time from   
    7. # the NTP server.  Run as "setclock.py --set" to set the Linux   
    8. # hardware clock (as the super user, of course).   
    9.   
    10. # Based on Simon Foster's simple SNTP client from ASPN Python cookbook.   
    11. # Adapted by Paul Rubin; this script lives at:   
    12. #    http://www.nightsong.com/phr/python/setclock.py   
    13.   
    14. time_server = ('time.apple.com'123)   
    15. # time.apple.com is a stratum 2 time server.  (123 is the SNTP port number).   
    16. # More servers info can be found at   
    17. #   
    18. #   http://www.eecis.udel.edu/~mills/ntp/servers.htm   
    19. #   
    20. # Note it's considered antisocial to use a stratum 1 server (like NIST)   
    21. for purposes like this which don't need extreme accuracy (i.e. syncing   
    22. # your own big NTP network).  See www.ntp.org for more info.   
    23. #   
    24. # You could also use time.windows.com (Microsoft server) which syncs   
    25. # all Windows XP machines everywhere, so it can presumably handle lots   
    26. # of clients.   
    27.   
    28. # number of seconds between NTP epoch (1900) and Unix epoch (1970).   
    29. TIME1970 = 2208988800L      # Thanks to F.Lundh   
    30.   
    31. client = socket( AF_INET, SOCK_DGRAM )   
    32. data = '\x1b' + 47 * '\0'  
    33. client.sendto(data, time_server)   
    34. data, address = client.recvfrom( 1024 )   
    35. if data:   
    36.     print 'Response received from', address,'\n'  
    37.     t = struct.unpack( '!12I', data )[10]   
    38.     if t == 0:   
    39.         raise 'invalid response'  
    40.     ct = time.ctime(t - TIME1970)   
    41.     print 'Current time = %s\n' % ct   
    42.     if len(sys.argv) > 1 and sys.argv[1] == "--set":   
    43.         os.system("/usr/sbin/hwclock --set '--date=%s'"% ct)   
    44. else:   
    45.     raise 'no data returned'  


    上面這個腳本原址在這里,http://www.nightsong.com/phr/python/setclock.pyhttp://www.bt285.cnhttp://www.guihua.org。使用方式如下:
    $ python setclock.py
    Response received from ('17.151.16.23', 123)

    Current time = Fri Mar  6 16:03:19 2009

    posted on 2009-03-06 19:48 閱讀(2181) 評論(0)  編輯  收藏

    <2009年3月>
    22232425262728
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    導航

    統(tǒng)計

    常用鏈接

    留言簿(3)

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 有色视频在线观看免费高清在线直播 | 亚洲国产精品专区在线观看| 久久久久亚洲AV无码网站| 亚洲视频一区二区在线观看| 国产无遮挡无码视频免费软件| 久久亚洲中文字幕精品一区四| 一级做a爱片特黄在线观看免费看 一级做a爱过程免费视 | 成人亚洲性情网站WWW在线观看| 猫咪免费观看人成网站在线| 又粗又大又长又爽免费视频| 国产成人亚洲毛片| mm1313亚洲精品无码又大又粗| 国产A∨免费精品视频| 久久不见久久见中文字幕免费| 2020亚洲男人天堂精品| 久久精品无码精品免费专区| 亚洲av日韩综合一区在线观看| 久久精品免费观看国产| 久久久婷婷五月亚洲97号色| 成人女人A级毛片免费软件| 亚洲欧洲精品成人久久曰| 国产免费一区二区三区| 亚洲国产乱码最新视频| 高清在线亚洲精品国产二区| a毛片免费在线观看| 亚洲精品白色在线发布| 性xxxx视频免费播放直播| 亚洲国产成人久久| 免费人成视频x8x8入口| 日韩免费电影网站| 伊人久久五月丁香综合中文亚洲| 国产伦一区二区三区免费| 久久免费香蕉视频| 国产偷国产偷亚洲高清日韩 | 日本三级2019在线观看免费| WWW国产亚洲精品久久麻豆| 亚洲区小说区图片区QVOD| 国产大片免费网站不卡美女| 在线精品自拍亚洲第一区| 亚洲第一AAAAA片| 青青草国产免费久久久91|