如题所述
å¤ CentOS æå¡å¨
ç°å¨è®©æ们æ¥å¼å§å¨ CentOS ä¸è®¾ç½® NTP æå¡å¨ã
é¦å ï¼æ们éè¦ä¿è¯æ£ç¡®è®¾ç½®äºæå¡å¨çæ¶åºãå¨ CentOS 7 ä¸ï¼æ们å¯ä»¥ä½¿ç¨ timedatectl å½ä»¤æ¥çåæ´æ¹æå¡å¨çæ¶åº(æ¯å¦ï¼"Australia/Adelaide"ï¼LCTT è¯æ³¨ï¼ä¸å½å¯è®¾ç½®ä¸º Asia/Shanghai )
# timedatectl list-timezones | grep Australia
# timedatectl set-timezone Australia/Adelaide
# timedatectl
继ç»å¹¶ä½¿ç¨ yum å®è£ éè¦ç软件
# yum install ntp
ç¶åæ们ä¼æ·»å å ¨ç NTP æå¡å¨ç¨äºåæ¥æ¶é´ã
# vim /etc/ntp.conf
server 0.oceania.pool.ntp.org
server 1.oceania.pool.ntp.org
server 2.oceania.pool.ntp.org
server 3.oceania.pool.ntp.org
é»è®¤æ åµä¸ï¼NTP æå¡å¨çæ¥å¿ä¿åå¨ /var/log/messagesãå¦æä½ å¸æ使ç¨èªå®ä¹çæ¥å¿æ件ï¼é£ä¹å¯ä»¥æå®ã
logfile /var/log/ntpd.log
å¦æä½ éæ©èªå®ä¹æ¥å¿æ件ï¼ç¡®ä¿æ´æ¹äºå®çå±ä¸»å SELinux ç¯å¢ã
# chown ntp:ntp /var/log/ntpd.log
# chcon -t ntpd_log_t /var/log/ntpd.log
ç°å¨åå§å NTP æå¡å¹¶ç¡®ä¿æå®æ·»å å°äºå¼æºå¯å¨ã
# systemctl restart ntp
# systemctl enable ntp
éªè¯ NTP Server æ¶é
æ们å¯ä»¥ä½¿ç¨ ntpq å½ä»¤æ¥æ£æ¥æ¬å°æå¡å¨çæ¶éå¦ä½éè¿ NTP åæ¥ã
æ§å¶å° NTP æå¡å¨ç访é®
é»è®¤æ åµä¸ï¼NTP æå¡å¨å 许æ¥èªææ主æºçæ¥è¯¢ãå¦æä½ æ³è¿æ»¤è¿æ¥ç NTP åæ¥è¿æ¥ï¼ä½ å¯ä»¥å¨ä½ çé²ç«å¢ä¸æ·»å è§åè¿æ»¤æµéã
# iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 123 -j ACCEPT
# iptables -A INPUT -p udp --dport 123 -j DROP
该è§åå è®¸ä» 192.168.1.0/24 æ¥ç NTP æµé(ç«¯å£ UDP/123)ï¼ä»»ä½å ¶å®ç½ç»çæµéä¼è¢«ä¸¢å¼ãä½ å¯ä»¥æ ¹æ®éè¦æ´æ¹è§åã
é ç½® NTP 客æ·ç«¯
1. Linux
NTP 客æ·ç«¯ä¸»æºéè¦ ntpupdate 软件å æ¥åæå¡å¨åæ¥æ¶é´ãå¯ä»¥è½»æ¾å°ä½¿ç¨ yum æ apt-get å®è£ è¿ä¸ªè½¯ä»¶å ãå®è£ å®è½¯ä»¶å ä¹åï¼ç¨æå¡å¨ç IP å°åè¿è¡ä¸é¢çå½ä»¤ã
# ntpdate <server-IP-address>
åºäº RHEL å Debian çç³»ç»å½ä»¤é½ç¸åã
2. Windows
å¦æä½ æ£å¨ä½¿ç¨ Windowsï¼å¨æ¥æåæ¶é´è®¾ç½®(Date and Time settings)ä¸æ¥æ¾ç½ç»æ¶é´(Internet Time)ã
3. Cisco 设å¤
å¦æä½ æ³è¦åæ¥ Cisco 设å¤çæ¶é´ï¼ä½ å¯ä»¥å¨å ¨å±é 置模å¼ä¸ä½¿ç¨ä¸é¢çå½ä»¤ã
# ntp server <server-IP-address>
æ¥èªå ¶å®å家çæ¯æ NTP ç设å¤æèªå·±çç¨äºç½ç»æ¶é´çåæ°ãå¦æä½ æ³å°è®¾å¤å NTPæå¡å¨åæ¥æ¶é´ï¼è¯·æ¥ç设å¤ç说æææ¡£ã
ç»è®º
æ»èè¨ä¹ï¼NTP æ¯å¨ä½ çææ主æºä¸åæ¥æ¶éçä¸ä¸ªåè®®ãæ们已ç»ä»ç»äºå¦ä½è®¾ç½® NTP æå¡å¨å¹¶ä½¿æ¯æ NTP ç设å¤åæå¡å¨åæ¥æ¶é´ã