Saturday, December 19, 2009

NTP

The Network Time Protocol package contains utilities and daemons that will synchronize your computer's time to Coordinated Universal Time (UTC) via the NTP protocol and NTP servers. 

The NTP packageincludes ntpdate (a program for retrieving the date and time from remote machines via a network) and ntpd (a daemon which continuously adjusts system time).

NTP Server Configuration
Your NTP server contacts a central NTP server (Public Server located at ntp.org, to obtain accurate time data).
The server then allows other machines on your network to request the time data.

Sample Network
192.168.1.10           ==> NTPD Server
201.55.11.1            ==> Remote NTP server
192.168.1.0/24         ==> NTP clients

# vi /etc/ntp.conf
restrict default ignore
//Above will deny all access to any machine, server or client

restrict 202.55.11.1 mask 255.255.255.245 nomodify notrap noquery
server 202.55.11.1

//Configure NTP clients to access your NTP Server
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
//Allow NTP clients to access the Server

NTP Client configuration
# vi /etc/ntp.conf
server 192.168.1.100

Determining If NTP Is Synchronized Properly
# ntpq -p

update NTP manually, but ntp daemon should be off
# ntpdate servername

Local date & time
Date command displays the date and time of the system
# date nnddhhmm[[cc]yy][.ss]
where,
nn = month of the year (01 to 12) 
dd = day of the month (01 to 31) 
hh = hour of the day (00 to 23) 
mm = minute of the hour (00 to 59> 
cc = The first to digits of the year 
yy = The last two digits of the year 
.ss = The seconds 

The hardware clock is the clock that runs in you PC hardware even if you disconnect it from the main power supply, this is because it has a lithium battery.
hwclock command used to set or get the time of you hardware clock

Set the clock you August 8th, 2007 at 21:08 and will tell your clock that is the local time
# hwclock --set --date='08/18/07 21:08:40' --localtime

To check
# hwclock --show

No comments:

Post a Comment