部屬 NTP Server
Oracle Linux 7
- 安裝 ntp 服務
yum install ntp
- /etc/ntp.conf
# 先拒絕IPv4 & IPv6的用戶存取服務
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# 設定需要的時間伺服器進入
restrict 118.163.81.61
restrict 118.163.81.63
restrict 211.22.103.157
# 允許本機與相關網段
restrict 127.0.0.1
restrict ::1
restrict 192.168.56.0 mask 255.255.255.0 nomodify
# 設定校時用的Server,perfer為最優先
server 118.163.81.61 prefer
server 118.163.81.63
server 211.22.103.157
systemctl enable --now ntpd
firewall-cmd --add-port=123/udp --permanent && systemctl restart firewalld
- 檢查有設定成功
ntpq -p
以下為檢查結果
[root@common-server ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*118-163-81-61.h 133.243.238.243 2 u 36 64 17 6.196 21.164 3.700
118-163-81-63.h .FREQ. 1 u 31 64 17 5.608 6.353 3.006
211-22-103-157. 133.243.238.163 2 u 31 64 17 6.611 16.182 1.64
Oracle Linux 8
sudo yum install chrony -y
- /etc/chrony.conf
# 編輯設定檔
sudo vi /etc/chrony.conf
# 找到並加入以下行(例如允許 192.168.1.0/24 網段)
allow 192.168.1.0/24
sudo systemctl enable --now chronyd
chronyc sources
# 開啟防火牆 UDP 123 埠並重新載入
sudo firewall-cmd --add-port=123/udp --permanent
sudo firewall-cmd --reload
# 檢查連線到此伺服器的客戶端
chronyc clients
PolloChang 工作筆記