Author Topic: ntp server set time server style กอล์ฟ@packetlove.com  (Read 6535 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
ntp server set time server style กอล์ฟ@packetlove.com
« on: มกราคม 24, 2011, 11:58:36 AM »
#cd /usr/ports/net/ntp
#make install clean

vi /etc/ntp.conf

#server ntplocal.example.com prefer
#server timeserver.example.org
#server ntp2a.example.net
server clock.nectec.or.th
server 127.127.1.0
server xxx.xxx.com
fudge 127.127.1.0 stratum 13
restrict 202.142.213.0 mask 255.255.255.0

driftfile /var/db/ntp.drift

------------------------------------------------------
#vi /etc/rc.conf
ntpd_enable="YES"
------------------------------------------------------
สั่งให้ service ทำงาน
/etc/rc.d/ntpd stop
/etc/rc.d/ntpd start

###test
#ntpq -p
#ntpdate 202.142.213.172

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ntp server set time server style กอล์ฟ@packetlove.com
« Reply #1 on: มกราคม 24, 2011, 11:58:48 AM »
สำหรับ debian เวลาจะ อัฟเดท เวลาให้ตรงกับเวลา ท้องถิ่นก็

cd /usr/share/zoneinfo/เลือกประเทศ /etc/localtime

แล้วใช้ตำสั่ง
#ntpdate หาserverท้องถิ่น
#ntpdate sg.pool.ntp.org


แค่นี้ครับแล้วลอง ตรวจสอบดู
#date

ตัวย่อประเทศ ต้องตรงกันด้วยน่ะครับ MYT (Malaysia)
จะให้ sync ทุกครั้งที่ restart ใหม่ก็
#vi /etc/rc.local
add

ntpdate sg.pool.ntp.org

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ntp server set time server style กอล์ฟ@packetlove.com
« Reply #2 on: มกราคม 24, 2011, 12:15:00 PM »
วิธีการลง NTP (Network Time Protocol) Server ใน CentOS 5 ครับ

step ที่ 1
#yum install ntp


step 2
# crontab -e


step 3
# vi /etc/ntp.conf
สำหรับบันทัดนี้ มันจะเป็นแหล่งที่เรา ไป sync กับตัว หลัก
server clock.nectec.or.th prefer
บันทัดนี้ สำหรับ server รอง
server 202.142.213.175
อนุญาติให้ ทุกๆ client ติดต่อสั่ง ntpdate ได้
restrict 0.0.0.0 mask 0.0.0.0 nomodify


step 4
# chkconfig ntpd on
# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
(write the sync time to CMOS)

Final
# pgrep ntpd
(checking the ntpd process ID)
# netstat -ntlup
(checking the sync status)
# ntpq -p
(checking the port’s status)
configure the firewall rule, make sure the UDP:123 is accept.
#service ntpd start
(start the ntp server)
Client may get the ntpserver time after 5~10 min.

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ntp server set time server style กอล์ฟ@packetlove.com
« Reply #3 on: มกราคม 24, 2011, 01:53:28 PM »
สำหรับ debian เวลาจะ อัฟเดท เวลาให้ตรงกับเวลา ท้องถิ่นก็

cp /usr/share/zoneinfo/เลือกประเทศ  /etc/localtime

แล้วใช้ตำสั่ง
#ntpdate หาserverท้องถิ่น
#ntpdate sg.pool.ntp.org

ถ้ายังไม่มี tool ntpdate ก็ลงได้โดย
#apt-get install ntpdate

แค่นี้ครับแล้วลอง ตรวจสอบดู
#date

ตัวย่อประเทศ ต้องตรงกันด้วยน่ะครับ MYT (Malaysia)
จะให้ sync ทุกครั้งที่ restart ใหม่ก็
#vi /etc/rc.local
add

ntpdate sg.pool.ntp.org