Ubuntu NTP Client 校時設定

Loading

測試環境 Ubuntu 22.04 (虛擬機)

先前在 CentOS 8 架設了一台 NTP Server ( chronyd – https://benjr.tw/102661 ) , Ubuntu 要怎麼設定連線到這一台 NTP Server , 參考文章 https://medium.com/@nyphoon/%E5%9C%A8-ubuntu-server-22-04-%E8%A8%AD%E5%AE%9A-ntp-server-%E6%A0%A1%E6%99%82-e59c37c5cac5

CentOS 8 NTP Server ( chronyd , IP: 192.168.31.129 ) <- Ubuntu 22.04 NTP Client

安裝 systemd-timesyncd 並啟動服務.

root@ben-virtual-machine:~# apt install systemd-timesyncd
root@ben-virtual-machine:~# timedatectl set-ntp true
root@ben-virtual-machine:~# systemctl enable systemd-timesyncd
root@ben-virtual-machine:~# systemctl start systemd-timesyncd

檢查服務

root@ben-virtual-machine:~# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-06-11 11:03:24 CST; 21min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 2473 (systemd-timesyn)
     Status: "Initial synchronization to time server 192.168.31.129:123 (192.168.31.129)."
      Tasks: 2 (limit: 9388)
     Memory: 1.4M
        CPU: 207ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─2473 /lib/systemd/systemd-timesyncd

修改設定, 指向內部 NTP Server.

root@ben-virtual-machine:~# vi /etc/systemd/timesyncd.conf
[Time]
NTP=192.168.31.129

重啟服務

root@ben-virtual-machine:~# systemctl restart systemd-timesyncd

驗證是否可以連線到 NTP Server.

root@ben-virtual-machine:~# timedatectl show-timesync --all
LinkNTPServers=
SystemNTPServers=192.168.31.129
FallbackNTPServers=ntp.ubuntu.com
ServerName=192.168.31.129
ServerAddress=192.168.31.129
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=1min 4s
NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=2, Precision=-26, RootDelay=29.144ms, RootDispersion=5.966ms, Reference=6FEBF879, OriginateTimestamp=Tue 2024-06-11 11:27:11 CST, ReceiveTimestamp=Tue 2024-06-11 11:27:11 CST, TransmitTimestamp=Tue 2024-06-11 11:27:11 CST, DestinationTimestamp=Tue 2024-06-11 11:27:11 CST, Ignored=no PacketCount=1, Jitter=0 }
Frequency=3418239
沒有解決問題,試試搜尋本站其他內容

One thought on “Ubuntu NTP Client 校時設定

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料