2018年9月18日 星期二

CentOS NTP 架設


安裝:
[root@ntp ~]# yum install ntp -y

啟動 NTP 服務
[root@ntp ~]# /etc/init.d/ntpd start
Starting ntpd:     [  OK  ]

Linux Iptables Firewall 停用
# /etc/init.d/iptables stop
# chkconfig iptables off

關閉 selinux
# cd /etc/selinux
# vi config
SELINUX=disabled


觀察 NTP 服務的 Port 123
[root@ntp ~]# netstat -tlunp | grep 123
udp        0      0 192.168.0.250:123           0.0.0.0:*     3224/ntpd         
udp        0      0 127.0.0.1:123               0.0.0.0:*     3224/ntpd         
udp        0      0 0.0.0.0:123                 0.0.0.0:*     3224/ntpd         
udp        0      0 ::1:123                     :::*          3224/ntpd         
udp        0      0 fe80::5054:ff:fe00:fa:123   :::*          3224/ntpd         
udp        0      0 :::123                      :::*          3224/ntpd   


設定開機啟動 ntpd
[root@ntp ~]# chkconfig ntpd on

查詢開機是否啟動 ntpd
[root@ntp ~]# chkconfig --list ntpd
ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

確認 NTP 伺服器是否順利更新時間?
[root@demo ~]# ntpstat -p

編輯 ntp.conf 的內容
[root@ntp ~]# vi /var/ntp.conf

restrict tock.stdtime.gov.tw
restrict tick.stdtime.gov.tw
restrict time.stdtime.gov.tw
restrict time1.google.com
restrict time2.google.com
restrict time3.google.com
restrict time4.google.com
restrict 192.168.0.0 mask 255.255.0.0 nomodify -->設定允許的IP網段
restrict 10.168.0.0  mask 255.255.0.0 nomodify

server tock.stdtime.gov.tw prefer
server watch.stdtime.gov.tw prefer
server time.stdtime.gov.tw prefer
server clock.stdtime.gov.tw
server tick.stdtime.gov.tw
server time1.google.com
server time2.google.com
server time3.google.com
server time4.google.com


參考網站 鳥哥的 Linux 私房菜


沒有留言:

張貼留言