系統剛安裝好,先處理系統時間,從資安的角度來看,系統時間的正確性是基本的查核項目。
在CentOS裏關於時間的命令有date、hwclock,若透過網路更新的話則有ntpdatet可用。
以CentOS-5.6-i386-netinstall.iso以最小安裝為例。
不過,為了一勞永逸,當然是透過網路更新比較省事囉!首先,要先安裝ntp這個套件。
[root@centos5 ~]# yum install ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.tc.edu.tw
* extras: ftp.tc.edu.tw
* updates: ftp.tc.edu.tw
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.i386 0:4.2.2p1-9.el5.centos.2.1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
ntp i386 4.2.2p1-9.el5.centos.2.1 base 1.3 M
Transaction Summary
=========================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 1.3 M
Is this ok [y/N]:
按y繼續囉!
Downloading Packages:
ntp-4.2.2p1-9.el5.centos.2.1.i386.rpm | 1.3 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ntp 1/1
Installed:
ntp.i386 0:4.2.2p1-9.el5.centos.2.1
Complete!
話不多說,趕快同步一下,不過得先挑個伺服器。我慣用的的是tock.stdtime.gov.tw,
[root@centos5 ~]# ntpdate tock.stdtime.gov.tw
5 Jul 14:42:35 ntpdate[2664]: step time server 220.130.158.71 offset 73445.538839 sec
不過也有人建議用pool.ntp.org這個網址,所以上pool.ntp.org網站查了一下,在台灣它有13台伺服器在服務,網站是tw.pool.ntp.org。用ping測試了一下,好像是tock.stdtime.gov.tw回應快了一點點。
C:\Documents and Settings\User>ping tock.stdtime.gov.tw
Pinging tock.stdtime.gov.tw [220.130.158.71] with 32 bytes of data:
Reply from 220.130.158.71: bytes=32 time=8ms TTL=47
Reply from 220.130.158.71: bytes=32 time=9ms TTL=47
Reply from 220.130.158.71: bytes=32 time=8ms TTL=47
Reply from 220.130.158.71: bytes=32 time=8ms TTL=47
Ping statistics for 220.130.158.71:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 8ms, Maximum = 9ms, Average = 8ms
C:\Documents and Settings\User>ping tw.pool.ntp.org
Pinging tw.pool.ntp.org [140.130.175.9] with 32 bytes of data:
Reply from 140.130.175.9: bytes=32 time=10ms TTL=51
Reply from 140.130.175.9: bytes=32 time=10ms TTL=51
Reply from 140.130.175.9: bytes=32 time=10ms TTL=51
Reply from 140.130.175.9: bytes=32 time=9ms TTL=51
Ping statistics for 140.130.175.9:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 9ms, Maximum = 10ms, Average = 9ms